public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: rusty@rustcorp.com.au, linux-kernel@vger.kernel.org,
	Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] cpu_hotplug: don't affect current task's affinity
Date: Wed, 22 Jul 2009 15:02:46 -0700	[thread overview]
Message-ID: <20090722150246.6d28003a.akpm@linux-foundation.org> (raw)
In-Reply-To: <4A5C4626.8000000@cn.fujitsu.com>

On Tue, 14 Jul 2009 16:47:34 +0800
Lai Jiangshan <laijs@cn.fujitsu.com> wrote:

> 
> _cpu_down() changes current task's affinity and then
> recovers it at the end.
> 
> It brings two defects:
> 
> 1) The recovering will failed in some condition.
> 
> # grep Cpus_allowed_list /proc/$$/status
> Cpus_allowed_list:      0-3
> 
> # taskset -pc 2 $$
> pid 29075's current affinity list: 0-3
> pid 29075's new affinity list: 2
> 
> # grep Cpus_allowed_list /proc/$$/status
> Cpus_allowed_list:      2
> 
> # echo 0 > /sys/devices/system/cpu/cpu2/online
> 
> # grep Cpus_allowed_list /proc/$$/status
> Cpus_allowed_list:      0
> 
> In linux, tasks' "Cpus_allowed_list" which are "2" originally
> will become "0-1,3" after the cpu#2 is offlined.
> 
> This "Cpus_allowed_list:      0" is suspicionful.
> 
> 2) current task is a userspace task, the user may change
> its cpu-affinity at the same time. The user may get unexpected
> result if _cpu_down() changes current task's affinity.
> 
> Actually, we don't have to change the affinity.
> We create a kernel thread to do the works.
> 

I've rewritten the description as below.  Can you check it please?

: _cpu_down() changes the current task's affinity and then recovers it at the
: end.
: 
: It has two problems:
: 
: 1) The recovery of the current tasks's cpus_allowed will fail under
:    some conditions.
: 
:    # grep Cpus_allowed_list /proc/$$/status
:    Cpus_allowed_list:      0-3
: 
:    # taskset -pc 2 $$
:    pid 29075's current affinity list: 0-3
:    pid 29075's new affinity list: 2
: 
:    # grep Cpus_allowed_list /proc/$$/status
:    Cpus_allowed_list:      2
: 
:    # echo 0 > /sys/devices/system/cpu/cpu2/online
: 
:    # grep Cpus_allowed_list /proc/$$/status
:    Cpus_allowed_list:      0
: 
:    Here, the Cpus_allowed_list was originally "2" and has become
:    "0-1,3" after cpu #2 is offlined.
: 
:    This "Cpus_allowed_list:      0" is incorrect.
: 
: 2) If the current task is a userspace task, the user may change its
:    cpu-affinity during the CPU hot-unplugging.  This change can be
:    overwritten when _cpu_down() changes the current task's affinity.
: 
: 
: Fix all this by not changing the current tasks's affinity.  Instead we
: create a kernel thread to do the work.



I don't fully understand 1).  You say that the tasks's cpus_allowed has
become "0-1,3".  But it hasn't - it has become "0".

Are you saying that the mask is internally 0-1,3 and that the
/proc/$$/status file is incorrectly displaying it?

Or are you saying that the mask _should_ have been 0-1,3 but the kernel
incorrectly set it to "0"?


Also, it says "The recovery of the current tasks's cpus_allowed will
fail under some conditions".  What are those conditions?

Thanks.

  reply	other threads:[~2009-07-22 22:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-14  8:47 [PATCH] cpu_hotplug: don't affect current task's affinity Lai Jiangshan
2009-07-22 22:02 ` Andrew Morton [this message]
2009-07-23  2:06   ` Lai Jiangshan

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=20090722150246.6d28003a.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rusty@rustcorp.com.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox