From 246854f524660d3636b45f526172bd587aeb23a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= Date: Mon, 8 Jun 2015 14:11:31 +0200 Subject: [PATCH] functions: optimisation of 'cpus_online' built-in function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now it operates over CPU sets parsed from /sys/devices/system/cpu/online and it no more checks each CPU from the list individually for its online status. Signed-off-by: Jaroslav Škarvada --- tuned/profiles/functions/function_cpus_online.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tuned/profiles/functions/function_cpus_online.py b/tuned/profiles/functions/function_cpus_online.py index d036ba6..925695e 100644 --- a/tuned/profiles/functions/function_cpus_online.py +++ b/tuned/profiles/functions/function_cpus_online.py @@ -17,5 +17,6 @@ class cpus_online(base.Function): def execute(self, args): if not super(self.__class__, self).execute(args): return None - cpus = ",".join(args) - return ",".join(filter(lambda cpu: self._cmd.is_cpu_online(cpu), cpus.split(","))) + cpus = self._cmd.cpulist_unpack(",".join(args)) + online = self._cmd.cpulist_unpack(self._cmd.read_file("/sys/devices/system/cpu/online")) + return ",".join(str(v) for v in set(cpus).intersection(set(online)))