From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E365AB6FAF for ; Tue, 1 May 2012 20:46:22 +1000 (EST) Message-ID: <1335869133.13683.125.camel@twins> Subject: Re: [PATCH 1/9] cpu: Introduce clear_tasks_mm_cpumask() helper From: Peter Zijlstra To: Andrew Morton Date: Tue, 01 May 2012 12:45:33 +0200 In-Reply-To: <20120426165911.00cebd31.akpm@linux-foundation.org> References: <20120423070641.GA27702@lizard> <20120423070736.GA30752@lizard> <20120426165911.00cebd31.akpm@linux-foundation.org> Content-Type: text/plain; charset="ISO-8859-1" Mime-Version: 1.0 Cc: linaro-kernel@lists.linaro.org, Mike Frysinger , user-mode-linux-devel@lists.sourceforge.net, linux-sh@vger.kernel.org, Richard Weinberger , linuxppc-dev@lists.ozlabs.org, Oleg Nesterov , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Anton Vorontsov , Paul Mundt , John Stultz , patches@linaro.org, KOSAKI Motohiro , Russell King , uclinux-dist-devel@blackfin.uclinux.org, linux-arm-kernel@lists.infradead.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, 2012-04-26 at 16:59 -0700, Andrew Morton wrote: > > +void clear_tasks_mm_cpumask(int cpu) >=20 > The operation of this function was presumably obvious to you at the > time you wrote it, but that isn't true of other people at later times. >=20 > Please document it? >=20 >=20 > > +{ > > + struct task_struct *p; > > + > > + /* > > + * This function is called after the cpu is taken down and marked > > + * offline, >=20 > hm, well. Who said that this function will only ever be called > after that CPU was taken down? There is nothing in the function name > nor in the (absent) documentation which enforces this precondition. >=20 > If someone tries to use this function for a different purpose, or > copies-and-modifies it for a different purpose, we just shot them in > the foot. >=20 > They'd be pretty dumb to do that without reading the local comment, > but still... Methinks something simple like: WARN_ON(cpu_online(cpu)); Ought to cure that worry, no? :-) >=20 > > so its not like new tasks will ever get this cpu set in > > + * their mm mask. -- Peter Zijlstra > > + * Thus, we may use rcu_read_lock() here, instead of grabbing > > + * full-fledged tasklist_lock. > > + */ > > + rcu_read_lock(); > > + for_each_process(p) { > > + struct task_struct *t; > > + > > + t =3D find_lock_task_mm(p); > > + if (!t) > > + continue; > > + cpumask_clear_cpu(cpu, mm_cpumask(t->mm)); > > + task_unlock(t); > > + } > > + rcu_read_unlock(); > > +}=20