Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1946110AbbEVPzW (ORCPT ); Fri, 22 May 2015 11:55:22 -0400 Received: from mga09.intel.com ([134.134.136.24]:8755 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757939AbbEVPzR convert rfc822-to-8bit (ORCPT ); Fri, 22 May 2015 11:55:17 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,476,1427785200"; d="scan'208";a="730301525" From: "Brown, Len" To: Prarit Bhargava , "linux-kernel@vger.kernel.org" , "linux-pm@vger.kernel.org" CC: "Semin, Andrey" Subject: RE: [PATCH 2/2] turbostat, add set_base_cpu() Thread-Topic: [PATCH 2/2] turbostat, add set_base_cpu() Thread-Index: AQHQlIcG1PMkkNtSxkyAPYW9nu1fwJ2IJFbA Date: Fri, 22 May 2015 15:55:15 +0000 Message-ID: <1A7043D5F58CCB44A599DFD55ED4C9484688E5F2@fmsmsx115.amr.corp.intel.com> References: <1432296063-22185-1-git-send-email-prarit@redhat.com> <1432296063-22185-3-git-send-email-prarit@redhat.com> In-Reply-To: <1432296063-22185-3-git-send-email-prarit@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.1.200.106] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 997 Lines: 36 > +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 -- 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/