diff options
author | Mark Salyzyn <salyzyn@google.com> | 2019-10-29 08:38:55 -0700 |
---|---|---|
committer | Mark Salyzyn <salyzyn@google.com> | 2019-10-30 07:20:18 -0700 |
commit | 8c1051918e1aaf7610ddb0e6ef5cb6d97abe3d82 (patch) | |
tree | cd2e211b59ec1740d0f55b4e11a4d4164c845aa7 /libmodprobe/libmodprobe_ext.cpp | |
parent | f77c98a7804f7017c9c2c4634a90ce7acab86238 (diff) |
libmodprobe: Do not reload modules previously instantiated
For modprobe operation.
For an interlocking driver set of about 50 modules, the impact of
their dependencies resulted in a 30 second impact in boot time
trying to load previously loaded modules. This impact is handily
eliminated by keeping a list of modules paths that have been loaded
and skipping them proactively.
Test: Confirmed device boot and 50 module set of drivers functions.
Test: libmodprobe_tests
Bug: 142938937
Bug: 140827934
Change-Id: Iccd11399d6043b38cbd5f93578ee202022e7770c
Diffstat (limited to 'libmodprobe/libmodprobe_ext.cpp')
-rw-r--r-- | libmodprobe/libmodprobe_ext.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libmodprobe/libmodprobe_ext.cpp b/libmodprobe/libmodprobe_ext.cpp index 2efcac290..8bebe4c9f 100644 --- a/libmodprobe/libmodprobe_ext.cpp +++ b/libmodprobe/libmodprobe_ext.cpp @@ -30,8 +30,9 @@ bool Modprobe::Insmod(const std::string& path_name, const std::string& parameter return false; } + auto canonical_name = MakeCanonical(path_name); std::string options = ""; - auto options_iter = module_options_.find(MakeCanonical(path_name)); + auto options_iter = module_options_.find(canonical_name); if (options_iter != module_options_.end()) { options = options_iter->second; } @@ -44,6 +45,7 @@ bool Modprobe::Insmod(const std::string& path_name, const std::string& parameter if (ret != 0) { if (errno == EEXIST) { // Module already loaded + module_loaded_.emplace(canonical_name); return true; } LOG(ERROR) << "Failed to insmod '" << path_name << "' with args '" << options << "'"; @@ -51,15 +53,18 @@ bool Modprobe::Insmod(const std::string& path_name, const std::string& parameter } LOG(INFO) << "Loaded kernel module " << path_name; + module_loaded_.emplace(canonical_name); return true; } bool Modprobe::Rmmod(const std::string& module_name) { - int ret = syscall(__NR_delete_module, MakeCanonical(module_name).c_str(), O_NONBLOCK); + auto canonical_name = MakeCanonical(module_name); + int ret = syscall(__NR_delete_module, canonical_name.c_str(), O_NONBLOCK); if (ret != 0) { PLOG(ERROR) << "Failed to remove module '" << module_name << "'"; return false; } + module_loaded_.erase(canonical_name); return true; } |