boost uclamp_min for loading modules in parallel
Unlike loading modules in serial, current parallel method cannot accumlate its utilization so usage of big cpu is really low in heterogeneous system, To make use of big core when we load kernel modules in parallel. we boost uclamp min for these parallel threads. Bug: 288847187 Test: redeuce about 6~10%(30-55ms) loading time for Pixel 7 Change-Id: I55e9ee4294f93b3039d519b5716fa55d58f3d625 Signed-off-by: Chungkai Mei <chungkai@google.com>
This commit is contained in:
parent
df5fad696f
commit
b1488addda
|
@ -19,6 +19,8 @@
|
|||
#include <fnmatch.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
@ -33,6 +35,19 @@
|
|||
#include <android-base/strings.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
|
||||
struct sched_attr {
|
||||
unsigned int size;
|
||||
unsigned int sched_policy;
|
||||
unsigned long long sched_flags;
|
||||
int sched_nice;
|
||||
unsigned int sched_priority;
|
||||
unsigned long long sched_runtime;
|
||||
unsigned long long sched_deadline;
|
||||
unsigned long long sched_period;
|
||||
unsigned int sched_util_min;
|
||||
unsigned int sched_util_max;
|
||||
};
|
||||
|
||||
std::string Modprobe::MakeCanonical(const std::string& module_path) {
|
||||
auto start = module_path.find_last_of('/');
|
||||
if (start == std::string::npos) {
|
||||
|
@ -497,6 +512,17 @@ bool Modprobe::LoadModulesParallel(int num_threads) {
|
|||
|
||||
// Load independent modules in parallel
|
||||
auto thread_function = [&] {
|
||||
#if defined(__NR_sched_setattr) && defined(SCHED_FLAG_RESET_ON_FORK)
|
||||
int pid = getpid();
|
||||
sched_attr attr = {};
|
||||
attr.size = sizeof(attr);
|
||||
attr.sched_flags =
|
||||
(SCHED_FLAG_RESET_ON_FORK | SCHED_FLAG_KEEP_ALL | SCHED_FLAG_UTIL_CLAMP_MIN);
|
||||
attr.sched_util_min = 1024;
|
||||
|
||||
syscall(__NR_sched_setattr, pid, attr, 0);
|
||||
#endif
|
||||
|
||||
std::unique_lock lk(vector_lock);
|
||||
while (!mods_path_to_load.empty()) {
|
||||
auto ret_load = true;
|
||||
|
|
Loading…
Reference in New Issue