Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946467AbbEVWaW (ORCPT ); Fri, 22 May 2015 18:30:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51087 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756771AbbEVWaU (ORCPT ); Fri, 22 May 2015 18:30:20 -0400 Message-ID: <555FADFA.609@redhat.com> Date: Fri, 22 May 2015 18:30:18 -0400 From: Prarit Bhargava User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131028 Thunderbird/17.0.10 MIME-Version: 1.0 To: "Brown, Len" CC: "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" , "Semin, Andrey" Subject: Re: [PATCH 2/2] turbostat, add set_base_cpu() References: <1432296063-22185-1-git-send-email-prarit@redhat.com> <1432296063-22185-3-git-send-email-prarit@redhat.com> <1A7043D5F58CCB44A599DFD55ED4C9484688E5F2@fmsmsx115.amr.corp.intel.com> In-Reply-To: <1A7043D5F58CCB44A599DFD55ED4C9484688E5F2@fmsmsx115.amr.corp.intel.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1247 Lines: 49 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 > > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/