diff options
-rw-r--r-- | aidl/binder/android/os/PersistableBundle.aidl | 2 | ||||
-rw-r--r-- | cmds/cmd/cmd.cpp | 3 | ||||
-rw-r--r-- | cmds/servicemanager/ServiceManager.cpp | 26 | ||||
-rw-r--r-- | cmds/servicemanager/ServiceManager.h | 2 | ||||
-rw-r--r-- | libs/binder/LazyServiceRegistrar.cpp | 29 | ||||
-rw-r--r-- | libs/binder/ndk/test/Android.bp | 3 | ||||
-rw-r--r-- | libs/cputimeinstate/Android.bp | 1 | ||||
-rw-r--r-- | libs/cputimeinstate/cputimeinstate.cpp | 49 | ||||
-rw-r--r-- | libs/cputimeinstate/cputimeinstate.h | 1 | ||||
-rw-r--r-- | libs/cputimeinstate/testtimeinstate.cpp | 11 | ||||
-rw-r--r-- | libs/gui/OWNERS | 5 | ||||
-rw-r--r-- | libs/ui/Android.bp | 6 | ||||
-rw-r--r-- | opengl/libs/Android.bp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/OWNERS | 1 |
14 files changed, 103 insertions, 40 deletions
diff --git a/aidl/binder/android/os/PersistableBundle.aidl b/aidl/binder/android/os/PersistableBundle.aidl index 94e8607630..493ecb414c 100644 --- a/aidl/binder/android/os/PersistableBundle.aidl +++ b/aidl/binder/android/os/PersistableBundle.aidl @@ -17,4 +17,4 @@ package android.os; -parcelable PersistableBundle cpp_header "binder/PersistableBundle.h"; +@JavaOnlyStableParcelable parcelable PersistableBundle cpp_header "binder/PersistableBundle.h"; diff --git a/cmds/cmd/cmd.cpp b/cmds/cmd/cmd.cpp index 7b4aeb2cc2..8dad47502f 100644 --- a/cmds/cmd/cmd.cpp +++ b/cmds/cmd/cmd.cpp @@ -223,7 +223,8 @@ int cmdMain(const std::vector<std::string_view>& argv, TextOutput& outputLog, Te sp<MyResultReceiver> result = new MyResultReceiver(); #if DEBUG - ALOGD("cmd: Invoking %s in=%d, out=%d, err=%d", cmd, in, out, err); + ALOGD("cmd: Invoking %.*s in=%d, out=%d, err=%d", + static_cast<int>(cmd.size()), cmd.data(), in, out, err); #endif // TODO: block until a result is returned to MyResultReceiver. diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp index ae74ac3847..abe64365f3 100644 --- a/cmds/servicemanager/ServiceManager.cpp +++ b/cmds/servicemanager/ServiceManager.cpp @@ -423,11 +423,12 @@ ssize_t ServiceManager::Service::getNodeStrongRefCount() { void ServiceManager::handleClientCallbacks() { for (const auto& [name, service] : mNameToService) { - handleServiceClientCallback(name); + handleServiceClientCallback(name, true); } } -ssize_t ServiceManager::handleServiceClientCallback(const std::string& serviceName) { +ssize_t ServiceManager::handleServiceClientCallback(const std::string& serviceName, + bool isCalledOnInterval) { auto serviceIt = mNameToService.find(serviceName); if (serviceIt == mNameToService.end() || mNameToClientCallback.count(serviceName) < 1) { return -1; @@ -451,14 +452,17 @@ ssize_t ServiceManager::handleServiceClientCallback(const std::string& serviceNa service.guaranteeClient = false; } - if (hasClients && !service.hasClients) { - // client was retrieved in some other way - sendClientCallbackNotifications(serviceName, true); - } + // only send notifications if this was called via the interval checking workflow + if (isCalledOnInterval) { + if (hasClients && !service.hasClients) { + // client was retrieved in some other way + sendClientCallbackNotifications(serviceName, true); + } - // there are no more clients, but the callback has not been called yet - if (!hasClients && service.hasClients) { - sendClientCallbackNotifications(serviceName, false); + // there are no more clients, but the callback has not been called yet + if (!hasClients && service.hasClients) { + sendClientCallbackNotifications(serviceName, false); + } } return count; @@ -518,7 +522,7 @@ Status ServiceManager::tryUnregisterService(const std::string& name, const sp<IB return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE); } - int clients = handleServiceClientCallback(name); + int clients = handleServiceClientCallback(name, false); // clients < 0: feature not implemented or other error. Assume clients. // Otherwise: @@ -527,7 +531,7 @@ Status ServiceManager::tryUnregisterService(const std::string& name, const sp<IB // So, if clients > 2, then at least one other service on the system must hold a refcount. if (clients < 0 || clients > 2) { // client callbacks are either disabled or there are other clients - LOG(INFO) << "Tried to unregister " << name << " but there are clients: " << clients; + LOG(INFO) << "Tried to unregister " << name << ", but there are clients: " << clients; return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE); } diff --git a/cmds/servicemanager/ServiceManager.h b/cmds/servicemanager/ServiceManager.h index 77f52506b9..a2fc5a84c5 100644 --- a/cmds/servicemanager/ServiceManager.h +++ b/cmds/servicemanager/ServiceManager.h @@ -75,7 +75,7 @@ private: void removeRegistrationCallback(const wp<IBinder>& who, ServiceCallbackMap::iterator* it, bool* found); - ssize_t handleServiceClientCallback(const std::string& serviceName); + ssize_t handleServiceClientCallback(const std::string& serviceName, bool isCalledOnInterval); // Also updates mHasClients (of what the last callback was) void sendClientCallbackNotifications(const std::string& serviceName, bool hasClients); // removes a callback from mNameToClientCallback, deleting the entry if the vector is empty diff --git a/libs/binder/LazyServiceRegistrar.cpp b/libs/binder/LazyServiceRegistrar.cpp index dc9482c536..f064bd77ce 100644 --- a/libs/binder/LazyServiceRegistrar.cpp +++ b/libs/binder/LazyServiceRegistrar.cpp @@ -53,14 +53,13 @@ private: struct Service { sp<IBinder> service; - std::string name; bool allowIsolated; int dumpFlags; }; /** - * Number of services that have been registered. + * Map of registered names and services */ - std::vector<Service> mRegisteredServices; + std::map<std::string, Service> mRegisteredServices; }; bool ClientCounterCallback::registerService(const sp<IBinder>& service, const std::string& name, @@ -68,20 +67,24 @@ bool ClientCounterCallback::registerService(const sp<IBinder>& service, const st auto manager = interface_cast<AidlServiceManager>( ProcessState::self()->getContextObject(nullptr)); - ALOGI("Registering service %s", name.c_str()); + bool reRegister = mRegisteredServices.count(name) > 0; + std::string regStr = (reRegister) ? "Re-registering" : "Registering"; + ALOGI("%s service %s", regStr.c_str(), name.c_str()); if (!manager->addService(name.c_str(), service, allowIsolated, dumpFlags).isOk()) { ALOGE("Failed to register service %s", name.c_str()); return false; } - if (!manager->registerClientCallback(name, service, this).isOk()) - { - ALOGE("Failed to add client callback for service %s", name.c_str()); - return false; + if (!manager->registerClientCallback(name, service, this).isOk()) { + ALOGE("Failed to add client callback for service %s", name.c_str()); + return false; } - mRegisteredServices.push_back({service, name, allowIsolated, dumpFlags}); + if (!reRegister) { + // Only add this when a service is added for the first time, as it is not removed + mRegisteredServices[name] = {service, allowIsolated, dumpFlags}; + } return true; } @@ -119,10 +122,11 @@ void ClientCounterCallback::tryShutdown() { for (; unRegisterIt != mRegisteredServices.end(); ++unRegisterIt) { auto& entry = (*unRegisterIt); - bool success = manager->tryUnregisterService(entry.name, entry.service).isOk(); + bool success = manager->tryUnregisterService(entry.first, entry.second.service).isOk(); + if (!success) { - ALOGI("Failed to unregister service %s", entry.name.c_str()); + ALOGI("Failed to unregister service %s", entry.first.c_str()); break; } } @@ -137,7 +141,8 @@ void ClientCounterCallback::tryShutdown() { auto& entry = (*reRegisterIt); // re-register entry - if (!registerService(entry.service, entry.name, entry.allowIsolated, entry.dumpFlags)) { + if (!registerService(entry.second.service, entry.first, entry.second.allowIsolated, + entry.second.dumpFlags)) { // Must restart. Otherwise, clients will never be able to get a hold of this service. ALOGE("Bad state: could not re-register services"); } diff --git a/libs/binder/ndk/test/Android.bp b/libs/binder/ndk/test/Android.bp index ebd08b2f71..daaaa5aa7e 100644 --- a/libs/binder/ndk/test/Android.bp +++ b/libs/binder/ndk/test/Android.bp @@ -90,8 +90,7 @@ cc_test { aidl_interface { name: "IBinderVendorDoubleLoadTest", - // TODO(b/119771576): only vendor is needed - vendor_available: true, + vendor: true, srcs: [ "IBinderVendorDoubleLoadTest.aidl", ], diff --git a/libs/cputimeinstate/Android.bp b/libs/cputimeinstate/Android.bp index a8f7d92b41..b1943a4afd 100644 --- a/libs/cputimeinstate/Android.bp +++ b/libs/cputimeinstate/Android.bp @@ -14,6 +14,7 @@ cc_library { "-Wall", "-Wextra", ], + export_include_dirs: ["."], } cc_test { diff --git a/libs/cputimeinstate/cputimeinstate.cpp b/libs/cputimeinstate/cputimeinstate.cpp index 45fea850aa..037846b4a4 100644 --- a/libs/cputimeinstate/cputimeinstate.cpp +++ b/libs/cputimeinstate/cputimeinstate.cpp @@ -85,6 +85,16 @@ static int comparePolicyFiles(const struct dirent **d1, const struct dirent **d2 return policyN1 - policyN2; } +static int bpf_obj_get_wronly(const char *pathname) { + union bpf_attr attr; + + memset(&attr, 0, sizeof(attr)); + attr.pathname = ptr_to_u64((void *)pathname); + attr.file_flags = BPF_F_WRONLY; + + return syscall(__NR_bpf, BPF_OBJ_GET, &attr, sizeof(attr)); +} + static bool initGlobals() { std::lock_guard<std::mutex> guard(gInitializedMutex); if (gInitialized) return true; @@ -153,17 +163,17 @@ static bool attachTracepointProgram(const std::string &eventType, const std::str bool startTrackingUidTimes() { if (!initGlobals()) return false; - unique_fd fd(bpf_obj_get(BPF_FS_PATH "map_time_in_state_cpu_policy_map")); - if (fd < 0) return false; + unique_fd cpuPolicyFd(bpf_obj_get_wronly(BPF_FS_PATH "map_time_in_state_cpu_policy_map")); + if (cpuPolicyFd < 0) return false; for (uint32_t i = 0; i < gPolicyCpus.size(); ++i) { for (auto &cpu : gPolicyCpus[i]) { - if (writeToMapEntry(fd, &cpu, &i, BPF_ANY)) return false; + if (writeToMapEntry(cpuPolicyFd, &cpu, &i, BPF_ANY)) return false; } } - unique_fd fd2(bpf_obj_get(BPF_FS_PATH "map_time_in_state_freq_to_idx_map")); - if (fd2 < 0) return false; + unique_fd freqToIdxFd(bpf_obj_get_wronly(BPF_FS_PATH "map_time_in_state_freq_to_idx_map")); + if (freqToIdxFd < 0) return false; freq_idx_key_t key; for (uint32_t i = 0; i < gNPolicies; ++i) { key.policy = i; @@ -173,14 +183,41 @@ bool startTrackingUidTimes() { // The uid_times map still uses 0-based indexes, and the sched_switch program handles // conversion between them, so this does not affect our map reading code. uint32_t idx = j + 1; - if (writeToMapEntry(fd2, &key, &idx, BPF_ANY)) return false; + if (writeToMapEntry(freqToIdxFd, &key, &idx, BPF_ANY)) return false; } } + unique_fd cpuLastUpdateFd(bpf_obj_get_wronly(BPF_FS_PATH "map_time_in_state_cpu_last_update_map")); + if (cpuLastUpdateFd < 0) return false; + std::vector<uint64_t> zeros(get_nprocs_conf(), 0); + uint32_t zero = 0; + if (writeToMapEntry(cpuLastUpdateFd, &zero, zeros.data(), BPF_ANY)) return false; + + unique_fd nrActiveFd(bpf_obj_get_wronly(BPF_FS_PATH "map_time_in_state_nr_active_map")); + if (nrActiveFd < 0) return false; + if (writeToMapEntry(nrActiveFd, &zero, &zero, BPF_ANY)) return false; + + unique_fd policyNrActiveFd(bpf_obj_get_wronly(BPF_FS_PATH "map_time_in_state_policy_nr_active_map")); + if (policyNrActiveFd < 0) return false; + for (uint32_t i = 0; i < gNPolicies; ++i) { + if (writeToMapEntry(policyNrActiveFd, &i, &zero, BPF_ANY)) return false; + } + + unique_fd policyFreqIdxFd(bpf_obj_get_wronly(BPF_FS_PATH "map_time_in_state_policy_freq_idx_map")); + if (policyFreqIdxFd < 0) return false; + for (uint32_t i = 0; i < gNPolicies; ++i) { + if (writeToMapEntry(policyFreqIdxFd, &i, &zero, BPF_ANY)) return false; + } + return attachTracepointProgram("sched", "sched_switch") && attachTracepointProgram("power", "cpu_frequency"); } +std::optional<std::vector<std::vector<uint32_t>>> getCpuFreqs() { + if (!gInitialized && !initGlobals()) return {}; + return gPolicyFreqs; +} + // Retrieve the times in ns that uid spent running at each CPU frequency. // Return contains no value on error, otherwise it contains a vector of vectors using the format: // [[t0_0, t0_1, ...], diff --git a/libs/cputimeinstate/cputimeinstate.h b/libs/cputimeinstate/cputimeinstate.h index f620715dab..49469d8e04 100644 --- a/libs/cputimeinstate/cputimeinstate.h +++ b/libs/cputimeinstate/cputimeinstate.h @@ -26,6 +26,7 @@ bool startTrackingUidTimes(); std::optional<std::vector<std::vector<uint64_t>>> getUidCpuFreqTimes(uint32_t uid); std::optional<std::unordered_map<uint32_t, std::vector<std::vector<uint64_t>>>> getUidsCpuFreqTimes(); +std::optional<std::vector<std::vector<uint32_t>>> getCpuFreqs(); struct concurrent_time_t { std::vector<uint64_t> active; diff --git a/libs/cputimeinstate/testtimeinstate.cpp b/libs/cputimeinstate/testtimeinstate.cpp index e82aad89a8..23d87fd646 100644 --- a/libs/cputimeinstate/testtimeinstate.cpp +++ b/libs/cputimeinstate/testtimeinstate.cpp @@ -367,5 +367,16 @@ TEST(TimeInStateTest, RemoveUid) { ASSERT_EQ(allConcurrentTimes->find(uid), allConcurrentTimes->end()); } +TEST(TimeInStateTest, GetCpuFreqs) { + auto freqs = getCpuFreqs(); + ASSERT_TRUE(freqs.has_value()); + + auto times = getUidCpuFreqTimes(0); + ASSERT_TRUE(times.has_value()); + + ASSERT_EQ(freqs->size(), times->size()); + for (size_t i = 0; i < freqs->size(); ++i) EXPECT_EQ((*freqs)[i].size(), (*times)[i].size()); +} + } // namespace bpf } // namespace android diff --git a/libs/gui/OWNERS b/libs/gui/OWNERS index 73150dcb58..c13401dc5c 100644 --- a/libs/gui/OWNERS +++ b/libs/gui/OWNERS @@ -1,7 +1,12 @@ +adyabr@google.com +akrulec@google.com +alecmouri@google.com jessehall@google.com jwcai@google.com lpy@google.com marissaw@google.com mathias@google.com racarr@google.com +steventhomas@google.com stoza@google.com +vhau@google.com diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp index 42b578cce8..080336b890 100644 --- a/libs/ui/Android.bp +++ b/libs/ui/Android.bp @@ -32,12 +32,6 @@ cc_library_shared { sanitize: { integer_overflow: true, misc_undefined: ["bounds"], - diag: { - misc_undefined: ["bounds"], - no_recover: [ - "bounds", - ], - }, }, srcs: [ diff --git a/opengl/libs/Android.bp b/opengl/libs/Android.bp index eb90c8b45b..3c741ab4fb 100644 --- a/opengl/libs/Android.bp +++ b/opengl/libs/Android.bp @@ -161,6 +161,10 @@ cc_library_shared { ], ldflags: ["-Wl,--exclude-libs=ALL"], export_include_dirs: ["EGL/include"], + stubs: { + symbol_file: "libEGL.map.txt", + versions: ["29"], + }, } cc_test { diff --git a/services/surfaceflinger/OWNERS b/services/surfaceflinger/OWNERS index 4ef64b68ae..f2bc65db35 100644 --- a/services/surfaceflinger/OWNERS +++ b/services/surfaceflinger/OWNERS @@ -5,5 +5,6 @@ chaviw@google.com lpy@google.com marissaw@google.com racarr@google.com +steventhomas@google.com stoza@google.com vhau@google.com |