lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 16 Jan 2009 09:58:39 +0100
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Lai Jiangshan <laijs@...fujitsu.com>
Cc:	Steven Rostedt <rostedt@...dmis.org>, Ingo Molnar <mingo@...e.hu>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -tip] trace_workqueue: use percpu data for workqueue
	stat

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 <laijs@...fujitsu.com>:
> >> 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.
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ