All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/9] cpu: Introduce clear_tasks_mm_cpumask() helper
Date: Tue, 01 May 2012 10:45:33 +0000	[thread overview]
Message-ID: <1335869133.13683.125.camel@twins> (raw)
In-Reply-To: <20120426165911.00cebd31.akpm@linux-foundation.org>

On Thu, 2012-04-26 at 16:59 -0700, Andrew Morton wrote:
> > +void clear_tasks_mm_cpumask(int cpu)
> 
> 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.
> 
> Please document it?
> 
> 
> > +{
> > +     struct task_struct *p;
> > +
> > +     /*
> > +      * This function is called after the cpu is taken down and marked
> > +      * offline,
> 
> 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.
> 
> 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.
> 
> 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? :-)

> 
> >        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 = find_lock_task_mm(p);
> > +             if (!t)
> > +                     continue;
> > +             cpumask_clear_cpu(cpu, mm_cpumask(t->mm));
> > +             task_unlock(t);
> > +     }
> > +     rcu_read_unlock();
> > +} 

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Anton Vorontsov <anton.vorontsov@linaro.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Russell King <linux@arm.linux.org.uk>,
	Mike Frysinger <vapier@gentoo.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Richard Weinberger <richard@nod.at>,
	Paul Mundt <lethal@linux-sh.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	John Stultz <john.stultz@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org,
	user-mode-linux-devel@lists.sourceforge.net,
	linaro-kernel@lists.linaro.org, patches@linaro.org,
	linux-mm@kvack.org
Subject: Re: [PATCH 1/9] cpu: Introduce clear_tasks_mm_cpumask() helper
Date: Tue, 01 May 2012 12:45:33 +0200	[thread overview]
Message-ID: <1335869133.13683.125.camel@twins> (raw)
In-Reply-To: <20120426165911.00cebd31.akpm@linux-foundation.org>

On Thu, 2012-04-26 at 16:59 -0700, Andrew Morton wrote:
> > +void clear_tasks_mm_cpumask(int cpu)
> 
> 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.
> 
> Please document it?
> 
> 
> > +{
> > +     struct task_struct *p;
> > +
> > +     /*
> > +      * This function is called after the cpu is taken down and marked
> > +      * offline,
> 
> 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.
> 
> 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.
> 
> 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? :-)

> 
> >        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 = find_lock_task_mm(p);
> > +             if (!t)
> > +                     continue;
> > +             cpumask_clear_cpu(cpu, mm_cpumask(t->mm));
> > +             task_unlock(t);
> > +     }
> > +     rcu_read_unlock();
> > +} 

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linaro-kernel@lists.linaro.org,
	Mike Frysinger <vapier@gentoo.org>,
	user-mode-linux-devel@lists.sourceforge.net,
	linux-sh@vger.kernel.org, Richard Weinberger <richard@nod.at>,
	linuxppc-dev@lists.ozlabs.org, Oleg Nesterov <oleg@redhat.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Anton Vorontsov <anton.vorontsov@linaro.org>,
	Paul Mundt <lethal@linux-sh.org>,
	John Stultz <john.stultz@linaro.org>,
	patches@linaro.org,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	Russell King <linux@arm.linux.org.uk>,
	uclinux-dist-devel@blackfin.uclinux.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/9] cpu: Introduce clear_tasks_mm_cpumask() helper
Date: Tue, 01 May 2012 12:45:33 +0200	[thread overview]
Message-ID: <1335869133.13683.125.camel@twins> (raw)
In-Reply-To: <20120426165911.00cebd31.akpm@linux-foundation.org>

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

WARNING: multiple messages have this Message-ID (diff)
From: a.p.zijlstra@chello.nl (Peter Zijlstra)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/9] cpu: Introduce clear_tasks_mm_cpumask() helper
Date: Tue, 01 May 2012 12:45:33 +0200	[thread overview]
Message-ID: <1335869133.13683.125.camel@twins> (raw)
In-Reply-To: <20120426165911.00cebd31.akpm@linux-foundation.org>

On Thu, 2012-04-26 at 16:59 -0700, Andrew Morton wrote:
> > +void clear_tasks_mm_cpumask(int cpu)
> 
> 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.
> 
> Please document it?
> 
> 
> > +{
> > +     struct task_struct *p;
> > +
> > +     /*
> > +      * This function is called after the cpu is taken down and marked
> > +      * offline,
> 
> 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.
> 
> 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.
> 
> 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? :-)

> 
> >        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 = find_lock_task_mm(p);
> > +             if (!t)
> > +                     continue;
> > +             cpumask_clear_cpu(cpu, mm_cpumask(t->mm));
> > +             task_unlock(t);
> > +     }
> > +     rcu_read_unlock();
> > +} 

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Anton Vorontsov <anton.vorontsov@linaro.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Russell King <linux@arm.linux.org.uk>,
	Mike Frysinger <vapier@gentoo.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Richard Weinberger <richard@nod.at>,
	Paul Mundt <lethal@linux-sh.org>,
	KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
	John Stultz <john.stultz@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	uclinux-dist-devel@blackfin.uclinux.org,
	linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org,
	user-mode-linux-devel@lists.sourceforge.net,
	linaro-kernel@lists.linaro.org, patches@linaro.org,
	linux-mm@kvack.org
Subject: Re: [PATCH 1/9] cpu: Introduce clear_tasks_mm_cpumask() helper
Date: Tue, 01 May 2012 12:45:33 +0200	[thread overview]
Message-ID: <1335869133.13683.125.camel@twins> (raw)
In-Reply-To: <20120426165911.00cebd31.akpm@linux-foundation.org>

On Thu, 2012-04-26 at 16:59 -0700, Andrew Morton wrote:
> > +void clear_tasks_mm_cpumask(int cpu)
> 
> 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.
> 
> Please document it?
> 
> 
> > +{
> > +     struct task_struct *p;
> > +
> > +     /*
> > +      * This function is called after the cpu is taken down and marked
> > +      * offline,
> 
> 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.
> 
> 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.
> 
> 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? :-)

> 
> >        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 = find_lock_task_mm(p);
> > +             if (!t)
> > +                     continue;
> > +             cpumask_clear_cpu(cpu, mm_cpumask(t->mm));
> > +             task_unlock(t);
> > +     }
> > +     rcu_read_unlock();
> > +} 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2012-05-01 10:45 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23  7:06 [PATCH v3 0/9] Fixes for common mistakes w/ for_each_process and task->mm Anton Vorontsov
2012-04-23  7:06 ` Anton Vorontsov
2012-04-23  7:06 ` Anton Vorontsov
2012-04-23  7:06 ` Anton Vorontsov
2012-04-23  7:06 ` Anton Vorontsov
2012-04-23  7:07 ` [PATCH 1/9] cpu: Introduce clear_tasks_mm_cpumask() helper Anton Vorontsov
2012-04-23  7:07   ` Anton Vorontsov
2012-04-23  7:07   ` Anton Vorontsov
2012-04-23  7:07   ` Anton Vorontsov
2012-04-23  7:07   ` Anton Vorontsov
2012-04-26 23:59   ` Andrew Morton
2012-04-26 23:59     ` Andrew Morton
2012-04-26 23:59     ` Andrew Morton
2012-04-26 23:59     ` Andrew Morton
2012-04-26 23:59     ` Andrew Morton
2012-04-26 23:59     ` Andrew Morton
2012-05-01 10:45     ` Peter Zijlstra [this message]
2012-05-01 10:45       ` Peter Zijlstra
2012-05-01 10:45       ` Peter Zijlstra
2012-05-01 10:45       ` Peter Zijlstra
2012-05-01 10:45       ` Peter Zijlstra
2012-05-05  1:47       ` [PATCH] cpu: Document clear_tasks_mm_cpumask() Anton Vorontsov
2012-05-05  1:47         ` Anton Vorontsov
2012-05-05  1:47         ` Anton Vorontsov
2012-05-05  1:47         ` Anton Vorontsov
2012-05-05  1:47         ` Anton Vorontsov
2012-05-05  1:47     ` [PATCH 1/9] cpu: Introduce clear_tasks_mm_cpumask() helper Anton Vorontsov
2012-05-05  1:47       ` Anton Vorontsov
2012-05-05  1:47       ` Anton Vorontsov
2012-05-05  1:47       ` Anton Vorontsov
2012-05-05  1:47       ` Anton Vorontsov
2012-04-23  7:08 ` [PATCH 2/9] arm: Use clear_tasks_mm_cpumask() Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08 ` [PATCH 3/9] powerpc: " Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08 ` [PATCH 4/9] sh: " Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:08   ` Anton Vorontsov
2012-04-23  7:09 ` [PATCH 5/9] blackfin: A couple of task->mm handling fixes Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-06-01  4:36   ` Mike Frysinger
2012-06-01  4:36     ` Mike Frysinger
2012-06-01  4:36     ` Mike Frysinger
2012-06-01  4:36     ` Mike Frysinger
2012-04-23  7:09 ` [PATCH 6/9] blackfin: Fix possible deadlock in decode_address() Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09 ` [PATCH 7/9] um: Should hold tasklist_lock while traversing processes Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23 14:57   ` Richard Weinberger
2012-04-23 14:57     ` Richard Weinberger
2012-04-23 14:57     ` Richard Weinberger
2012-04-23 14:57     ` Richard Weinberger
2012-04-23 14:57     ` Richard Weinberger
2012-04-23 15:40     ` Anton Vorontsov
2012-04-23 15:40       ` Anton Vorontsov
2012-04-23 15:40       ` Anton Vorontsov
2012-04-23 15:40       ` Anton Vorontsov
2012-04-23 15:40       ` Anton Vorontsov
2012-04-23  7:09 ` [PATCH 8/9] um: Fix possible race on task->mm Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09 ` [PATCH 9/9] um: Properly check all process' threads for a live mm Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov
2012-04-23  7:09   ` Anton Vorontsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335869133.13683.125.camel@twins \
    --to=a.p.zijlstra@chello.nl \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.