Fix log spam about CPU frequency on one device
Previous kernels have allowed opening the CPU frequency file regardless
whether the CPU is up or not. This fixes some log spam on one device
with dynamic hot plug CPU feature, which does not allow opening the CPU
frequency file if CPU is down.
Also, since the file descriptors are global and have long lives, add
the close-on-exec flag.
Change-Id: Ia14a2b9e20038dfb96a573920176a47a96bd3f5a
diff --git a/include/cpustats/ThreadCpuUsage.h b/include/cpustats/ThreadCpuUsage.h
index 9cd93d8..9756844 100644
--- a/include/cpustats/ThreadCpuUsage.h
+++ b/include/cpustats/ThreadCpuUsage.h
@@ -131,7 +131,8 @@
uint32_t mCurrentkHz[MAX_CPU]; // current CPU frequency in kHz, not static to avoid a race
static pthread_once_t sOnceControl;
static int sKernelMax; // like MAX_CPU, but determined at runtime == cpu/kernel_max + 1
- static void init();
+ static void init(); // called once at first ThreadCpuUsage construction
+ static pthread_mutex_t sMutex; // protects sScalingFds[] after initialization
};
} // namespace android