lkml.org 
[lkml]   [2012]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/2] Introduce crash ipi helpers to wait for APs to stop
    Date
    Introduce crash ipi helpers to use them from BSP and AP sides in
    common.

    There's no logical change in this patch.

    Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
    ---

    arch/x86/include/asm/reboot.h | 4 +++
    arch/x86/kernel/reboot.c | 53 ++++++++++++++++++++++++++++++++---------
    2 files changed, 45 insertions(+), 12 deletions(-)

    diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
    index 92f29706..2f8e9e7 100644
    --- a/arch/x86/include/asm/reboot.h
    +++ b/arch/x86/include/asm/reboot.h
    @@ -26,4 +26,8 @@ void machine_real_restart(unsigned int type);
    typedef void (*nmi_shootdown_cb)(int, struct pt_regs*);
    void nmi_shootdown_cpus(nmi_shootdown_cb callback);

    +void crash_ipi_init(void);
    +void crash_ipi_dec_and_halt(void);
    +void crash_ipi_wait_for_APs(void);
    +
    #endif /* _ASM_X86_REBOOT_H */
    diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
    index d840e69..6dd77a8 100644
    --- a/arch/x86/kernel/reboot.c
    +++ b/arch/x86/kernel/reboot.c
    @@ -769,6 +769,31 @@ static nmi_shootdown_cb shootdown_callback;

    static atomic_t waiting_for_crash_ipi;

    +void crash_ipi_init(void)
    +{
    + atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
    +}
    +
    +void crash_ipi_dec_and_halt(void)
    +{
    + atomic_dec(&waiting_for_crash_ipi);
    + /* Assume hlt works */
    + halt();
    + for (;;)
    + cpu_relax();
    +}
    +
    +void crash_ipi_wait_for_APs(void)
    +{
    + unsigned long msecs;
    +
    + msecs = 1000; /* Wait at most a second for the other cpus to stop */
    + while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) {
    + mdelay(1);
    + msecs--;
    + }
    +}
    +
    static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)
    {
    int cpu;
    @@ -785,11 +810,7 @@ static int crash_nmi_callback(unsigned int val, struct pt_regs *regs)

    shootdown_callback(cpu, regs);

    - atomic_dec(&waiting_for_crash_ipi);
    - /* Assume hlt works */
    - halt();
    - for (;;)
    - cpu_relax();
    + crash_ipi_dec_and_halt();

    return NMI_HANDLED;
    }
    @@ -807,7 +828,6 @@ static void smp_send_nmi_allbutself(void)
    */
    void nmi_shootdown_cpus(nmi_shootdown_cb callback)
    {
    - unsigned long msecs;
    local_irq_disable();

    /* Make a note of crashing cpu. Will be used in NMI callback.*/
    @@ -815,7 +835,8 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)

    shootdown_callback = callback;

    - atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
    + crash_ipi_init();
    +
    /* Would it be better to replace the trap vector here? */
    if (register_nmi_handler(NMI_LOCAL, crash_nmi_callback,
    NMI_FLAG_FIRST, "crash"))
    @@ -827,11 +848,7 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)

    smp_send_nmi_allbutself();

    - msecs = 1000; /* Wait at most a second for the other cpus to stop */
    - while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) {
    - mdelay(1);
    - msecs--;
    - }
    + crash_ipi_wait_for_APs();

    /* Leave the nmi callback set */
    }
    @@ -840,4 +857,16 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)
    {
    /* No other CPUs to shoot down */
    }
    +
    +void crash_ipi_init(void)
    +{
    +}
    +
    +void crash_ipi_dec_and_halt(void)
    +{
    +}
    +
    +void crash_ipi_wait_for_APs(void)
    +{
    +}
    #endif


    \
     
     \ /
      Last update: 2012-04-16 04:25    [W:2.286 / U:0.288 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site