1. 18 7月, 2008 2 次提交
    • M
      cpu hotplug: Make cpu_active_map synchronization dependency clear · 39b0fad7
      Max Krasnyansky 提交于
      This goes on top of the cpu_active_map (take 2) patch.
      
      Currently we depend on the stop_machine to provide nescessesary
      synchronization for the cpu_active_map updates.
      As Dmitry Adamushko pointed this is fragile and is not much clearer
      than the previous scheme. In other words we do not want to depend on
      the internal stop machine operation here.
      So make the synchronization rules clear by doing synchronize_sched()
      after clearing out cpu active bit.
      
      Tested on quad-Core2 with:
      
         while true; do
            for i in 1 2 3; do
              echo 0 > /sys/devices/system/cpu/cpu$i/online
            done
            for i in 1 2 3; do
              echo 1 > /sys/devices/system/cpu/cpu$i/online
            done
         done
      and
         stress -c 200
      
      No lockdep, preempt or other complaints.
      Signed-off-by: NMax Krasnyansky <maxk@qualcomm.com>
      Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      39b0fad7
    • M
      cpu hotplug, sched: Introduce cpu_active_map and redo sched domain managment (take 2) · e761b772
      Max Krasnyansky 提交于
      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: NMax Krasnyanskiy <maxk@qualcomm.com>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Acked-by: NGregory Haskins <ghaskins@novell.com>
      Cc: dmitry.adamushko@gmail.com
      Cc: pj@sgi.com
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      e761b772
  2. 17 7月, 2008 1 次提交
  3. 06 6月, 2008 1 次提交
  4. 24 5月, 2008 1 次提交
  5. 30 4月, 2008 1 次提交
  6. 29 4月, 2008 4 次提交
    • O
      simplify cpu_hotplug_begin()/put_online_cpus() · d2ba7e2a
      Oleg Nesterov 提交于
      cpu_hotplug_begin() must be always called under cpu_add_remove_lock, this
      means that only one process can be cpu_hotplug.active_writer.  So we don't
      need the cpu_hotplug.writer_queue, we can wake up the ->active_writer
      directly.
      
      Also, fix the comment.
      Signed-off-by: NOleg Nesterov <oleg@tv-sign.ru>
      Cc: Dipankar Sarma <dipankar@in.ibm.com>
      Acked-by: NGautham R Shenoy <ego@in.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      d2ba7e2a
    • S
      cpu: fix section mismatch warning in reference to register_cpu_notifier · f7b16c10
      Sam Ravnborg 提交于
      Fix following warnings:
      WARNING: vmlinux.o(.text+0xc60): Section mismatch in reference from the function kvm_init() to the function .cpuinit.text:register_cpu_notifier()
      WARNING: vmlinux.o(.text+0x33869a): Section mismatch in reference from the function xfs_icsb_init_counters() to the function .cpuinit.text:register_cpu_notifier()
      WARNING: vmlinux.o(.text+0x5556a1): Section mismatch in reference from the function acpi_processor_install_hotplug_notify() to the function .cpuinit.text:register_cpu_notifier()
      WARNING: vmlinux.o(.text+0xfe6b28): Section mismatch in reference from the function cpufreq_register_driver() to the function .cpuinit.text:register_cpu_notifier()
      
      register_cpu_notifier() are only really defined when HOTPLUG_CPU is enabled.
      So references to the function are OK.
      
      Annotate it with __ref so we do not get warnings from callers and do not get
      warnings for the functions/data used by register_cpu_notifier().
      Signed-off-by: NSam Ravnborg <sam@ravnborg.org>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f7b16c10
    • S
      cpu: fix section mismatch warnings in *cpu_down · 514a20a5
      Sam Ravnborg 提交于
      Fix following warnings:
      WARNING: vmlinux.o(.text+0x75c8d): Section mismatch in reference from the function take_cpu_down() to the variable .cpuinit.data:cpu_chain
      WARNING: vmlinux.o(.text+0x75d2a): Section mismatch in reference from the function _cpu_down() to the variable .cpuinit.data:cpu_chain
      WARNING: vmlinux.o(.text+0x75d4d): Section mismatch in reference from the function _cpu_down() to the variable .cpuinit.data:cpu_chain
      WARNING: vmlinux.o(.text+0x75de4): Section mismatch in reference from the function _cpu_down() to the variable .cpuinit.data:cpu_chain
      WARNING: vmlinux.o(.text+0x75e33): Section mismatch in reference from the function _cpu_down() to the variable .cpuinit.data:cpu_chain
      
      cpu_down is only used from code surrounded by HOTPLUG_CPU so any references to
      __cpuinit is OK.
      
      Add a few __ref to tech modpost to ignore the references.
      
      This is just papering over the fact that the cpu hotplug code is fragile with
      respect to use of HOTPLUG_CPU and in many cases rely on __cpuinit to get rid
      of code when HOTPLUG_CPU is not enabled.  For now this is the least invasive
      change.
      Signed-off-by: NSam Ravnborg <sam@ravnborg.org>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      514a20a5
    • S
      cpu: fix section mismatch warning in unregister_cpu_notifier · 9647155f
      Sam Ravnborg 提交于
      Fix following warning:
      WARNING: vmlinux.o(.text+0x75f4e): Section mismatch in reference from the function unregister_cpu_notifier() to the variable .cpuinit.data:cpu_chain
      
      We know that unregister_cpu_notifier is using HOTPLUG_CPU
      stuff - so ignore these references.
      Annotating unregister_cpu_notifier had been another option
      but this caused far more warnings since not all callers were
      annotated __cpuinit.
      Signed-off-by: NSam Ravnborg <sam@ravnborg.org>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9647155f
  7. 20 4月, 2008 1 次提交
    • M
      generic: use new set_cpus_allowed_ptr function · f70316da
      Mike Travis 提交于
        * Use new set_cpus_allowed_ptr() function added by previous patch,
          which instead of passing the "newly allowed cpus" cpumask_t arg
          by value,  pass it by pointer:
      
          -int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
          +int set_cpus_allowed_ptr(struct task_struct *p, const cpumask_t *new_mask)
      
        * Modify CPU_MASK_ALL
      
      Depends on:
      	[sched-devel]: sched: add new set_cpus_allowed_ptr function
      Signed-off-by: NMike Travis <travis@sgi.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      f70316da
  8. 09 2月, 2008 1 次提交
  9. 26 1月, 2008 3 次提交
  10. 20 10月, 2007 2 次提交
  11. 19 10月, 2007 1 次提交
    • A
      cpu hotplug: cpu: deliver CPU_UP_CANCELED only to NOTIFY_OKed callbacks with CPU_UP_PREPARE · a0d8cdb6
      Akinobu Mita 提交于
      The functions in a CPU notifier chain is called with CPU_UP_PREPARE event
      before making the CPU online.  If one of the callback returns NOTIFY_BAD, it
      stops to deliver CPU_UP_PREPARE event, and CPU online operation is canceled.
      Then CPU_UP_CANCELED event is delivered to the functions in a CPU notifier
      chain again.
      
      This CPU_UP_CANCELED event is delivered to the functions which have been
      called with CPU_UP_PREPARE, not delivered to the functions which haven't been
      called with CPU_UP_PREPARE.
      
      The problem that makes existing cpu hotplug error handlings complex is that
      the CPU_UP_CANCELED event is delivered to the function that has returned
      NOTIFY_BAD, too.
      
      Usually we don't expect to call destructor function against the object that
      has failed to initialize.  It is like:
      
      	err = register_something();
      	if (err) {
      		unregister_something();
      		return err;
      	}
      
      So it is natural to deliver CPU_UP_CANCELED event only to the functions that
      have returned NOTIFY_OK with CPU_UP_PREPARE event and not to call the function
      that have returned NOTIFY_BAD.  This is what this patch is doing.
      
      Otherwise, every cpu hotplug notifiler has to track whether notifiler event is
      failed or not for each cpu.  (drivers/base/topology.c is doing this with
      topology_dev_map)
      
      Similary this patch makes same thing with CPU_DOWN_PREPARE and CPU_DOWN_FAILED
      evnets.
      Acked-by: NRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: NAkinobu Mita <akinobu.mita@gmail.com>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a0d8cdb6
  12. 31 8月, 2007 1 次提交
  13. 16 7月, 2007 1 次提交
    • A
      HOTPLUG: Add CPU_DYING notifier · db912f96
      Avi Kivity 提交于
      KVM wants a notification when a cpu is about to die, so it can disable
      hardware extensions, but at a time when user processes cannot be scheduled
      on the cpu, so it doesn't try to use virtualization extensions after they
      have been disabled.
      
      This adds a CPU_DYING notification.  The notification is called in atomic
      context on the doomed cpu.
      Signed-off-by: NAvi Kivity <avi@qumranet.com>
      db912f96
  14. 10 5月, 2007 5 次提交
    • R
      microcode: use suspend-related CPU hotplug notifications · 455c017a
      Rafael J. Wysocki 提交于
      Make the microcode driver use the suspend-related CPU hotplug notifications
      to handle the CPU hotplug events occuring during system-wide suspend and
      resume transitions.  Remove the global variable suspend_cpu_hotplug
      previously used for this purpose.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      455c017a
    • R
      Add suspend-related notifications for CPU hotplug · 8bb78442
      Rafael J. Wysocki 提交于
      Since nonboot CPUs are now disabled after tasks and devices have been
      frozen and the CPU hotplug infrastructure is used for this purpose, we need
      special CPU hotplug notifications that will help the CPU-hotplug-aware
      subsystems distinguish normal CPU hotplug events from CPU hotplug events
      related to a system-wide suspend or resume operation in progress.  This
      patch introduces such notifications and causes them to be used during
      suspend and resume transitions.  It also changes all of the
      CPU-hotplug-aware subsystems to take these notifications into consideration
      (for now they are handled in the same way as the corresponding "normal"
      ones).
      
      [oleg@tv-sign.ru: cleanups]
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Cc: Gautham R Shenoy <ego@in.ibm.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Signed-off-by: NOleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8bb78442
    • G
      Remove kthread_bind() call from _cpu_down() · 7b0834c2
      Gautham R Shenoy 提交于
      We are anyway kthread_stop()ping other per-cpu kernel threads after
      move_task_off_dead_cpu(), so we can do it with the stop_machine_run thread
      as well.
      
      I just checked with Vatsa if there was any subtle reason why they
      had put in the kthread_bind() in cpu.c. Vatsa cannot seem to recollect
      any and I can't see any. So let us just remove the kthread_bind.
      Signed-off-by: NGautham R Shenoy <ego@in.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7b0834c2
    • H
      call cpu_chain with CPU_DOWN_FAILED if CPU_DOWN_PREPARE failed · e7407dcc
      Heiko Carstens 提交于
      This makes cpu hotplug symmetrical: if CPU_UP_PREPARE fails we get
      CPU_UP_CANCELED, so we can undo what ever happened on PREPARE.  The same
      should happen for CPU_DOWN_PREPARE.
      
      [akpm@linux-foundation.org: fix for reduce-size-of-task_struct-on-64-bit-machines]
      Cc: Srivatsa Vaddagiri <vatsa@in.ibm.com>
      Cc: Gautham Shenoy <ego@in.ibm.com>
      Signed-off-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e7407dcc
    • G
      Define and use new events,CPU_LOCK_ACQUIRE and CPU_LOCK_RELEASE · baaca49f
      Gautham R Shenoy 提交于
      This is an attempt to provide an alternate mechanism for postponing
      a hotplug event instead of using a global mechanism like lock_cpu_hotplug.
      
      The proposal is to add two new events namely CPU_LOCK_ACQUIRE and
      CPU_LOCK_RELEASE. The notification for these two events would be sent
      out before and after a cpu_hotplug event respectively.
      
      During the CPU_LOCK_ACQUIRE event, a cpu-hotplug-aware subsystem is
      supposed to acquire any per-subsystem hotcpu mutex ( Eg. workqueue_mutex
      in kernel/workqueue.c ).
      
      During the CPU_LOCK_RELEASE release event the cpu-hotplug-aware subsystem
      is supposed to release the per-subsystem hotcpu mutex.
      
      The reasons for defining new events as opposed to reusing the existing events
      like CPU_UP_PREPARE/CPU_UP_FAILED/CPU_ONLINE for locking/unlocking of
      per-subsystem hotcpu mutexes are as follow:
      
      	- CPU_LOCK_ACQUIRE: All hotcpu mutexes are taken before subsystems
      	start handling pre-hotplug events like CPU_UP_PREPARE/CPU_DOWN_PREPARE
      	etc, thus ensuring a clean handling of these events.
      
      	- CPU_LOCK_RELEASE: The hotcpu mutexes will be released only after
      	all subsystems have handled post-hotplug events like CPU_DOWN_FAILED,
      	CPU_DEAD,CPU_ONLINE etc thereby ensuring that there are no subsequent
      	clashes amongst the interdependent subsystems after a cpu hotplugs.
      
      This patch also uses __raw_notifier_call chain in _cpu_up to take care
      of the dependency between the two consequetive calls to
      raw_notifier_call_chain.
      
      [akpm@linux-foundation.org: fix a bug]
      Signed-off-by: NGautham R Shenoy <ego@in.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      baaca49f
  15. 03 4月, 2007 1 次提交
    • R
      [PATCH] Fix microcode-related suspend problem · 1d64b9cb
      Rafael J. Wysocki 提交于
      Fix the regression resulting from the recent change of suspend code
      ordering that causes systems based on Intel x86 CPUs using the microcode
      driver to hang during the resume.
      
      The problem occurs since the microcode driver uses request_firmware() in
      its CPU hotplug notifier, which is called after tasks has been frozen and
      hangs.  It can be fixed by telling the microcode driver to use the
      microcode stored in memory during the resume instead of trying to load it
      from disk.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Adrian Bunk <bunk@stusta.de>
      Cc: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Maxim <maximlevitsky@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1d64b9cb
  16. 12 2月, 2007 1 次提交
  17. 12 1月, 2007 1 次提交
    • G
      [PATCH] Change cpu_up and co from __devinit to __cpuinit · b282b6f8
      Gautham R Shenoy 提交于
      Compiling the kernel with CONFIG_HOTPLUG = y and CONFIG_HOTPLUG_CPU = n
      with CONFIG_RELOCATABLE = y generates the following modpost warnings
      
      WARNING: vmlinux - Section mismatch: reference to .init.data: from
      .text between '_cpu_up' (at offset 0xc0141b7d) and 'cpu_up'
      WARNING: vmlinux - Section mismatch: reference to .init.data: from
      .text between '_cpu_up' (at offset 0xc0141b9c) and 'cpu_up'
      WARNING: vmlinux - Section mismatch: reference to .init.text:__cpu_up
      from .text between '_cpu_up' (at offset 0xc0141bd8) and 'cpu_up'
      WARNING: vmlinux - Section mismatch: reference to .init.data: from
      .text between '_cpu_up' (at offset 0xc0141c05) and 'cpu_up'
      WARNING: vmlinux - Section mismatch: reference to .init.data: from
      .text between '_cpu_up' (at offset 0xc0141c26) and 'cpu_up'
      WARNING: vmlinux - Section mismatch: reference to .init.data: from
      .text between '_cpu_up' (at offset 0xc0141c37) and 'cpu_up'
      
      This is because cpu_up, _cpu_up and __cpu_up (in some architectures) are
      defined as __devinit
      AND
      __cpu_up calls some __cpuinit functions.
      
      Since __cpuinit would map to __init with this kind of a configuration,
      we get a .text refering .init.data warning.
      
      This patch solves the problem by converting all of __cpu_up, _cpu_up
      and cpu_up from __devinit to __cpuinit. The approach is justified since
      the callers of cpu_up are either dependent on CONFIG_HOTPLUG_CPU or
      are of __init type.
      
      Thus when CONFIG_HOTPLUG_CPU=y, all these cpu up functions would land up
      in .text section, and when CONFIG_HOTPLUG_CPU=n, all these functions would
      land up in .init section.
      
      Tested on a i386 SMP machine running linux-2.6.20-rc3-mm1.
      Signed-off-by: NGautham R Shenoy <ego@in.ibm.com>
      Cc: Vivek Goyal <vgoyal@in.ibm.com>
      Cc: Mikael Starvik <starvik@axis.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Kyle McMartin <kyle@mcmartin.ca>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      b282b6f8
  18. 24 12月, 2006 1 次提交
    • I
      [PATCH] suspend: fix suspend on single-CPU systems · e1d9fd2e
      Ingo Molnar 提交于
      Clark Williams reported that suspend doesnt work on his laptop on
      2.6.20-rc1-rt kernels. The bug was introduced by the following cleanup
      commit:
      
       commit 112cecb2
       Author: Siddha, Suresh B <suresh.b.siddha@intel.com>
       Date:   Wed Dec 6 20:34:31 2006 -0800
      
          [PATCH] suspend: don't change cpus_allowed for task initiating the suspend
      
      because with this change 'error' is not initialized to 0 anymore, if
      there are no other online CPUs. (i.e. if the system is single-CPU).
      
      the fix is the initialize it to 0. The really weird thing is that my
      version of gcc does not warn about this non-initialized variable
      situation ...
      
      (also fix the kernel printk in the error branch, it was missing a
       newline)
      Reported-by: NClark Williams <williams@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      e1d9fd2e
  19. 08 12月, 2006 1 次提交
  20. 06 11月, 2006 1 次提交
  21. 29 10月, 2006 1 次提交
  22. 17 10月, 2006 1 次提交
    • N
      [PATCH] Convert cpu hotplug notifiers to use raw_notifier instead of blocking_notifier · bd5349cf
      Neil Brown 提交于
      The use of blocking notifier by _cpu_up and _cpu_down in cpu.c has two
      problem.
      
      1/ An interaction with the workqueue notifier causes lockdep to spit a
         warning.
      
      2/ A notifier could conceivable be added or removed while _cpu_up or
         _cpu_down are in process.  As each notifier is called twice (prepare
         then commit/abort) this could be unhealthy.
      
      To fix to we simply take cpu_add_remove_lock while adding or removing
      notifiers to/from the list.
      
      This makes the 'blocking' usage unnecessary as all accesses to cpu_chain
      are now protected by cpu_add_remove_lock.  So change "blocking" to "raw" in
      all relevant places.  This fixes 1.
      
      Credit: Andrew Morton
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Michal Piotrowski <michal.k.k.piotrowski@gmail.com> (reporter)
      Signed-off-by: NNeil Brown <neilb@suse.de>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      bd5349cf
  23. 26 9月, 2006 1 次提交
    • R
      [PATCH] Disable CPU hotplug during suspend · e3920fb4
      Rafael J. Wysocki 提交于
      The current suspend code has to be run on one CPU, so we use the CPU
      hotplug to take the non-boot CPUs offline on SMP machines.  However, we
      should also make sure that these CPUs will not be enabled by someone else
      after we have disabled them.
      
      The functions disable_nonboot_cpus() and enable_nonboot_cpus() are moved to
      kernel/cpu.c, because they now refer to some stuff in there that should
      better be static.  Also it's better if disable_nonboot_cpus() returns an
      error instead of panicking if something goes wrong, and
      enable_nonboot_cpus() has no reason to panic(), because the CPUs may have
      been enabled by the userland before it tries to take them online.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Acked-by: NPavel Machek <pavel@ucw.cz>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      e3920fb4
  24. 24 7月, 2006 1 次提交
    • L
      cpu hotplug: simplify and hopefully fix locking · aa953877
      Linus Torvalds 提交于
      The CPU hotplug locking was quite messy, with a recursive lock to
      handle the fact that both the actual up/down sequence wanted to
      protect itself from being re-entered, but the callbacks that it
      called also tended to want to protect themselves from CPU events.
      
      This splits the lock into two (one to serialize the whole hotplug
      sequence, the other to protect against the CPU present bitmaps
      changing). The latter still allows recursive usage because some
      subsystems (ondemand policy for cpufreq at least) had already gotten
      too used to the lax locking, but the locking mistakes are hopefully
      now less fundamental, and we now warn about recursive lock usage
      when we see it, in the hope that it can be fixed.
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      aa953877
  25. 28 6月, 2006 1 次提交
  26. 27 6月, 2006 1 次提交
  27. 28 3月, 2006 1 次提交
    • A
      [PATCH] Notifier chain update: API changes · e041c683
      Alan Stern 提交于
      The kernel's implementation of notifier chains is unsafe.  There is no
      protection against entries being added to or removed from a chain while the
      chain is in use.  The issues were discussed in this thread:
      
          http://marc.theaimsgroup.com/?l=linux-kernel&m=113018709002036&w=2
      
      We noticed that notifier chains in the kernel fall into two basic usage
      classes:
      
      	"Blocking" chains are always called from a process context
      	and the callout routines are allowed to sleep;
      
      	"Atomic" chains can be called from an atomic context and
      	the callout routines are not allowed to sleep.
      
      We decided to codify this distinction and make it part of the API.  Therefore
      this set of patches introduces three new, parallel APIs: one for blocking
      notifiers, one for atomic notifiers, and one for "raw" notifiers (which is
      really just the old API under a new name).  New kinds of data structures are
      used for the heads of the chains, and new routines are defined for
      registration, unregistration, and calling a chain.  The three APIs are
      explained in include/linux/notifier.h and their implementation is in
      kernel/sys.c.
      
      With atomic and blocking chains, the implementation guarantees that the chain
      links will not be corrupted and that chain callers will not get messed up by
      entries being added or removed.  For raw chains the implementation provides no
      guarantees at all; users of this API must provide their own protections.  (The
      idea was that situations may come up where the assumptions of the atomic and
      blocking APIs are not appropriate, so it should be possible for users to
      handle these things in their own way.)
      
      There are some limitations, which should not be too hard to live with.  For
      atomic/blocking chains, registration and unregistration must always be done in
      a process context since the chain is protected by a mutex/rwsem.  Also, a
      callout routine for a non-raw chain must not try to register or unregister
      entries on its own chain.  (This did happen in a couple of places and the code
      had to be changed to avoid it.)
      
      Since atomic chains may be called from within an NMI handler, they cannot use
      spinlocks for synchronization.  Instead we use RCU.  The overhead falls almost
      entirely in the unregister routine, which is okay since unregistration is much
      less frequent that calling a chain.
      
      Here is the list of chains that we adjusted and their classifications.  None
      of them use the raw API, so for the moment it is only a placeholder.
      
        ATOMIC CHAINS
        -------------
      arch/i386/kernel/traps.c:		i386die_chain
      arch/ia64/kernel/traps.c:		ia64die_chain
      arch/powerpc/kernel/traps.c:		powerpc_die_chain
      arch/sparc64/kernel/traps.c:		sparc64die_chain
      arch/x86_64/kernel/traps.c:		die_chain
      drivers/char/ipmi/ipmi_si_intf.c:	xaction_notifier_list
      kernel/panic.c:				panic_notifier_list
      kernel/profile.c:			task_free_notifier
      net/bluetooth/hci_core.c:		hci_notifier
      net/ipv4/netfilter/ip_conntrack_core.c:	ip_conntrack_chain
      net/ipv4/netfilter/ip_conntrack_core.c:	ip_conntrack_expect_chain
      net/ipv6/addrconf.c:			inet6addr_chain
      net/netfilter/nf_conntrack_core.c:	nf_conntrack_chain
      net/netfilter/nf_conntrack_core.c:	nf_conntrack_expect_chain
      net/netlink/af_netlink.c:		netlink_chain
      
        BLOCKING CHAINS
        ---------------
      arch/powerpc/platforms/pseries/reconfig.c:	pSeries_reconfig_chain
      arch/s390/kernel/process.c:		idle_chain
      arch/x86_64/kernel/process.c		idle_notifier
      drivers/base/memory.c:			memory_chain
      drivers/cpufreq/cpufreq.c		cpufreq_policy_notifier_list
      drivers/cpufreq/cpufreq.c		cpufreq_transition_notifier_list
      drivers/macintosh/adb.c:		adb_client_list
      drivers/macintosh/via-pmu.c		sleep_notifier_list
      drivers/macintosh/via-pmu68k.c		sleep_notifier_list
      drivers/macintosh/windfarm_core.c	wf_client_list
      drivers/usb/core/notify.c		usb_notifier_list
      drivers/video/fbmem.c			fb_notifier_list
      kernel/cpu.c				cpu_chain
      kernel/module.c				module_notify_list
      kernel/profile.c			munmap_notifier
      kernel/profile.c			task_exit_notifier
      kernel/sys.c				reboot_notifier_list
      net/core/dev.c				netdev_chain
      net/decnet/dn_dev.c:			dnaddr_chain
      net/ipv4/devinet.c:			inetaddr_chain
      
      It's possible that some of these classifications are wrong.  If they are,
      please let us know or submit a patch to fix them.  Note that any chain that
      gets called very frequently should be atomic, because the rwsem read-locking
      used for blocking chains is very likely to incur cache misses on SMP systems.
      (However, if the chain's callout routines may sleep then the chain cannot be
      atomic.)
      
      The patch set was written by Alan Stern and Chandra Seetharaman, incorporating
      material written by Keith Owens and suggestions from Paul McKenney and Andrew
      Morton.
      
      [jes@sgi.com: restructure the notifier chain initialization macros]
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NChandra Seetharaman <sekharan@us.ibm.com>
      Signed-off-by: NJes Sorensen <jes@sgi.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      e041c683
  28. 25 3月, 2006 1 次提交
  29. 29 11月, 2005 1 次提交
    • A
      [PATCH] clean up lock_cpu_hotplug() in cpufreq · a9d9baa1
      Ashok Raj 提交于
      There are some callers in cpufreq hotplug notify path that the lowest
      function calls lock_cpu_hotplug().  The lock is already held during
      cpu_up() and cpu_down() calls when the notify calls are broadcast to
      registered clients.
      
      Ideally if possible, we could disable_preempt() at the highest caller and
      make sure we dont sleep in the path down in cpufreq->driver_target() calls
      but the calls are so intertwined and cumbersome to cleanup.
      
      Hence we consistently use lock_cpu_hotplug() and unlock_cpu_hotplug() in
      all places.
      
       - Removed export of cpucontrol semaphore and made it static.
       - removed explicit uses of up/down with lock_cpu_hotplug()
         so we can keep track of the the callers in same thread context and
         just keep refcounts without calling a down() that causes a deadlock.
       - Removed current_in_hotplug() uses
       - Removed PF_HOTPLUG_CPU in sched.h introduced for the current_in_hotplug()
         temporary workaround.
      
      Tested with insmod of cpufreq_stat.ko, and logical online/offline
      to make sure we dont have any hang situations.
      Signed-off-by: NAshok Raj <ashok.raj@intel.com>
      Cc: Zwane Mwaikambo <zwane@linuxpower.ca>
      Cc: Shaohua Li <shaohua.li@intel.com>
      Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
      a9d9baa1