From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763317AbZAPI6z (ORCPT ); Fri, 16 Jan 2009 03:58:55 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755436AbZAPI6p (ORCPT ); Fri, 16 Jan 2009 03:58:45 -0500 Received: from fg-out-1718.google.com ([72.14.220.155]:35089 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754372AbZAPI6o (ORCPT ); Fri, 16 Jan 2009 03:58:44 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; b=xjB4SjtufIp3wnz0+UIpdowDkLO2wYuLcm67RSSAqw3jxvnXQ+1W++jeXyr3rZWvXg SLnC70Lxd0Z0SIhV+7KZwQ0A+iPJ+IUDnyI8UIW2ID2uQ7LWmauLx1r9Th/c4E3Sby2u v18UxC0HpzlJMCw/WCik4LNDH9orb1arKjDC4= Date: Fri, 16 Jan 2009 09:58:39 +0100 From: Frederic Weisbecker To: Lai Jiangshan Cc: Steven Rostedt , Ingo Molnar , Linux Kernel Mailing List Subject: Re: [PATCH -tip] trace_workqueue: use percpu data for workqueue stat Message-ID: <20090116085838.GA7846@nowhere> References: <496F25A8.5040303@cn.fujitsu.com> <49704147.6000003@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <49704147.6000003@cn.fujitsu.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 16, 2009 at 04:11:51PM +0800, Lai Jiangshan wrote: > Frédéric Weisbecker wrote: > > Hi Lai, > > > > 2009/1/15 Lai Jiangshan : > >> Impact: make trace_workqueue works well on NUMA > >> > >> It's not correct when (num_possible_cpus() < nr_cpumask_bits): > >> all_workqueue_stat = kmalloc(sizeof(struct workqueue_global_stats) > >> * num_possible_cpus(), GFP_KERNEL); > > > > > > What is the difference between num_possible_cpus() and nr_cpumask_bits actually? > > It looks like nr_cpumask_bits binds to NR_CPUS on early time and after > > it is set to > > num_possible_cpus() , right? > > In this case num_possible_cpus() seems more relevant...no? > > > > (I'm pretty sure I'm wrong.... :-) > > > > I wanted to reference to nr_cpu_ids, not nr_cpumask_bits(I made mistake yesterday) > > init/main.c > static void __init setup_nr_cpu_ids(void) > { > nr_cpu_ids = find_last_bit(cpumask_bits(cpu_possible_mask),NR_CPUS) + 1; > } > setup_nr_cpu_ids() is called directly in main.c, it's earlier than early_initcall. > > So nr_cpu_ids is better than num_possible_cpus(), for maybe cpu_possible_mask=101B > nr_cpu_ids=3, num_possible_cpus()=2, We will access to invalid memory when we use > num_possible_cpus(). Oh ok I see now. If the cpu_possible_mask is 101, there is a risk I use cpu number 3 later to directly find the index into the table. But I allocated the array in a contiguous way. Thanks I better understand now. > but percpu data as my patch shows is better than nr_cpu_ids. > > Thanks, Lai. > > >