public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>,
	Gautham R Shenoy <ego@in.ibm.com>,
	Dipankar Sarma <dipankar@in.ibm.com>, Paul Jackson <pj@sgi.com>
Subject: Re: getting processor numbers
Date: Tue, 3 Apr 2007 15:48:31 -0700	[thread overview]
Message-ID: <20070403154831.37bde672.akpm@linux-foundation.org> (raw)
In-Reply-To: <4612D175.30604@redhat.com>

On Tue, 03 Apr 2007 15:13:09 -0700
Ulrich Drepper <drepper@redhat.com> wrote:

> Andrew Morton wrote:
> > Did we mean to go off-list?
> 
> Oops, no, pressed the wrong button.
> 
> >> Andrew Morton wrote:
> >>> So I'd have thought that in general an application should be querying its
> >>> present affinity mask - something like sched_getaffinity()?  That fixes the
> >>> CPU hotplug issues too, of course.
> >> Does it really?
> >>
> >> My recollection is that the affinity masks of running processes is not
> >> updated on hotplugging.  Is this addressed?
> > 
> > ah, yes, you're correct.
> > 
> > Inside a cpuset:
> > 
> >   sched_setaffinity() is constrained to those CPUs which are in the
> >   cpuset.
> > 
> >   If a cpu if on/offlined we update each cpuset's cpu mask appropriately
> >   but we do not update all the tasks presently running in the cpuset.
> > 
> > Outside a cpuset:
> > 
> >   sched_setaffinity() is constrained to all possible cpus
> > 
> >   We don't update each task's cpus_allowed when a CPU is removed.
> > 
> > 
> > I think we trivially _could_ update each tasks's cpus_allowed mask when a
> > CPU is removed, actually.
> 
> I think it has to be done.  But that's not so trivial.  What happens if
> all the CPUs a process was supposed to be runnable on vanish.
> Shouldn't, if no affinity mask is defined, new processors be added?  I
> agree that if the process has a defined affinity mask no new processors
> should be added _automatically_.
> 

Yes, some policy decision needs to be made there.

But whatever we decide to do, the implementation will be relatively
straightforward, because hot-unplug uses stop_machine_run() and later, we
hope, will use the process freezer.  This setting of the whole machine into
a known state means (I think) that we can avoid a whole lot of fuss which
happens when affinity is altered.

Anyway.  It's not really clear who maintains CPU hotplug nowadays.  <adds a
few cc's>.  But yes, I do thing we should do <something sane> with process
affinity when CPU hot[un]plug happens.

Now it could be argued that the current behaviour is that sane thing: we
allow the process to "pin" itself to not-present CPUs and just handle it in
the CPU scheduler.

Paul, could you please describe what cpusets' policy is in the presence of
CPU additional and removal?

> 
> >> If yes, sched_getaffinity is a solution until the NUMA topology
> >> framework can provide something better.  Even without a popcnt
> >> instruction in the CPU (64-bit albeit) it's twice as fast as the the
> >> stat() method proposed.
> > 
> > I'm surprised - I'd have expected sched_getaffinity() to be vastly quicker
> > that doing fileystem operations.
> 
> You mean because it's only a factor of two?  Well, it's not once you
> count the whole overhead.

Is it kernel overhead, or userspace?  The overhead of counting the bits?

Because sched_getaffinity() could be easily sped up in the case where
it is operating on the current process.


Anyway, where do we stand?  Assuming we can address the CPU hotplug issues,
does sched_getaffinity() look like it will be suitable?

  reply	other threads:[~2007-04-03 22:48 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-03 16:54 getting processor numbers Ulrich Drepper
2007-04-03 17:30 ` linux-os (Dick Johnson)
2007-04-03 17:37   ` Ulrich Drepper
2007-04-03 17:56 ` Dr. David Alan Gilbert
2007-04-03 18:11 ` Andi Kleen
2007-04-03 17:17   ` Ulrich Drepper
2007-04-03 17:22     ` Alan Cox
2007-04-03 17:30       ` Andi Kleen
2007-04-03 20:24         ` Jeremy Fitzhardinge
2007-04-03 17:27     ` Andi Kleen
2007-04-03 17:30       ` Ulrich Drepper
2007-04-03 17:35         ` Andi Kleen
2007-04-03 17:45           ` Ulrich Drepper
2007-04-03 17:58             ` Andi Kleen
2007-04-03 18:05               ` Ulrich Drepper
2007-04-03 18:11                 ` Andi Kleen
2007-04-03 18:21                   ` Ulrich Drepper
2007-04-03 17:44         ` Siddha, Suresh B
2007-04-03 17:59           ` Ulrich Drepper
2007-04-03 19:40             ` Jakub Jelinek
2007-04-03 20:13             ` Ingo Oeser
2007-04-03 23:38               ` J.A. Magallón
2007-04-03 19:55           ` Ulrich Drepper
2007-04-03 20:13             ` Siddha, Suresh B
2007-04-03 20:19               ` Ulrich Drepper
2007-04-03 20:32                 ` Eric Dumazet
2007-04-03 20:20             ` Nathan Lynch
2007-04-03 19:15 ` Davide Libenzi
2007-04-03 19:32   ` Ulrich Drepper
2007-04-04  0:31     ` H. Peter Anvin
2007-04-04  0:35       ` Jeremy Fitzhardinge
2007-04-04  0:38         ` H. Peter Anvin
2007-04-04  5:09           ` Eric Dumazet
2007-04-04  5:16             ` H. Peter Anvin
2007-04-04  5:22               ` Jeremy Fitzhardinge
2007-04-04  5:40                 ` H. Peter Anvin
2007-04-04  5:46                   ` Eric Dumazet
2007-04-04  5:29               ` Eric Dumazet
2007-04-03 20:16 ` Andrew Morton
     [not found]   ` <4612BB89.8040102@redhat.com>
     [not found]     ` <20070403141348.9bcdb13e.akpm@linux-foundation.org>
2007-04-03 22:13       ` Ulrich Drepper
2007-04-03 22:48         ` Andrew Morton [this message]
2007-04-03 23:00           ` Ulrich Drepper
2007-04-03 23:23             ` Andrew Morton
2007-04-03 23:54               ` Ulrich Drepper
2007-04-04  2:55               ` Paul Jackson
2007-04-04  8:39               ` Oleg Nesterov
2007-04-04  9:39                 ` Ingo Molnar
2007-04-04  8:57                   ` Oleg Nesterov
2007-04-04 10:01                     ` Ingo Molnar
2007-04-04  2:58             ` Paul Jackson
2007-04-04  3:04             ` Paul Jackson
2007-04-04  2:52           ` Paul Jackson
2007-04-04  2:04   ` Paul Jackson
2007-04-04  6:47     ` Jakub Jelinek
2007-04-04  7:02       ` Paul Jackson
2007-04-04 14:51       ` Cliff Wickman

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=20070403154831.37bde672.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dipankar@in.ibm.com \
    --cc=drepper@redhat.com \
    --cc=ego@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pj@sgi.com \
    /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