lkml.org 
[lkml]   [2014]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v11 12/16] pvqspinlock, x86: Add PV data structure & methods
    Date
    This patch modifies the para-virtualization (PV) infrastructure code
    of the x86-64 architecture to support the PV queue spinlock. Three
    new virtual methods are added to support PV qspinlock:

    1) kick_cpu - schedule in a virtual CPU
    2) halt_cpu - schedule out a virtual CPU
    3) lockstat - update statistical data for debugfs

    Signed-off-by: Waiman Long <Waiman.Long@hp.com>
    ---
    arch/x86/include/asm/paravirt.h | 18 +++++++++++++++++-
    arch/x86/include/asm/paravirt_types.h | 17 +++++++++++++++++
    arch/x86/kernel/paravirt-spinlocks.c | 6 ++++++
    3 files changed, 40 insertions(+), 1 deletions(-)

    diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
    index cd6e161..d71e123 100644
    --- a/arch/x86/include/asm/paravirt.h
    +++ b/arch/x86/include/asm/paravirt.h
    @@ -711,7 +711,23 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
    }

    #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
    +#ifdef CONFIG_QUEUE_SPINLOCK
    +static __always_inline void __queue_kick_cpu(int cpu)
    +{
    + PVOP_VCALL1(pv_lock_ops.kick_cpu, cpu);
    +}
    +
    +static __always_inline void
    +__queue_halt_cpu(enum pv_lock_stats type, s8 *state, s8 sval)
    +{
    + PVOP_VCALL3(pv_lock_ops.halt_cpu, type, state, sval);
    +}

    +static __always_inline void __queue_lockstat(enum pv_lock_stats type)
    +{
    + PVOP_VCALL1(pv_lock_ops.lockstat, type);
    +}
    +#else
    static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
    __ticket_t ticket)
    {
    @@ -723,7 +739,7 @@ static __always_inline void __ticket_unlock_kick(struct arch_spinlock *lock,
    {
    PVOP_VCALL2(pv_lock_ops.unlock_kick, lock, ticket);
    }
    -
    +#endif
    #endif

    #ifdef CONFIG_X86_32
    diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
    index 7549b8b..549b3a0 100644
    --- a/arch/x86/include/asm/paravirt_types.h
    +++ b/arch/x86/include/asm/paravirt_types.h
    @@ -333,9 +333,26 @@ struct arch_spinlock;
    typedef u16 __ticket_t;
    #endif

    +#ifdef CONFIG_QUEUE_SPINLOCK
    +enum pv_lock_stats {
    + PV_HALT_QHEAD, /* Queue head halting */
    + PV_HALT_QNODE, /* Other queue node halting */
    + PV_HALT_ABORT, /* Halting aborted */
    + PV_WAKE_KICKED, /* Wakeup by kicking */
    + PV_WAKE_SPURIOUS, /* Spurious wakeup */
    + PV_KICK_NOHALT /* Kick but CPU not halted */
    +};
    +#endif
    +
    struct pv_lock_ops {
    +#ifdef CONFIG_QUEUE_SPINLOCK
    + void (*kick_cpu)(int cpu);
    + void (*halt_cpu)(enum pv_lock_stats type, s8 *state, s8 sval);
    + void (*lockstat)(enum pv_lock_stats type);
    +#else
    struct paravirt_callee_save lock_spinning;
    void (*unlock_kick)(struct arch_spinlock *lock, __ticket_t ticket);
    +#endif
    };

    /* This contains all the paravirt structures: we get a convenient
    diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
    index d9041c9..17435b7 100644
    --- a/arch/x86/kernel/paravirt-spinlocks.c
    +++ b/arch/x86/kernel/paravirt-spinlocks.c
    @@ -11,9 +11,15 @@
    #ifdef CONFIG_PARAVIRT_SPINLOCKS
    struct pv_lock_ops pv_lock_ops = {
    #ifdef CONFIG_SMP
    +#ifdef CONFIG_QUEUE_SPINLOCK
    + .kick_cpu = paravirt_nop,
    + .halt_cpu = paravirt_nop,
    + .lockstat = paravirt_nop,
    +#else
    .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
    .unlock_kick = paravirt_nop,
    #endif
    +#endif
    };
    EXPORT_SYMBOL(pv_lock_ops);

    --
    1.7.1


    \
     
     \ /
      Last update: 2014-05-30 19:21    [W:2.642 / U:2.088 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site