[PATCH] powerpc: set default kernel thread priority to medium-low
All the important PThread locking occurs in GLIBC libpthread.so For scaling to large core counts we need to stay out of the kernel and scheduler as much as possible which implies increasing the spin time in user mode. For POWER implementations with SMT this implies that user mode needs to manage SMT priority for spinning and active (in the critical region) threads. Libpthread must be able to raise and lower the the SMT priority versus the default to be effective. This lowers the default kernel thread priority from medium to medium-low. Signed-off-by: Philippe Bergheaud --- arch/powerpc/include/asm/exception-64s.h|2 +- arch/powerpc/include/asm/ppc_asm.h |4 ++-- arch/powerpc/include/asm/processor.h|2 +- arch/powerpc/include/asm/spinlock.h |8 arch/powerpc/kernel/entry_64.S |2 +- arch/powerpc/kernel/exceptions-64s.S|4 ++-- arch/powerpc/kernel/head_64.S |4 ++-- arch/powerpc/kernel/idle.c |2 +- arch/powerpc/kernel/prom_init.c |2 +- arch/powerpc/kernel/time.c |2 +- arch/powerpc/kvm/book3s_hv.c|2 +- arch/powerpc/kvm/book3s_hv_rmhandlers.S |4 ++-- arch/powerpc/lib/locks.c|2 +- arch/powerpc/platforms/cell/beat_hvCall.S | 16 arch/powerpc/platforms/powernv/opal-takeover.S |2 +- arch/powerpc/platforms/pseries/hvCall.S | 10 +- arch/powerpc/platforms/pseries/processor_idle.c |4 ++-- 17 files changed, 36 insertions(+), 36 deletions(-) diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h index 402c1c4..30bedd9 100644 --- a/arch/powerpc/include/asm/exception-64s.h +++ b/arch/powerpc/include/asm/exception-64s.h @@ -135,7 +135,7 @@ END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,941) */ #define HMT_MEDIUM_PPR_DISCARD \ BEGIN_FTR_SECTION_NESTED(942) \ - HMT_MEDIUM; \ + HMT_MEDIUM_LOW; \ END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,0,942) /*non P7*/ /* diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h index ce05bba..22d4ba4 100644 --- a/arch/powerpc/include/asm/ppc_asm.h +++ b/arch/powerpc/include/asm/ppc_asm.h @@ -478,9 +478,9 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601) * PPR restore macros used in entry_64.S * Used for P7 or later processors */ -#define HMT_MEDIUM_LOW_HAS_PPR \ +#define HMT_LOW_HAS_PPR \ BEGIN_FTR_SECTION_NESTED(944) \ - HMT_MEDIUM_LOW; \ + HMT_LOW;\ END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,944) #define SET_DEFAULT_THREAD_PPR(ra, rb) \ diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index b4a3045..2f8625b 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -387,7 +387,7 @@ static inline unsigned long __pack_fe01(unsigned int fpmode) } #ifdef CONFIG_PPC64 -#define cpu_relax()do { HMT_low(); HMT_medium(); barrier(); } while (0) +#define cpu_relax()do { HMT_low(); HMT_medium_low(); barrier(); } while (0) #else #define cpu_relax()barrier() #endif diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h index 5f54a74..b047a6a 100644 --- a/arch/powerpc/include/asm/spinlock.h +++ b/arch/powerpc/include/asm/spinlock.h @@ -120,7 +120,7 @@ static inline void arch_spin_lock(arch_spinlock_t *lock) if (SHARED_PROCESSOR) __spin_yield(lock); } while (unlikely(lock->slock != 0)); - HMT_medium(); + HMT_medium_low(); } } @@ -140,7 +140,7 @@ void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags) if (SHARED_PROCESSOR) __spin_yield(lock); } while (unlikely(lock->slock != 0)); - HMT_medium(); + HMT_medium_low(); local_irq_restore(flags_dis); } } @@ -240,7 +240,7 @@ static inline void arch_read_lock(arch_rwlock_t *rw) if (SHARED_PROCESSOR) __rw_yield(rw); } while (unlikely(rw->lock < 0)); - HMT_medium(); + HMT_medium_low(); } } @@ -254,7 +254,7 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
Re: [PATCH] powerpc: set default kernel thread priority to medium-low
On Tue, 2013-12-10 at 08:39 +0100, Philippe Bergheaud wrote: > All the important PThread locking occurs in GLIBC libpthread.so > > For scaling to large core counts we need to stay out of the kernel and > scheduler as much as possible which implies increasing the spin time in user > mode. For POWER implementations with SMT this implies that user mode needs to > manage SMT priority for spinning and active (in the critical region) threads. > > Libpthread must be able to raise and lower the the SMT priority versus the > default to be effective. > > This lowers the default kernel thread priority from medium to medium-low. Hi Philippe, It would be nice if you could make an assertion about what the state of HMT handling should be once your patch is applied. I think it's: * The kernel should use HMT_MEDIUM_LOW as it's "default" priority * The kernel should use HMT_LOW as it's "low" priority Which would imply: * The kernel should not use HMT_MEDIUM anywhere .. * Nor should it use any of the other higher HMT modes. Do you agree? The reason I ask is I still see HMT_MEDIUM used in a few places, and it's not clear to me if that is correct. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: set default kernel thread priority to medium-low
On Wed, 2013-12-11 at 17:29 +1100, Michael Ellerman wrote: > It would be nice if you could make an assertion about what the state of HMT > handling should be once your patch is applied. > > I think it's: > > * The kernel should use HMT_MEDIUM_LOW as it's "default" priority > * The kernel should use HMT_LOW as it's "low" priority > > Which would imply: > > * The kernel should not use HMT_MEDIUM anywhere .. > * Nor should it use any of the other higher HMT modes. > > Do you agree? > > The reason I ask is I still see HMT_MEDIUM used in a few places, and it's not > clear to me if that is correct. HMT_MEDIUM used to be our default no ? Also there's an open question... when doing things with interrupts off (or worse, in real mode) such as some KVM hcalls etc... should we on the contrary boost up to limit interrupt latency ? Ben. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: set default kernel thread priority to medium-low
Benjamin Herrenschmidt wrote: On Wed, 2013-12-11 at 17:29 +1100, Michael Ellerman wrote: It would be nice if you could make an assertion about what the state of HMT handling should be once your patch is applied. I think it's: * The kernel should use HMT_MEDIUM_LOW as it's "default" priority * The kernel should use HMT_LOW as it's "low" priority Which would imply: * The kernel should not use HMT_MEDIUM anywhere .. * Nor should it use any of the other higher HMT modes. Do you agree? Not entirely. HT_MEDIUM might still be used by the kernel, in places where a priority higher than the default is required. The reason I ask is I still see HMT_MEDIUM used in a few places, and it's not clear to me if that is correct. HMT_MEDIUM used to be our default no ? Yes, but I am not sure that all references to HMT_MEDIUM were references to the default kernel priority. Also there's an open question... when doing things with interrupts off (or worse, in real mode) such as some KVM hcalls etc... should we on the contrary boost up to limit interrupt latency ? Yes. I think that there are cases when one should consider using HT_MEDIUM. Shouldn't we define a new macro HMT_DEFAULT, to identify explicitely where the default priority is required? Philippe ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: set default kernel thread priority to medium-low
On Wed, 2013-12-11 at 11:30 +0100, Philippe Bergheaud wrote: > Benjamin Herrenschmidt wrote: > > On Wed, 2013-12-11 at 17:29 +1100, Michael Ellerman wrote: > > > > > >>It would be nice if you could make an assertion about what the state of HMT > >>handling should be once your patch is applied. > >> > >>I think it's: > >> > >> * The kernel should use HMT_MEDIUM_LOW as it's "default" priority > >> * The kernel should use HMT_LOW as it's "low" priority > >> > >>Which would imply: > >> > >> * The kernel should not use HMT_MEDIUM anywhere .. > >> * Nor should it use any of the other higher HMT modes. > >> > >>Do you agree? > Not entirely. HT_MEDIUM might still be used by the kernel, in places where a > priority higher than the default is required. Right. But any code that currently uses HMT_MEDIUM is at the default level, whereas once your patch is applied any code still using HMT_MEDIUM will be boosted vs the default. So any code that still uses HMT_MEDIUM after your patch seems like a bug to me. > >>The reason I ask is I still see HMT_MEDIUM used in a few places, and it's > >>not > >>clear to me if that is correct. > > > > > > HMT_MEDIUM used to be our default no ? > Yes, but I am not sure that all references to HMT_MEDIUM were references to > the default kernel priority. What were they references to? Regardless they will now have the effect of boosting the priority in those code sections. It would be good to understand, and document, any places where we still use HMT_MEDIUM and why. > > Also there's an open question... when doing things with interrupts off > > (or worse, in real mode) such as some KVM hcalls etc... should we on the > > contrary boost up to limit interrupt latency ? > Yes. I think that there are cases when one should consider using HT_MEDIUM. Or HIGH? But let's not get side-tracked on that until we've got the default sorted. > Shouldn't we define a new macro HMT_DEFAULT, to identify explicitely where > the default priority is required? That might help clarify things yes. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: set default kernel thread priority to medium-low
Michael Ellerman wrote: On Wed, 2013-12-11 at 11:30 +0100, Philippe Bergheaud wrote: Benjamin Herrenschmidt wrote: On Wed, 2013-12-11 at 17:29 +1100, Michael Ellerman wrote: It would be nice if you could make an assertion about what the state of HMT handling should be once your patch is applied. I think it's: * The kernel should use HMT_MEDIUM_LOW as it's "default" priority * The kernel should use HMT_LOW as it's "low" priority Which would imply: * The kernel should not use HMT_MEDIUM anywhere .. * Nor should it use any of the other higher HMT modes. Do you agree? Not entirely. HT_MEDIUM might still be used by the kernel, in places where a priority higher than the default is required. Right. But any code that currently uses HMT_MEDIUM is at the default level, whereas once your patch is applied any code still using HMT_MEDIUM will be boosted vs the default. So any code that still uses HMT_MEDIUM after your patch seems like a bug to me. The reason I ask is I still see HMT_MEDIUM used in a few places, and it's not clear to me if that is correct. HMT_MEDIUM used to be our default no ? Yes, but I am not sure that all references to HMT_MEDIUM were references to the default kernel priority. What were they references to? Regardless they will now have the effect of boosting the priority in those code sections. It would be good to understand, and document, any places where we still use HMT_MEDIUM and why. Yes. This needs to be documented. Also there's an open question... when doing things with interrupts off (or worse, in real mode) such as some KVM hcalls etc... should we on the contrary boost up to limit interrupt latency ? Yes. I think that there are cases when one should consider using HT_MEDIUM. Or HIGH? Correct, I had not thought of that option. But let's not get side-tracked on that until we've got the default sorted. Shouldn't we define a new macro HMT_DEFAULT, to identify explicitely where the default priority is required? That might help clarify things yes. cheers Thank you for the help. I will rework this. Philippe ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: set default kernel thread priority to medium-low
On Thu, 2013-12-12 at 08:11 +0100, Philippe Bergheaud wrote: > Michael Ellerman wrote: > > On Wed, 2013-12-11 at 11:30 +0100, Philippe Bergheaud wrote: > > > >>Shouldn't we define a new macro HMT_DEFAULT, to identify explicitely where > >>the default priority is required? > > > > > > That might help clarify things yes. > > Thank you for the help. I will rework this. Thanks. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev