[lkml]   [2012]   [May]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: get/put_online_cpus documentation wrong?
    On 05/01/2012 04:56 PM, Gilad Ben-Yossef wrote:

    > On Tue, May 1, 2012 at 3:12 AM, Paul Mackerras <> wrote:
    >> In Documentation/cpu-hotplug.txt it says:
    >> " #include <linux/cpu.h>
    >> get_online_cpus() and put_online_cpus():
    >> The above calls are used to inhibit cpu hotplug operations. While the
    >> cpu_hotplug.refcount is non zero, the cpu_online_mask will not change.
    >> If you merely need to avoid cpus going away, you could also use
    >> preempt_disable() and preempt_enable() for those sections.
    >> Just remember the critical section cannot call any
    >> function that can sleep or schedule this process away."
    > I *think* the critical section remark here is referring to using
    > preempt_disable/enable(),
    > rather then the use of get/put_online_cpus().

    Yes, what Gilad said is right.

    Using preempt_disable()/preempt_enable() around a piece of code is a
    light-weight way of preventing CPUs from going away (CPUs going offline)
    while executing that code. (However, they don't prevent new CPUs from
    coming online). So, if you are using preempt_disable|enable() to
    prevent some CPU from going offline, then the usual rules for using
    preempt_disable|enable() apply - that code should not sleep.

    But if you want to avoid CPU hotplug entirely (both CPU offlining and
    onlining), then you should use get/put_online_cpus(). You can use this
    around any piece of code, including those which can sleep.

    Srivatsa S. Bhat
    IBM Linux Technology Center

     \ /
      Last update: 2012-05-01 16:21    [W:0.025 / U:16.892 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site