From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753097Ab2AZRXO (ORCPT ); Thu, 26 Jan 2012 12:23:14 -0500 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:59288 "EHLO e23smtp02.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752422Ab2AZRXM (ORCPT ); Thu, 26 Jan 2012 12:23:12 -0500 Message-ID: <4F218BF1.6050303@linux.vnet.ibm.com> Date: Thu, 26 Jan 2012 22:52:57 +0530 From: "Srivatsa S. Bhat" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: Venkatesh Pallipadi CC: KOSAKI Motohiro , Andrew Morton , KOSAKI Motohiro , Mike Travis , "Paul E. McKenney" , "Rafael J. Wysocki" , Paul Gortmaker , linux-kernel@vger.kernel.org Subject: Re: [PATCH] Avoid mask based num_possible_cpus and num_online_cpus -v4 References: <1327447541-3040-1-git-send-email-venki@google.com> In-Reply-To: <1327447541-3040-1-git-send-email-venki@google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit x-cbid: 12012607-5490-0000-0000-0000009F5358 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/25/2012 04:55 AM, Venkatesh Pallipadi wrote: > Kernel's notion of possible cpus (from include/linux/cpumask.h) > * cpu_possible_mask- has bit 'cpu' set iff cpu is populatable > > * The cpu_possible_mask is fixed at boot time, as the set of CPU id's > * that it is possible might ever be plugged in at anytime during the > * life of that system boot. > > #define num_possible_cpus() cpumask_weight(cpu_possible_mask) > > and on x86 cpumask_weight() calls hweight64 and hweight64 (on older kernels > and systems with !X86_FEATURE_POPCNT) or a popcnt based alternative. > > i.e, We needlessly go through this mask based calculation everytime > num_possible_cpus() is called. > > The problem is there with cpu_online_mask() as well, which is fixed value at > boot time in !CONFIG_HOTPLUG_CPU case and should not change that often even > in HOTPLUG case. > > Though most of the callers of these two routines are init time (with few > exceptions of runtime calls), it is cleaner to use variables > and not go through this repeated mask based calculation. > > Signed-off-by: Venkatesh Pallipadi > --- Looks good to me now :-) Acked-by: Srivatsa S. Bhat Regards, Srivatsa S. Bhat