From: Prarit Bhargava <prarit@redhat.com>
To: "Brown, Len" <len.brown@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"Semin, Andrey" <andrey.semin@intel.com>
Subject: Re: [PATCH 2/2] turbostat, add set_base_cpu()
Date: Fri, 22 May 2015 18:30:18 -0400 [thread overview]
Message-ID: <555FADFA.609@redhat.com> (raw)
In-Reply-To: <1A7043D5F58CCB44A599DFD55ED4C9484688E5F2@fmsmsx115.amr.corp.intel.com>
On 05/22/2015 11:55 AM, Brown, Len wrote:
>> +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.
Any objection to sched_getcpu()? That way the code is simply
base_cpu = sched_getcpu();
if (base_cpu == -1)
err(-ENODEV, "No valid cpus found");
P.
>
> thanks,
> -Len
>
> ps. patches to turbostat should go to linux-pm@vger.kernel.org
>
>
next prev parent reply other threads:[~2015-05-22 22:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1432296063-22185-1-git-send-email-prarit@redhat.com>
[not found] ` <1432296063-22185-3-git-send-email-prarit@redhat.com>
2015-05-22 15:55 ` [PATCH 2/2] turbostat, add set_base_cpu() Brown, Len
2015-05-22 21:44 ` Prarit Bhargava
2015-05-22 22:30 ` Prarit Bhargava [this message]
2015-05-26 0:32 ` Brown, Len
2015-05-25 12:34 [PATCH 0/2] turbostat, support CPU0 hotplug [v2] Prarit Bhargava
2015-05-25 12:34 ` [PATCH 2/2] turbostat, add set_base_cpu() Prarit Bhargava
2015-05-27 21:54 ` Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=555FADFA.609@redhat.com \
--to=prarit@redhat.com \
--cc=andrey.semin@intel.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).