27 Jul, 2011

1 commit


25 May, 2011

1 commit

  • Manually adjusting the smp_affinity for IRQ's becomes unwieldy when the
    cpu count is large.

    Setting smp affinity to cpus 256 to 263 would be:

    echo 000000ff,00000000,00000000,00000000,00000000,00000000,00000000,00000000 > smp_affinity

    instead of:

    echo 256-263 > smp_affinity_list

    Think about what it looks like for cpus around say, 4088 to 4095.

    We already have many alternate "list" interfaces:

    /sys/devices/system/cpu/cpuX/indexY/shared_cpu_list
    /sys/devices/system/cpu/cpuX/topology/thread_siblings_list
    /sys/devices/system/cpu/cpuX/topology/core_siblings_list
    /sys/devices/system/node/nodeX/cpulist
    /sys/devices/pci***/***/local_cpulist

    Add a companion interface, smp_affinity_list to use cpu lists instead of
    cpu maps. This conforms to other companion interfaces where both a map
    and a list interface exists.

    This required adding a bitmap_parselist_user() function in a manner
    similar to the bitmap_parse_user() function.

    [akpm@linux-foundation.org: make __bitmap_parselist() static]
    Signed-off-by: Mike Travis
    Cc: Thomas Gleixner
    Cc: Jack Steiner
    Cc: Lee Schermerhorn
    Cc: Andy Shevchenko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Travis
     

07 Mar, 2010

1 commit

  • Dependent on CONFIG_SMP the num_*_cpus() functions return unsigned or
    signed values. Let them always return unsigned values to avoid strange
    casts.

    Fixes at least one warning:

    kernel/kprobes.c: In function 'register_kretprobe':
    kernel/kprobes.c:1038: warning: comparison of distinct pointer types lacks a cast

    Signed-off-by: Heiko Carstens
    Cc: Heiko Carstens
    Cc: Ananth N Mavinakayanahalli
    Cc: Masami Hiramatsu
    Cc: Ingo Molnar
    Cc: Rusty Russell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     

25 Feb, 2010

1 commit

  • Currently, rcu_needs_cpu() simply checks whether the current CPU
    has an outstanding RCU callback, which means that the last CPU
    to go into dyntick-idle mode might wait a few ticks for the
    relevant grace periods to complete. However, if all the other
    CPUs are in dyntick-idle mode, and if this CPU is in a quiescent
    state (which it is for RCU-bh and RCU-sched any time that we are
    considering going into dyntick-idle mode), then the grace period
    is instantly complete.

    This patch therefore repeatedly invokes the RCU grace-period
    machinery in order to force any needed grace periods to complete
    quickly. It does so a limited number of times in order to
    prevent starvation by an RCU callback function that might pass
    itself to call_rcu().

    However, if any CPU other than the current one is not in
    dyntick-idle mode, fall back to simply checking (with fix to bug
    noted by Lai Jiangshan). Also, take advantage of last
    grace-period forcing, the opportunity to do so noted by Steve
    Rostedt. And apply simplified #ifdef condition suggested by
    Frederic Weisbecker.

    Signed-off-by: Paul E. McKenney
    Cc: laijs@cn.fujitsu.com
    Cc: dipankar@in.ibm.com
    Cc: mathieu.desnoyers@polymtl.ca
    Cc: josh@joshtriplett.org
    Cc: dvhltc@us.ibm.com
    Cc: niv@us.ibm.com
    Cc: peterz@infradead.org
    Cc: rostedt@goodmis.org
    Cc: Valdis.Kletnieks@vt.edu
    Cc: dhowells@redhat.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Paul E. McKenney
     

07 Dec, 2009

1 commit

  • Since (e761b77: cpu hotplug, sched: Introduce cpu_active_map and redo
    sched domain managment) we have cpu_active_mask which is suppose to rule
    scheduler migration and load-balancing, except it never (fully) did.

    The particular problem being solved here is a crash in try_to_wake_up()
    where select_task_rq() ends up selecting an offline cpu because
    select_task_rq_fair() trusts the sched_domain tree to reflect the
    current state of affairs, similarly select_task_rq_rt() trusts the
    root_domain.

    However, the sched_domains are updated from CPU_DEAD, which is after the
    cpu is taken offline and after stop_machine is done. Therefore it can
    race perfectly well with code assuming the domains are right.

    Cure this by building the domains from cpu_active_mask on
    CPU_DOWN_PREPARE.

    Signed-off-by: Peter Zijlstra
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

24 Sep, 2009

4 commits

  • The new ones have pretty kerneldoc. Move the old ones to the end to
    avoid confusing people.

    Signed-off-by: Rusty Russell
    Cc: benh@kernel.crashing.org

    Rusty Russell
     
  • We're not forcing removal of the old cpu_ functions, but we might as
    well delete the now-unused ones.

    Especially CPUMASK_ALLOC and friends. I actually got a phone call (!)
    from a hacker who thought I had introduced them as the new cpumask
    API. He seemed bewildered that I had lost all taste.

    Signed-off-by: Rusty Russell
    Cc: benh@kernel.crashing.org

    Rusty Russell
     
  • It's only defined for NR_CPUS > BITS_PER_LONG; cpu_all_mask is always
    defined (and const).

    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • (Thanks to Al Viro for reminding me of this, via Ingo)

    CPU_MASK_ALL is the (deprecated) "all bits set" cpumask, defined as so:

    #define CPU_MASK_ALL (cpumask_t) { { ... } }

    Taking the address of such a temporary is questionable at best,
    unfortunately 321a8e9d (cpumask: add CPU_MASK_ALL_PTR macro) added
    CPU_MASK_ALL_PTR:

    #define CPU_MASK_ALL_PTR (&CPU_MASK_ALL)

    Which formalizes this practice. One day gcc could bite us over this
    usage (though we seem to have gotten away with it so far).

    Now all callers are removed, we kill it.

    Signed-off-by: Rusty Russell
    Acked-by: Ingo Molnar
    Reported-by: Al Viro
    Cc: Mike Travis

    Rusty Russell
     

23 Sep, 2009

1 commit

  • This patch can remove spinlock from struct call_function_data, the
    reasons are below:

    1: add a new interface for cpumask named cpumask_test_and_clear_cpu(),
    it can atomically test and clear specific cpu, we can use it instead
    of cpumask_test_cpu() and cpumask_clear_cpu() and no need data->lock
    to protect those in generic_smp_call_function_interrupt().

    2: in smp_call_function_many(), after csd_lock() return, the current's
    cfd_data is deleted from call_function list, so it not have race
    between other cpus, then cfs_data is only used in
    smp_call_function_many() that must disable preemption and not from
    a hardware interrupthandler or from a bottom half handler to call,
    only the correspond cpu can use it, so it not have race in current
    cpu, no need cfs_data->lock to protect it.

    3: after 1 and 2, cfs_data->lock is only use to protect cfs_data->refs in
    generic_smp_call_function_interrupt(), so we can define cfs_data->refs
    to atomic_t, and no need cfs_data->lock any more.

    Signed-off-by: Xiao Guangrong
    Cc: Ingo Molnar
    Cc: Jens Axboe
    Cc: Nick Piggin
    Cc: Peter Zijlstra
    Acked-by: Rusty Russell
    [akpm@linux-foundation.org: use atomic_dec_return()]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Xiao Guangrong
     

22 Aug, 2009

1 commit

  • When 'and'ing two bitmasks (where 'andnot' is a variation on it), some
    cases want to know whether the result is the empty set or not. In
    particular, the TLB IPI sending code wants to do cpumask operations and
    determine if there are any CPU's left in the final set.

    So this just makes the bitmask (and cpumask) functions return a boolean
    for whether the result has any bits set.

    Cc: stable@kernel.org (2.6.30, needed by TLB shootdown fix)
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

09 Jun, 2009

1 commit


01 Jan, 2009

1 commit


30 Dec, 2008

3 commits

  • They're only for use in boot/cpu hotplug code anyway, and this avoids
    the use of deprecated cpu_*_map.

    Stephen Rothwell points out that gcc 4.2.4 (on powerpc at least)
    didn't like the cast away of const anyway:

    include/linux/cpumask.h: In function 'set_cpu_possible':
    include/linux/cpumask.h:1052: warning: passing argument 2 of 'cpumask_set_cpu' discards qualifiers from pointer target type

    So this kills two birds with one stone.

    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • Changes:
    1) cpumask_t to struct cpumask,
    2) cpus_weight_nr to cpumask_weight,
    3) cpu_isset to cpumask_test_cpu,
    4) ->bits to cpumask_bits()
    5) cpu_*_map to cpu_*_mask.
    6) for_each_cpu_mask_nr to for_each_cpu

    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • Impact: cleanup

    This implements the obsolescent cpu_online_map in terms of
    cpu_online_mask, rather than the other way around. Same for the other
    maps.

    The documentation comments are also updated to refer to _mask rather
    than _map.

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis

    Rusty Russell
     

19 Dec, 2008

1 commit

  • Impact: New API

    This will be needed in x86 code to allocate the domain and old_domain
    cpumasks on the same node as where the containing irq_cfg struct is
    allocated.

    (Also fixes double-dump_stack on rare CONFIG_DEBUG_PER_CPU_MAPS case)

    Signed-off-by: Mike Travis
    Signed-off-by: Rusty Russell (re-impl alloc_cpumask_var)

    Mike Travis
     

13 Dec, 2008

2 commits

  • Impact: futureproof as we convert more code to new APIs

    The old cpumask operators treat all NR_CPUS bits as relevent, the new
    ones use nr_cpumask_bits. For large NR_CPUS and small nr_cpu_ids, this
    makes a difference.

    However, mixing the two can cause problems with undefined bits. An
    arch which sets CONFIG_CPUMASK_OFFSTACK should have converted across
    to the new operators, so it's safe in that case.

    (Thanks to Stephen Rothwell for bisecting the initial unused-bits bug,
    and Mike Travis for this solution).

    Signed-off-by: Rusty Russell
    Cc: Mike Travis

    Rusty Russell
     
  • …t_scnprintf to take pointers.

    Impact: change calling convention of existing cpumask APIs

    Most cpumask functions started with cpus_: these have been replaced by
    cpumask_ ones which take struct cpumask pointers as expected.

    These four functions don't have good replacement names; fortunately
    they're rarely used, so we just change them over.

    Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
    Signed-off-by: Mike Travis <travis@sgi.com>
    Acked-by: Ingo Molnar <mingo@elte.hu>
    Cc: paulus@samba.org
    Cc: mingo@redhat.com
    Cc: tony.luck@intel.com
    Cc: ralf@linux-mips.org
    Cc: Greg Kroah-Hartman <gregkh@suse.de>
    Cc: cl@linux-foundation.org
    Cc: srostedt@redhat.com

    Rusty Russell
     

10 Nov, 2008

1 commit


07 Nov, 2008

1 commit


06 Nov, 2008

1 commit

  • Impact: introduce new APIs

    We want to deprecate cpumasks on the stack, as we are headed for
    gynormous numbers of CPUs. Eventually, we want to head towards an
    undefined 'struct cpumask' so they can never be declared on stack.

    1) New cpumask functions which take pointers instead of copies.
    (cpus_* -> cpumask_*)

    2) Several new helpers to reduce requirements for temporary cpumasks
    (cpumask_first_and, cpumask_next_and, cpumask_any_and)

    3) Helpers for declaring cpumasks on or offstack for large NR_CPUS
    (cpumask_var_t, alloc_cpumask_var and free_cpumask_var)

    4) 'struct cpumask' for explicitness and to mark new-style code.

    5) Make iterator functions stop at nr_cpu_ids (a runtime constant),
    not NR_CPUS for time efficiency and for smaller dynamic allocations
    in future.

    6) cpumask_copy() so we can allocate less than a full cpumask eventually
    (for alloc_cpumask_var), and so we can eliminate the 'struct cpumask'
    definition eventually.

    7) work_on_cpu() helper for doing task on a CPU, rather than saving old
    cpumask for current thread and manipulating it.

    8) smp_call_function_many() which is smp_call_function_mask() except
    taking a cpumask pointer.

    Note that this patch simply introduces the new functions and leaves
    the obsolescent ones in place. This is to simplify the transition
    patches.

    Signed-off-by: Rusty Russell
    Signed-off-by: Ingo Molnar

    Rusty Russell
     

31 Jul, 2008

1 commit

  • when you take the address of the result. Noticed on a sparc64 compile
    using a version 3.4.5 cross compiler.

    kernel/time/tick-common.c: In function `tick_check_new_device':
    kernel/time/tick-common.c:210: error: invalid lvalue in unary `&'
    ...

    Just make it a regular expression.

    Signed-off-by: Stephen Rothwell
    Acked-by: Ingo Molnar
    Signed-off-by: Linus Torvalds

    Stephen Rothwell
     

29 Jul, 2008

1 commit

  • Clean up and optimize cpumask_of_cpu(), by sharing all the zero words.

    Instead of stupidly generating all possible i=0...NR_CPUS 2^i patterns
    creating a huge array of constant bitmasks, realize that the zero words
    can be shared.

    In other words, on a 64-bit architecture, we only ever need 64 of these
    arrays - with a different bit set in one single world (with enough zero
    words around it so that we can create any bitmask by just offsetting in
    that big array). And then we just put enough zeroes around it that we
    can point every single cpumask to be one of those things.

    So when we have 4k CPU's, instead of having 4k arrays (of 4k bits each,
    with one bit set in each array - 2MB memory total), we have exactly 64
    arrays instead, each 8k bits in size (64kB total).

    And then we just point cpumask(n) to the right position (which we can
    calculate dynamically). Once we have the right arrays, getting
    "cpumask(n)" ends up being:

    static inline const cpumask_t *get_cpu_mask(unsigned int cpu)
    {
    const unsigned long *p = cpu_bit_bitmap[1 + cpu % BITS_PER_LONG];
    p -= cpu / BITS_PER_LONG;
    return (const cpumask_t *)p;
    }

    This brings other advantages and simplifications as well:

    - we are not wasting memory that is just filled with a single bit in
    various different places

    - we don't need all those games to re-create the arrays in some dense
    format, because they're already going to be dense enough.

    if we compile a kernel for up to 4k CPU's, "wasting" that 64kB of memory
    is a non-issue (especially since by doing this "overlapping" trick we
    probably get better cache behaviour anyway).

    [ mingo@elte.hu:

    Converted Linus's mails into a commit. See:

    http://lkml.org/lkml/2008/7/27/156
    http://lkml.org/lkml/2008/7/28/320

    Also applied a family filter - which also has the side-effect of leaving
    out the bits where Linus calls me an idio... Oh, never mind ;-)
    ]

    Signed-off-by: Ingo Molnar
    Cc: Rusty Russell
    Cc: Andrew Morton
    Cc: Al Viro
    Cc: Mike Travis
    Signed-off-by: Ingo Molnar

    Linus Torvalds
     

26 Jul, 2008

1 commit

  • If an arch doesn't define cpumask_of_cpu_map, create a generic
    statically-initialized one for them. This allows removal of the buggy
    cpumask_of_cpu() macro (&cpumask_of_cpu() gives address of
    out-of-scope var).

    An arch with NR_CPUS of 4096 probably wants to allocate this itself
    based on the actual number of CPUs, since otherwise they're using 2MB
    of rodata (1024 cpus means 128k). That's what
    CONFIG_HAVE_CPUMASK_OF_CPU_MAP is for (only x86/64 does so at the
    moment).

    In future as we support more CPUs, we'll need to resort to a
    get_cpu_map()/put_cpu_map() allocation scheme.

    Signed-off-by: Mike Travis
    Signed-off-by: Rusty Russell
    Cc: Andrew Morton
    Cc: Jack Steiner
    Signed-off-by: Ingo Molnar

    Mike Travis
     

24 Jul, 2008

1 commit

  • * 'sched/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    sched: hrtick_enabled() should use cpu_active()
    sched, x86: clean up hrtick implementation
    sched: fix build error, provide partition_sched_domains() unconditionally
    sched: fix warning in inc_rt_tasks() to not declare variable 'rq' if it's not needed
    cpu hotplug: Make cpu_active_map synchronization dependency clear
    cpu hotplug, sched: Introduce cpu_active_map and redo sched domain managment (take 2)
    sched: rework of "prioritize non-migratable tasks over migratable ones"
    sched: reduce stack size in isolated_cpu_setup()
    Revert parts of "ftrace: do not trace scheduler functions"

    Fixed up conflicts in include/asm-x86/thread_info.h (due to the
    TIF_SINGLESTEP unification vs TIF_HRTICK_RESCHED removal) and
    kernel/sched_fair.c (due to cpu_active_map vs for_each_cpu_mask_nr()
    introduction).

    Linus Torvalds
     

20 Jul, 2008

1 commit


19 Jul, 2008

2 commits

  • * Provide a generic set of CPUMASK_ALLOC macros patterned after the
    SCHED_CPUMASK_ALLOC macros. This is used where multiple cpumask_t
    variables are declared on the stack to reduce the amount of stack
    space required.

    Signed-off-by: Mike Travis
    Signed-off-by: Ingo Molnar

    Mike Travis
     
  • * This patch replaces the dangerous lvalue version of cpumask_of_cpu
    with new cpumask_of_cpu_ptr macros. These are patterned after the
    node_to_cpumask_ptr macros.

    In general terms, if there is a cpumask_of_cpu_map[] then a pointer to
    the cpumask_of_cpu_map[cpu] entry is used. The cpumask_of_cpu_map
    is provided when there is a large NR_CPUS count, reducing
    greatly the amount of code generated and stack space used for
    cpumask_of_cpu(). The pointer to the cpumask_t value is needed for
    calling set_cpus_allowed_ptr() to reduce the amount of stack space
    needed to pass the cpumask_t value.

    If there isn't a cpumask_of_cpu_map[], then a temporary variable is
    declared and filled in with value from cpumask_of_cpu(cpu) as well as
    a pointer variable pointing to this temporary variable. Afterwards,
    the pointer is used to reference the cpumask value. The compiler
    will optimize out the extra dereference through the pointer as well
    as the stack space used for the pointer, resulting in identical code.

    A good example of the orthogonal usages is in net/sunrpc/svc.c:

    case SVC_POOL_PERCPU:
    {
    unsigned int cpu = m->pool_to[pidx];
    cpumask_of_cpu_ptr(cpumask, cpu);

    *oldmask = current->cpus_allowed;
    set_cpus_allowed_ptr(current, cpumask);
    return 1;
    }
    case SVC_POOL_PERNODE:
    {
    unsigned int node = m->pool_to[pidx];
    node_to_cpumask_ptr(nodecpumask, node);

    *oldmask = current->cpus_allowed;
    set_cpus_allowed_ptr(current, nodecpumask);
    return 1;
    }

    Signed-off-by: Mike Travis
    Signed-off-by: Ingo Molnar

    Mike Travis
     

18 Jul, 2008

1 commit

  • This is based on Linus' idea of creating cpu_active_map that prevents
    scheduler load balancer from migrating tasks to the cpu that is going
    down.

    It allows us to simplify domain management code and avoid unecessary
    domain rebuilds during cpu hotplug event handling.

    Please ignore the cpusets part for now. It needs some more work in order
    to avoid crazy lock nesting. Although I did simplfy and unify domain
    reinitialization logic. We now simply call partition_sched_domains() in
    all the cases. This means that we're using exact same code paths as in
    cpusets case and hence the test below cover cpusets too.
    Cpuset changes to make rebuild_sched_domains() callable from various
    contexts are in the separate patch (right next after this one).

    This not only boots but also easily handles
    while true; do make clean; make -j 8; done
    and
    while true; do on-off-cpu 1; done
    at the same time.
    (on-off-cpu 1 simple does echo 0/1 > /sys/.../cpu1/online thing).

    Suprisingly the box (dual-core Core2) is quite usable. In fact I'm typing
    this on right now in gnome-terminal and things are moving just fine.

    Also this is running with most of the debug features enabled (lockdep,
    mutex, etc) no BUG_ONs or lockdep complaints so far.

    I believe I addressed all of the Dmitry's comments for original Linus'
    version. I changed both fair and rt balancer to mask out non-active cpus.
    And replaced cpu_is_offline() with !cpu_active() in the main scheduler
    code where it made sense (to me).

    Signed-off-by: Max Krasnyanskiy
    Acked-by: Linus Torvalds
    Acked-by: Peter Zijlstra
    Acked-by: Gregory Haskins
    Cc: dmitry.adamushko@gmail.com
    Cc: pj@sgi.com
    Signed-off-by: Ingo Molnar

    Max Krasnyansky
     

06 Jul, 2008

2 commits


05 Jul, 2008

1 commit

  • In linux-next there is a commit ("x86: Add performance variants of cpumask
    operators") which, as part of the 4096 cpu support work adds some new APIs
    for dealing with cpu masks. Add trivial versions of these now so that
    subsystems can update in a timely manner and avoid conflicts in linux-next
    and the next merge window.

    Cc: Mike Travis
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Signed-off-by: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Rothwell
     

24 May, 2008

2 commits

  • The for_each_cpu_mask loop is used quite often in the kernel. It
    makes use of two functions: first_cpu and next_cpu. This patch
    changes for_each_cpu_mask to use only the latter. Because next_cpu
    finds the next eligible cpu _after_ the given one, the iteration
    variable has to be initialized to -1 and next_cpu has to be
    called with this value before the first iteration. An x86_64
    defconfig kernel (from sched/latest) is about 2500 bytes smaller
    with this patch applied:

    text data bss dec hex filename
    6222517 917952 749932 7890401 7865e1 vmlinux.orig
    6219922 917952 749932 7887806 785bbe vmlinux

    The same size reduction is seen for defconfig+MAXSMP

    text data bss dec hex filename
    6241772 2563968 1492716 10298456 9d2458 vmlinux.orig
    6239211 2563968 1492716 10295895 9d1a57 vmlinux

    Signed-off-by: Alexander van Heukelum
    Signed-off-by: Ingo Molnar
    Signed-off-by: Thomas Gleixner

    Alexander van Heukelum
     
  • * Increase performance for systems with large count NR_CPUS by limiting
    the range of the cpumask operators that loop over the bits in a cpumask_t
    variable. This removes a large amount of wasted cpu cycles.

    * Add performance variants of the cpumask operators:

    int cpus_weight_nr(mask) Same using nr_cpu_ids instead of NR_CPUS
    int first_cpu_nr(mask) Number lowest set bit, or nr_cpu_ids
    int next_cpu_nr(cpu, mask) Next cpu past 'cpu', or nr_cpu_ids
    for_each_cpu_mask_nr(cpu, mask) for-loop cpu over mask using nr_cpu_ids

    * Modify following to use performance variants:

    #define num_online_cpus() cpus_weight_nr(cpu_online_map)
    #define num_possible_cpus() cpus_weight_nr(cpu_possible_map)
    #define num_present_cpus() cpus_weight_nr(cpu_present_map)

    #define for_each_possible_cpu(cpu) for_each_cpu_mask_nr((cpu), ...)
    #define for_each_online_cpu(cpu) for_each_cpu_mask_nr((cpu), ...)
    #define for_each_present_cpu(cpu) for_each_cpu_mask_nr((cpu), ...)

    * Comment added to include/linux/cpumask.h:

    Note: The alternate operations with the suffix "_nr" are used
    to limit the range of the loop to nr_cpu_ids instead of
    NR_CPUS when NR_CPUS > 64 for performance reasons.
    If NR_CPUS is
    Cc: Christoph Lameter
    Reviewed-by: Paul Jackson
    Reviewed-by: Christoph Lameter
    Signed-off-by: Mike Travis
    Signed-off-by: Ingo Molnar

    Mike Travis
     

13 May, 2008

1 commit

  • They aren't used. They were briefly used as part of some other patches to
    provide an alternative format for displaying some /proc and /sys cpumasks.
    They probably should have been removed when those other patches were dropped,
    in favor of a different solution.

    Signed-off-by: Paul Jackson
    Cc: "Mike Travis"
    Cc: "Bert Wesarg"
    Cc: Alexey Dobriyan
    Cc: WANG Cong
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Jackson
     

28 Apr, 2008

1 commit

  • The following adds two more bitmap operators, bitmap_onto() and bitmap_fold(),
    with the usual cpumask and nodemask wrappers.

    The bitmap_onto() operator computes one bitmap relative to another. If the
    n-th bit in the origin mask is set, then the m-th bit of the destination mask
    will be set, where m is the position of the n-th set bit in the relative mask.

    The bitmap_fold() operator folds a bitmap into a second that has bit m set iff
    the input bitmap has some bit n set, where m == n mod sz, for the specified sz
    value.

    There are two substantive changes between this patch and its
    predecessor bitmap_relative:
    1) Renamed bitmap_relative() to be bitmap_onto().
    2) Added bitmap_fold().

    The essential motivation for bitmap_onto() is to provide a mechanism for
    converting a cpuset-relative CPU or Node mask to an absolute mask. Cpuset
    relative masks are written as if the current task were in a cpuset whose CPUs
    or Nodes were just the consecutive ones numbered 0..N-1, for some N. The
    bitmap_onto() operator is provided in anticipation of adding support for the
    first such cpuset relative mask, by the mbind() and set_mempolicy() system
    calls, using a planned flag of MPOL_F_RELATIVE_NODES. These bitmap operators
    (and their nodemask wrappers, in particular) will be used in code that
    converts the user specified cpuset relative memory policy to a specific system
    node numbered policy, given the current mems_allowed of the tasks cpuset.

    Such cpuset relative mempolicies will address two deficiencies
    of the existing interface between cpusets and mempolicies:
    1) A task cannot at present reliably establish a cpuset
    relative mempolicy because there is an essential race
    condition, in that the tasks cpuset may be changed in
    between the time the task can query its cpuset placement,
    and the time the task can issue the applicable mbind or
    set_memplicy system call.
    2) A task cannot at present establish what cpuset relative
    mempolicy it would like to have, if it is in a smaller
    cpuset than it might have mempolicy preferences for,
    because the existing interface only allows specifying
    mempolicies for nodes currently allowed by the cpuset.

    Cpuset relative mempolicies are useful for tasks that don't distinguish
    particularly between one CPU or Node and another, but only between how many of
    each are allowed, and the proper placement of threads and memory pages on the
    various CPUs and Nodes available.

    The motivation for the added bitmap_fold() can be seen in the following
    example.

    Let's say an application has specified some mempolicies that presume 16 memory
    nodes, including say a mempolicy that specified MPOL_F_RELATIVE_NODES (cpuset
    relative) nodes 12-15. Then lets say that application is crammed into a
    cpuset that only has 8 memory nodes, 0-7. If one just uses bitmap_onto(),
    this mempolicy, mapped to that cpuset, would ignore the requested relative
    nodes above 7, leaving it empty of nodes. That's not good; better to fold the
    higher nodes down, so that some nodes are included in the resulting mapped
    mempolicy. In this case, the mempolicy nodes 12-15 are taken modulo 8 (the
    weight of the mems_allowed of the confining cpuset), resulting in a mempolicy
    specifying nodes 4-7.

    Signed-off-by: Paul Jackson
    Signed-off-by: David Rientjes
    Cc: Christoph Lameter
    Cc: Andi Kleen
    Cc: Mel Gorman
    Cc: Lee Schermerhorn
    Cc:
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Paul Jackson
     

20 Apr, 2008

3 commits

  • * Here is a simple patch to use an allocated array of cpumasks to
    represent cpumask_of_cpu() instead of constructing one on the stack.
    It's based on the Kconfig option "HAVE_CPUMASK_OF_CPU_MAP" which is
    currently only set for x86_64 SMP. Otherwise the the existing
    cpumask_of_cpu() is used but has been changed to produce an lvalue
    so a pointer to it can be used.

    Cc: H. Peter Anvin
    Signed-off-by: Christoph Lameter
    Signed-off-by: Mike Travis
    Signed-off-by: Ingo Molnar

    Mike Travis
     
  • * Add a static cpumask_t variable "CPU_MASK_ALL_PTR" to use as
    a pointer reference to CPU_MASK_ALL. This reduces where possible
    the instances where CPU_MASK_ALL allocates and fills a large
    array on the stack. Used only if NR_CPUS > BITS_PER_LONG.

    * Change init/main.c to use new set_cpus_allowed_ptr().

    Depends on:
    [sched-devel]: sched: add new set_cpus_allowed_ptr function

    Cc: H. Peter Anvin
    Signed-off-by: Mike Travis
    Signed-off-by: Ingo Molnar

    Mike Travis
     
  • Add a new function cpumask_scnprintf_len() to return the number of
    characters needed to display "len" cpumask bits. The current method
    of allocating NR_CPUS bytes is incorrect as what's really needed is
    9 characters per 32-bit word of cpumask bits (8 hex digits plus the
    seperator [','] or the terminating NULL.) This function provides the
    caller the means to allocate the correct string length.

    Cc: Paul Jackson
    Signed-off-by: Mike Travis
    Signed-off-by: Ingo Molnar

    Mike Travis