Thread (4 messages) 4 messages, 2 authors, 2015-05-26

RE: [PATCH 2/2] turbostat, add set_base_cpu()

From: Brown, Len <hidden>
Date: 2015-05-22 15:55:22
Also in: lkml

+void set_base_cpu(void)
+{
+	int cpu;
+
+	for (cpu = 0; cpu <= topo.max_cpu_num; ++cpu) {
+		if (cpu_is_not_present(cpu))
+			continue;
+		base_cpu = cpu;
+		break;
+	}
+
+	if (base_cpu == -1)
+		err(-ENODEV, "No valid cpus found");
+}

cpu0 hard-coding is indeed arbitrary.
However, so is this proposed replacement, base_cpu.
Either may not match where turbostat is currently running,
and thus could provoke unnecessary cross-calls to get there.

I think it would be better to ask getcpu(2) where we are already running,
and simply use that one.  I think we can call it once and cache it,
as you proposed, rather than multiple system calls.

thanks,
-Len

ps. patches to turbostat should go to linux-pm@vger.kernel.org
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help