Message ID | 20230910082911.3378782-13-guoren@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | riscv: Add Native/Paravirt qspinlock support | expand |
On Sun, Sep 10, 2023 at 04:29:06AM -0400, guoren@kernel.org wrote: > From: Guo Ren <guoren@linux.alibaba.com> > > Disables the qspinlock slow path using PV optimizations which > allow the hypervisor to 'idle' the guest on lock contention. > > Signed-off-by: Guo Ren <guoren@linux.alibaba.com> > Signed-off-by: Guo Ren <guoren@kernel.org> > --- > Documentation/admin-guide/kernel-parameters.txt | 2 +- > arch/riscv/kernel/qspinlock_paravirt.c | 13 +++++++++++++ > 2 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > index f75bedc50e00..e74aed631573 100644 > --- a/Documentation/admin-guide/kernel-parameters.txt > +++ b/Documentation/admin-guide/kernel-parameters.txt > @@ -3857,7 +3857,7 @@ > as generic guest with no PV drivers. Currently support > XEN HVM, KVM, HYPER_V and VMWARE guest. > > - nopvspin [X86,XEN,KVM] > + nopvspin [X86,XEN,KVM,RISC-V] > Disables the qspinlock slow path using PV optimizations > which allow the hypervisor to 'idle' the guest on lock > contention. > diff --git a/arch/riscv/kernel/qspinlock_paravirt.c b/arch/riscv/kernel/qspinlock_paravirt.c > index 85ff5a3ec234..a0ad4657f437 100644 > --- a/arch/riscv/kernel/qspinlock_paravirt.c > +++ b/arch/riscv/kernel/qspinlock_paravirt.c > @@ -41,8 +41,21 @@ EXPORT_STATIC_CALL(pv_queued_spin_lock_slowpath); > DEFINE_STATIC_CALL(pv_queued_spin_unlock, native_queued_spin_unlock); > EXPORT_STATIC_CALL(pv_queued_spin_unlock); > > +static bool nopvspin; It is only used in init, so it makes sense to add __initdata. static bool nopvspin __initdata; Other than that, LGTM: Reviewed-by: Leonardo Bras <leobras@redhat.com> Thanks! Leo > +static __init int parse_nopvspin(char *arg) > +{ > + nopvspin = true; > + return 0; > +} > +early_param("nopvspin", parse_nopvspin); > + > void __init pv_qspinlock_init(void) > { > + if (nopvspin) { > + pr_info("PV qspinlocks disabled\n"); > + return; > + } > + > if (num_possible_cpus() == 1) > return; > > -- > 2.36.1 >
On Fri, Sep 15, 2023 at 2:05 PM Leonardo Bras <leobras@redhat.com> wrote: > > On Sun, Sep 10, 2023 at 04:29:06AM -0400, guoren@kernel.org wrote: > > From: Guo Ren <guoren@linux.alibaba.com> > > > > Disables the qspinlock slow path using PV optimizations which > > allow the hypervisor to 'idle' the guest on lock contention. > > > > Signed-off-by: Guo Ren <guoren@linux.alibaba.com> > > Signed-off-by: Guo Ren <guoren@kernel.org> > > --- > > Documentation/admin-guide/kernel-parameters.txt | 2 +- > > arch/riscv/kernel/qspinlock_paravirt.c | 13 +++++++++++++ > > 2 files changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > > index f75bedc50e00..e74aed631573 100644 > > --- a/Documentation/admin-guide/kernel-parameters.txt > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > @@ -3857,7 +3857,7 @@ > > as generic guest with no PV drivers. Currently support > > XEN HVM, KVM, HYPER_V and VMWARE guest. > > > > - nopvspin [X86,XEN,KVM] > > + nopvspin [X86,XEN,KVM,RISC-V] > > Disables the qspinlock slow path using PV optimizations > > which allow the hypervisor to 'idle' the guest on lock > > contention. > > diff --git a/arch/riscv/kernel/qspinlock_paravirt.c b/arch/riscv/kernel/qspinlock_paravirt.c > > index 85ff5a3ec234..a0ad4657f437 100644 > > --- a/arch/riscv/kernel/qspinlock_paravirt.c > > +++ b/arch/riscv/kernel/qspinlock_paravirt.c > > @@ -41,8 +41,21 @@ EXPORT_STATIC_CALL(pv_queued_spin_lock_slowpath); > > DEFINE_STATIC_CALL(pv_queued_spin_unlock, native_queued_spin_unlock); > > EXPORT_STATIC_CALL(pv_queued_spin_unlock); > > > > +static bool nopvspin; > > It is only used in init, so it makes sense to add __initdata. > > static bool nopvspin __initdata; Okay. > > Other than that, LGTM: > Reviewed-by: Leonardo Bras <leobras@redhat.com> > > Thanks! > Leo > > > +static __init int parse_nopvspin(char *arg) > > +{ > > + nopvspin = true; > > + return 0; > > +} > > +early_param("nopvspin", parse_nopvspin); > > + > > void __init pv_qspinlock_init(void) > > { > > + if (nopvspin) { > > + pr_info("PV qspinlocks disabled\n"); > > + return; > > + } > > + > > if (num_possible_cpus() == 1) > > return; > > > > -- > > 2.36.1 > > >
On Sun, Sep 17, 2023 at 11:03:30PM +0800, Guo Ren wrote: > On Fri, Sep 15, 2023 at 2:05 PM Leonardo Bras <leobras@redhat.com> wrote: > > > > On Sun, Sep 10, 2023 at 04:29:06AM -0400, guoren@kernel.org wrote: > > > From: Guo Ren <guoren@linux.alibaba.com> > > > > > > Disables the qspinlock slow path using PV optimizations which > > > allow the hypervisor to 'idle' the guest on lock contention. > > > > > > Signed-off-by: Guo Ren <guoren@linux.alibaba.com> > > > Signed-off-by: Guo Ren <guoren@kernel.org> > > > --- > > > Documentation/admin-guide/kernel-parameters.txt | 2 +- > > > arch/riscv/kernel/qspinlock_paravirt.c | 13 +++++++++++++ > > > 2 files changed, 14 insertions(+), 1 deletion(-) > > > > > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > > > index f75bedc50e00..e74aed631573 100644 > > > --- a/Documentation/admin-guide/kernel-parameters.txt > > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > > @@ -3857,7 +3857,7 @@ > > > as generic guest with no PV drivers. Currently support > > > XEN HVM, KVM, HYPER_V and VMWARE guest. > > > > > > - nopvspin [X86,XEN,KVM] > > > + nopvspin [X86,XEN,KVM,RISC-V] > > > Disables the qspinlock slow path using PV optimizations > > > which allow the hypervisor to 'idle' the guest on lock > > > contention. > > > diff --git a/arch/riscv/kernel/qspinlock_paravirt.c b/arch/riscv/kernel/qspinlock_paravirt.c > > > index 85ff5a3ec234..a0ad4657f437 100644 > > > --- a/arch/riscv/kernel/qspinlock_paravirt.c > > > +++ b/arch/riscv/kernel/qspinlock_paravirt.c > > > @@ -41,8 +41,21 @@ EXPORT_STATIC_CALL(pv_queued_spin_lock_slowpath); > > > DEFINE_STATIC_CALL(pv_queued_spin_unlock, native_queued_spin_unlock); > > > EXPORT_STATIC_CALL(pv_queued_spin_unlock); > > > > > > +static bool nopvspin; > > > > It is only used in init, so it makes sense to add __initdata. > > > > static bool nopvspin __initdata; > Okay. Thx! Leo > > > > > Other than that, LGTM: > > Reviewed-by: Leonardo Bras <leobras@redhat.com> > > > > Thanks! > > Leo > > > > > +static __init int parse_nopvspin(char *arg) > > > +{ > > > + nopvspin = true; > > > + return 0; > > > +} > > > +early_param("nopvspin", parse_nopvspin); > > > + > > > void __init pv_qspinlock_init(void) > > > { > > > + if (nopvspin) { > > > + pr_info("PV qspinlocks disabled\n"); > > > + return; > > > + } > > > + > > > if (num_possible_cpus() == 1) > > > return; > > > > > > -- > > > 2.36.1 > > > > > > > > -- > Best Regards > Guo Ren >
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index f75bedc50e00..e74aed631573 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -3857,7 +3857,7 @@ as generic guest with no PV drivers. Currently support XEN HVM, KVM, HYPER_V and VMWARE guest. - nopvspin [X86,XEN,KVM] + nopvspin [X86,XEN,KVM,RISC-V] Disables the qspinlock slow path using PV optimizations which allow the hypervisor to 'idle' the guest on lock contention. diff --git a/arch/riscv/kernel/qspinlock_paravirt.c b/arch/riscv/kernel/qspinlock_paravirt.c index 85ff5a3ec234..a0ad4657f437 100644 --- a/arch/riscv/kernel/qspinlock_paravirt.c +++ b/arch/riscv/kernel/qspinlock_paravirt.c @@ -41,8 +41,21 @@ EXPORT_STATIC_CALL(pv_queued_spin_lock_slowpath); DEFINE_STATIC_CALL(pv_queued_spin_unlock, native_queued_spin_unlock); EXPORT_STATIC_CALL(pv_queued_spin_unlock); +static bool nopvspin; +static __init int parse_nopvspin(char *arg) +{ + nopvspin = true; + return 0; +} +early_param("nopvspin", parse_nopvspin); + void __init pv_qspinlock_init(void) { + if (nopvspin) { + pr_info("PV qspinlocks disabled\n"); + return; + } + if (num_possible_cpus() == 1) return;