From f0426467922bb8cb195de0f73c10ddf9bcf5d835 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Wed, 4 Oct 2017 13:19:26 +0100 Subject: [PATCH] module/hotplug: optimize online_all Optimize online_all by offloading it to a shutils function which only requres a single call to the target. --- devlib/bin/scripts/shutils.in | 16 ++++++++++++++++ devlib/module/hotplug.py | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/devlib/bin/scripts/shutils.in b/devlib/bin/scripts/shutils.in index 004030d..a678a65 100755 --- a/devlib/bin/scripts/shutils.in +++ b/devlib/bin/scripts/shutils.in @@ -195,6 +195,19 @@ cgroups_freezer_set_state() { exit 1 } +################################################################################ +# Hotplug +################################################################################ + +hotplug_online_all() { + PATHS=(/sys/devices/system/cpu/cpu[0-9]*) + for path in "${PATHS[@]}"; do + if [ $(cat $path/online) -eq 0 ]; then + echo 1 > $path/online + fi + done +} + ################################################################################ # Misc ################################################################################ @@ -252,6 +265,9 @@ cgroups_freezer_set_state) ftrace_get_function_stats) ftrace_get_function_stats ;; +hotplug_online_all) + hotplug_online_all + ;; read_tree_values) read_tree_values $* ;; diff --git a/devlib/module/hotplug.py b/devlib/module/hotplug.py index 8ae238e..cfce2e5 100644 --- a/devlib/module/hotplug.py +++ b/devlib/module/hotplug.py @@ -21,7 +21,8 @@ class HotplugModule(Module): return target.path.join(cls.base_path, cpu, 'online') def online_all(self): - self.online(*range(self.target.number_of_cpus)) + self.target._execute_util('hotplug_online_all', + as_root=self.target.is_rooted) def online(self, *args): for cpu in args: