17 Jun, 2011

1 commit

  • There is a problem that kdump(2nd kernel) sometimes hangs up due
    to a pending IPI from 1st kernel. Kernel panic occurs because IPI
    comes before call_single_queue is initialized.

    To fix the crash, rename init_call_single_data() to call_function_init()
    and call it in start_kernel() so that call_single_queue can be
    initialized before enabling interrupts.

    The details of the crash are:

    (1) 2nd kernel boots up

    (2) A pending IPI from 1st kernel comes when irqs are first enabled
    in start_kernel().

    (3) Kernel tries to handle the interrupt, but call_single_queue
    is not initialized yet at this point. As a result, in the
    generic_smp_call_function_single_interrupt(), NULL pointer
    dereference occurs when list_replace_init() tries to access
    &q->list.next.

    Therefore this patch changes the name of init_call_single_data()
    to call_function_init() and calls it before local_irq_enable()
    in start_kernel().

    Signed-off-by: Takao Indoh
    Reviewed-by: WANG Cong
    Acked-by: Neil Horman
    Acked-by: Vivek Goyal
    Acked-by: Peter Zijlstra
    Cc: Milton Miller
    Cc: Jens Axboe
    Cc: Paul E. McKenney
    Cc: kexec@lists.infradead.org
    Link: http://lkml.kernel.org/r/D6CBEE2F420741indou.takao@jp.fujitsu.com
    Signed-off-by: Ingo Molnar

    Takao Indoh
     

26 May, 2011

1 commit


23 Mar, 2011

2 commits

  • Commit 34db18a054c6 ("smp: move smp setup functions to kernel/smp.c")
    causes this build error on s390 because of a missing init.h include:

    CC arch/s390/kernel/asm-offsets.s
    In file included from /home2/heicarst/linux-2.6/arch/s390/include/asm/spinlock.h:14:0,
    from include/linux/spinlock.h:87,
    from include/linux/seqlock.h:29,
    from include/linux/time.h:8,
    from include/linux/timex.h:56,
    from include/linux/sched.h:57,
    from arch/s390/kernel/asm-offsets.c:10:
    include/linux/smp.h:117:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'setup_nr_cpu_ids'
    include/linux/smp.h:118:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'smp_init'

    Fix it by adding the include statement.

    Signed-off-by: Heiko Carstens
    Acked-by: WANG Cong
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     
  • Move setup_nr_cpu_ids(), smp_init() and some other SMP boot parameter
    setup functions from init/main.c to kenrel/smp.c, saves some #ifdef
    CONFIG_SMP.

    Signed-off-by: WANG Cong
    Cc: Rakib Mullick
    Cc: David Howells
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Tejun Heo
    Cc: Arnd Bergmann
    Cc: Akinobu Mita
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Amerigo Wang
     

28 Oct, 2010

1 commit

  • Typedef the pointer to the function to be called by smp_call_function() and
    friends:

    typedef void (*smp_call_func_t)(void *info);

    as it is used in a fair number of places.

    Signed-off-by: David Howells
    cc: linux-arch@vger.kernel.org

    David Howells
     

07 Mar, 2010

1 commit


18 Nov, 2009

1 commit

  • Andrew points out that acpi-cpufreq uses cpumask_any, when it really
    would prefer to use the same CPU if possible (to avoid an IPI). In
    general, this seems a good idea to offer.

    [ tglx: Documented selection preference and Inlined the UP case to
    avoid the copy of smp_call_function_single() and the extra
    EXPORT ]

    Signed-off-by: Rusty Russell
    Cc: Ingo Molnar
    Cc: Venkatesh Pallipadi
    Cc: Len Brown
    Cc: Zhao Yakui
    Cc: Dave Jones
    Cc: Thomas Gleixner
    Cc: Mike Galbraith
    Cc: "Zhang, Yanmin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Rusty Russell
     

24 Sep, 2009

1 commit


17 Jun, 2009

1 commit

  • put_cpu_no_resched() is an optimization of put_cpu() which unfortunately
    can cause high latencies.

    The nfs iostats code uses put_cpu_no_resched() in a code sequence where a
    reschedule request caused by an interrupt between the get_cpu() and the
    put_cpu_no_resched() can delay the reschedule for at least HZ.

    The other users of put_cpu_no_resched() optimize correctly in interrupt
    code, but there is no real harm in using the put_cpu() function which is
    an alias for preempt_enable(). The extra check of the preemmpt count is
    not as critical as the potential source of missing a reschedule.

    Debugged in the preempt-rt tree and verified in mainline.

    Impact: remove a high latency source

    [akpm@linux-foundation.org: build fix]
    Signed-off-by: Thomas Gleixner
    Acked-by: Ingo Molnar
    Cc: Tony Luck
    Cc: Trond Myklebust
    Cc: "J. Bruce Fields"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Gleixner
     

13 Mar, 2009

2 commits


25 Feb, 2009

1 commit

  • Oleg noticed that we don't strictly need CSD_FLAG_WAIT, rework
    the code so that we can use CSD_FLAG_LOCK for both purposes.

    Signed-off-by: Peter Zijlstra
    Cc: Oleg Nesterov
    Cc: Linus Torvalds
    Cc: Nick Piggin
    Cc: Jens Axboe
    Cc: "Paul E. McKenney"
    Cc: Rusty Russell
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

06 Feb, 2009

2 commits


11 Jan, 2009

1 commit

  • If you do

    smp_call_function_single(expression-with-side-effects, ...)

    then expression-with-side-effects never gets evaluated on UP builds.

    As always, implementing it in C is the correct thing to do.

    While we're there, uninline it for size and possible header dependency
    reasons.

    And create a new kernel/up.c, as a place in which to put
    uniprocessor-specific code and storage. It should mirror kernel/smp.c.

    Signed-off-by: Andrew Morton
    Signed-off-by: Ingo Molnar

    Andrew Morton
     

30 Dec, 2008

2 commits

  • Impact: Implementation change to remove cpumask_t from stack.

    Actually change smp_call_function_mask() to smp_call_function_many().
    We avoid cpumasks on the stack in this version.

    (S390 has its own version, but that's going away apparently).

    We have to do some dancing to figure out if 0 or 1 other cpus are in
    the mask supplied and the online mask without allocating a tmp
    cpumask. It's still fairly cheap.

    We allocate the cpumask at the end of the call_function_data
    structure: if allocation fails we fallback to smp_call_function_single
    rather than using the baroque quiescing code (which needs a cpumask on
    stack).

    (Thanks to Hiroshi Shimamoto for spotting several bugs in previous versions!)

    Signed-off-by: Rusty Russell
    Signed-off-by: Mike Travis
    Cc: Hiroshi Shimamoto
    Cc: npiggin@suse.de
    Cc: axboe@kernel.dk

    Rusty Russell
     
  • Rusty Russell
     

19 Dec, 2008

1 commit

  • Impact: add new sysfs files.

    Add sysfs files "kernel_max" and "offline" to display the max CPU index
    allowed (NR_CPUS-1), and the map of cpus that are offline.

    Cpus can be offlined via HOTPLUG, disabled by the BIOS ACPI tables, or
    if they exceed the number of cpus allowed by the NR_CPUS config option,
    or the "maxcpus=NUM" kernel start parameter.

    The "possible_cpus=NUM" parameter can also extend the number of possible
    cpus allowed, in which case the cpus not present at startup will be
    in the offline state. (These cpus can be HOTPLUGGED ON after system
    startup [pending a follow-on patch to provide the capability via the
    /sys/devices/sys/cpu/cpuN/online mechanism to bring them online.])

    By design, the "offlined cpus > possible cpus" display will always
    use the following formats:

    * all possible cpus online: "x$" or "x-y$"
    * some possible cpus offline: ".*,x$" or ".*,x-y$"

    where:
    x == number of possible cpus (nr_cpu_ids); and
    y == number of cpus >= NR_CPUS or maxcpus (if y > x).

    One use of this feature is for distros to select (or configure) the
    appropriate kernel to install for the resident system.

    Notes:
    * cpus offlined possible cpus will only be printed for arches that
    set 'total_cpus' [X86 only in this patch].

    Based on tip/cpus4096 + .../rusty/linux-2.6-for-ingo.git/master +
    x86-only-patches sent 12/15.

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

    Mike Travis
     

16 Dec, 2008

1 commit

  • Otherwise those using it in transition patches (eg. kvm) can't compile
    with CONFIG_SMP=n:

    arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function 'make_all_cpus_request':
    arch/x86/kvm/../../../virt/kvm/kvm_main.c:380: error: implicit declaration of function 'smp_call_function_many'

    Signed-off-by: Rusty Russell
    Signed-off-by: Linus Torvalds

    Rusty Russell
     

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
     

17 Oct, 2008

1 commit


27 Jul, 2008

1 commit

  • A previous patch added the early_initcall(), to allow a cleaner hooking of
    pre-SMP initcalls. Now we remove the older interface, converting all
    existing users to the new one.

    [akpm@linux-foundation.org: cleanups]
    [akpm@linux-foundation.org: build fix]
    [kosaki.motohiro@jp.fujitsu.com: warning fix]
    [kosaki.motohiro@jp.fujitsu.com: warning fix]
    Signed-off-by: Eduard - Gabriel Munteanu
    Cc: Tom Zanussi
    Signed-off-by: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Eduard - Gabriel Munteanu
     

04 Jul, 2008

1 commit

  • forgot to remove #include from linux/smp.h while
    fixing the original s390 build bug.

    Patch below fixes this build bug caused by header inclusion dependencies:

    CC kernel/timer.o
    In file included from include/linux/spinlock.h:87,
    from include/linux/smp.h:11,
    from include/linux/kernel_stat.h:4,
    from kernel/timer.c:22:
    include/asm/spinlock.h: In function '__raw_spin_lock':
    include/asm/spinlock.h:69: error: implicit declaration of function 'smp_processor_id'

    Signed-off-by: Heiko Carstens
    Signed-off-by: Ingo Molnar

    Heiko Carstens
     

26 Jun, 2008

3 commits

  • It's not even passed on to smp_call_function() anymore, since that
    was removed. So kill it.

    Acked-by: Jeremy Fitzhardinge
    Reviewed-by: Paul E. McKenney
    Signed-off-by: Jens Axboe

    Jens Axboe
     
  • It's never used and the comments refer to nonatomic and retry
    interchangably. So get rid of it.

    Acked-by: Jeremy Fitzhardinge
    Signed-off-by: Jens Axboe

    Jens Axboe
     
  • This adds kernel/smp.c which contains helpers for IPI function calls. In
    addition to supporting the existing smp_call_function() in a more efficient
    manner, it also adds a more scalable variant called smp_call_function_single()
    for calling a given function on a single CPU only.

    The core of this is based on the x86-64 patch from Nick Piggin, lots of
    changes since then. "Alan D. Brunelle" has
    contributed lots of fixes and suggestions as well. Also thanks to
    Paul E. McKenney for reviewing RCU usage
    and getting rid of the data allocation fallback deadlock.

    Acked-by: Ingo Molnar
    Reviewed-by: Paul E. McKenney
    Signed-off-by: Jens Axboe

    Jens Axboe
     

30 Jan, 2008

1 commit

  • On VMs implemented using JITs that cache translated code changing the lock
    prefixes is a quite costly operation that forces the JIT to throw away and
    retranslate a lot of code.

    Previously a SMP kernel would rewrite the locks once for each CPU which
    is quite unnecessary. This patch changes the code to never switch at boot in
    the normal case (SMP kernel booting with >1 CPU) or only once for SMP kernel
    on UP.

    This makes a significant difference in boot up performance on AMD SimNow!
    Also I expect it to be a little faster on native systems too because a smp
    switch does a lot of text_poke()s which each synchronize the pipeline.

    v1->v2: Rename max_cpus
    v1->v2: Fix off by one in UP check (Thomas Gleixner)

    Signed-off-by: Andi Kleen
    Signed-off-by: Ingo Molnar
    Signed-off-by: Thomas Gleixner

    Andi Kleen
     

10 Nov, 2007

1 commit

  • fix a !SMP build error:

    drivers/kvm/kvm_main.c: In function 'kvm_flush_remote_tlbs':
    drivers/kvm/kvm_main.c:220: error: implicit declaration of function 'smp_call_function_mask'

    (and also avoid unused function warning related to up_smp_call_function()
    not making use of the 'func' parameter.)

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

18 Jul, 2007

1 commit

  • ... or we end up with header include order problems from hell.

    E.g. on m68k this is 100% fatal - local_irq_enable() there
    wants preempt_count(), which wants task_struct fields, which
    we won't have when we are in smp.h pulled from sched.h.

    Signed-off-by: Al Viro
    Signed-off-by: Linus Torvalds

    Al Viro
     

16 Jul, 2007

1 commit


17 May, 2007

1 commit

  • All architectures that have an implementation of smp_call_function_single
    let it return -EBUSY if it is asked to execute func on the current cpu.
    (akpm: except for x86_64). Therefore the UP version must always return
    -EBUSY.

    [akpm@linux-foundation.org: build fix]
    Signed-off-by: Heiko Carstens
    Cc: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     

10 May, 2007

1 commit

  • With the advent of kdump, the assumption that the boot CPU when booting an UP
    kernel is always the CPU with a particular hardware ID (often 0) (usually
    referred to as BSP on some architectures) is not valid anymore. The reason
    being that the dump capture kernel boots on the crashed CPU (the CPU that
    invoked crash_kexec), which may be or may not be that particular CPU.

    Move definition of hard_smp_processor_id for the UP case to
    architecture-specific code ("asm/smp.h") where it belongs, so that each
    architecture can provide its own implementation.

    Signed-off-by: Fernando Luis Vazquez Cao
    Cc: "Luck, Tony"
    Acked-by: Andi Kleen
    Cc: "Eric W. Biederman"
    Cc: Vivek Goyal
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Fernando Luis Vazquez Cao
     

08 Dec, 2006

1 commit


26 Sep, 2006

1 commit

  • If we're going to implement smp_call_function_single() on three architecture
    with the same prototype then it should have a declaration in a
    non-arch-specific header file.

    Move it into .

    Cc: Stephane Eranian
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

01 Jul, 2006

1 commit

  • Presently, smp_processor_id() isn't necessarily set up until setup_arch().
    But it's used in boot_cpu_init() and printk() and perhaps in other places,
    prior to setup_arch() being called.

    So provide a new smp_setup_processor_id() which is called before anything
    else, wire it up for Voyager (which boots on a CPU other than #0, and broke).

    Cc: James Bottomley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

26 Apr, 2006

1 commit


27 Mar, 2006

1 commit


22 Mar, 2006

1 commit

  • When on_each_cpu() runs the callback on other CPUs, it runs with local
    interrupts disabled. So we should run the function with local interrupts
    disabled on this CPU, too.

    And do the same for UP, so the callback is run in the same environment on both
    UP and SMP. (strictly it should do preempt_disable() too, but I think
    local_irq_disable is sufficiently equivalent).

    Also uninlines on_each_cpu(). softirq.c was the most appropriate file I could
    find, but it doesn't seem to justify creating a new file.

    Oh, and fix up that comment over (under?) x86's smp_call_function(). It
    drives me nuts.

    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

08 Feb, 2006

1 commit


24 Nov, 2005

1 commit