Unverified Commit e1ace816 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!14004 Support haltpoll feature

Merge Pull Request from: @ci-robot 
 
PR sync from: lishusen <lishusen2@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/RCGPV2ESVMODZJUZUA2VYISRUJKU7QS2/ 
Support haltpoll feature to improve performance

Ankur Arora (10):
  asm-generic: add barrier smp_cond_load_relaxed_timeout()
  cpuidle/poll_state: poll via smp_cond_load_relaxed_timeout()
  cpuidle: rename ARCH_HAS_CPU_RELAX to ARCH_HAS_OPTIMIZED_POLL
  arm64: barrier: add support for smp_cond_relaxed_timeout()
  arm64: add support for polling in idle
  cpuidle-haltpoll: condition on ARCH_CPUIDLE_HALTPOLL
  arm64: idle: export arch_cpu_idle
  arm64: support cpuidle-haltpoll
  arm64/delay: add some constants to a separate header
  arm64: support WFET in smp_cond_relaxed_timeout()

Joao Martins (4):
  Kconfig: move ARCH_HAS_OPTIMIZED_POLL to arch/Kconfig
  arm64: define TIF_POLLING_NRFLAG
  cpuidle-haltpoll: define arch_haltpoll_want()
  governors/haltpoll: drop kvm_para_available() check

Lifeng Zheng (1):
  ACPI: processor_idle: Support polling state for LPI

lishusen (3):
  cpuidle: edit cpuidle-haltpoll driver module parameter
  arm64/delay: remove USECS_TO_CYCLES to avoid conflict
  arm64: add config for cpuidle-haltpoll


-- 
2.33.0
 
https://gitee.com/openeuler/kernel/issues/IB7PU3 
 
Link:https://gitee.com/openeuler/kernel/pulls/14004

 

Reviewed-by: default avatarLiu Chao <liuchao173@huawei.com>
Reviewed-by: default avatarWei Li <liwei391@huawei.com>
Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 148b436b 6df2e969
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -264,6 +264,9 @@ config HAVE_ARCH_TRACEHOOK
config HAVE_DMA_CONTIGUOUS
	bool

config ARCH_HAS_OPTIMIZED_POLL
	bool

config GENERIC_SMP_IDLE_THREAD
	bool

+9 −0
Original line number Diff line number Diff line
@@ -36,6 +36,9 @@ config ARM64
	select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
	select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
	select ARCH_HAS_NONLEAF_PMD_YOUNG if ARM64_HAFT
	select ARCH_HAS_OPTIMIZED_POLL
	select ARCH_CPUIDLE_HALTPOLL
	select HALTPOLL_CPUIDLE
	select ARCH_HAS_PTE_DEVMAP
	select ARCH_HAS_PTE_SPECIAL
	select ARCH_HAS_SETUP_DMA_OPS
@@ -2621,6 +2624,12 @@ config ARCH_HIBERNATION_HEADER
config ARCH_SUSPEND_POSSIBLE
	def_bool y

config ARCH_CPUIDLE_HALTPOLL
	bool "Enable selection of the cpuidle-haltpoll driver"
	help
	  cpuidle-haltpoll allows for adaptive polling based on
	  current load before entering the idle state.

endmenu # "Power management options"

menu "CPU Power Management"
+3 −0
Original line number Diff line number Diff line
@@ -627,6 +627,7 @@ CONFIG_CPU_PM=y
CONFIG_ARCH_HIBERNATION_POSSIBLE=y
CONFIG_ARCH_HIBERNATION_HEADER=y
CONFIG_ARCH_SUSPEND_POSSIBLE=y
CONFIG_ARCH_CPUIDLE_HALTPOLL=y
# end of Power management options

#
@@ -646,6 +647,7 @@ CONFIG_CPU_IDLE_GOV_TEO=y
#
# CONFIG_ARM_PSCI_CPUIDLE is not set
# end of ARM CPU Idle Drivers
CONFIG_HALTPOLL_CPUIDLE=y
# end of CPU Idle

#
@@ -788,6 +790,7 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
CONFIG_TRACE_IRQFLAGS_NMI_SUPPORT=y
CONFIG_HAVE_ARCH_TRACEHOOK=y
CONFIG_HAVE_DMA_CONTIGUOUS=y
CONFIG_ARCH_HAS_OPTIMIZED_POLL=y
CONFIG_GENERIC_SMP_IDLE_THREAD=y
CONFIG_GENERIC_IDLE_POLL_SETUP=y
CONFIG_ARCH_HAS_FORTIFY_SOURCE=y
+60 −2
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <linux/kasan-checks.h>

#include <asm/alternative-macros.h>
#include <asm/delay-const.h>

#define __nops(n)	".rept	" #n "\nnop\n.endr\n"
#define nops(n)		asm volatile(__nops(n))
@@ -198,7 +199,7 @@ do { \
		VAL = READ_ONCE(*__PTR);				\
		if (cond_expr)						\
			break;						\
		__cmpwait_relaxed(__PTR, VAL);				\
		__cmpwait_relaxed(__PTR, VAL, ~0UL);			\
	}								\
	(typeof(*ptr))VAL;						\
})
@@ -211,11 +212,68 @@ do { \
		VAL = smp_load_acquire(__PTR);				\
		if (cond_expr)						\
			break;						\
		__cmpwait_relaxed(__PTR, VAL);				\
		__cmpwait_relaxed(__PTR, VAL, ~0UL);			\
	}								\
	(typeof(*ptr))VAL;						\
})

#define __smp_cond_load_timeout_spin(ptr, cond_expr,			\
				     time_expr_ns, time_limit_ns)	\
({									\
	typeof(ptr) __PTR = (ptr);					\
	__unqual_scalar_typeof(*ptr) VAL;				\
	unsigned int __count = 0;					\
	for (;;) {							\
		VAL = READ_ONCE(*__PTR);				\
		if (cond_expr)						\
			break;						\
		cpu_relax();						\
		if (__count++ < smp_cond_time_check_count)		\
			continue;					\
		if ((time_expr_ns) >= time_limit_ns)			\
			break;						\
		__count = 0;						\
	}								\
	(typeof(*ptr))VAL;						\
})

#define __smp_cond_load_timeout_wait(ptr, cond_expr,			\
				     time_expr_ns, time_limit_ns)	\
({									\
	typeof(ptr) __PTR = (ptr);					\
	__unqual_scalar_typeof(*ptr) VAL;				\
	const unsigned long __time_limit_cycles =			\
					NSECS_TO_CYCLES(time_limit_ns);	\
	for (;;) {							\
		VAL = READ_ONCE(*__PTR);				\
		if (cond_expr)						\
			break;						\
		__cmpwait_relaxed(__PTR, VAL, __time_limit_cycles);	\
		if ((time_expr_ns) >= time_limit_ns)			\
			break;						\
	}								\
	(typeof(*ptr))VAL;						\
})

#define smp_cond_load_relaxed_timeout(ptr, cond_expr,			\
				      time_expr_ns, time_limit_ns)	\
({									\
	__unqual_scalar_typeof(*ptr) _val;				\
									\
	int __wfe = arch_timer_evtstrm_available() ||			\
		    alternative_has_cap_unlikely(ARM64_HAS_WFXT);	\
	if (likely(__wfe))						\
		_val = __smp_cond_load_timeout_wait(ptr, cond_expr,	\
						   time_expr_ns,	\
						   time_limit_ns);	\
	else								\
		_val = __smp_cond_load_timeout_spin(ptr, cond_expr,	\
						   time_expr_ns,	\
						   time_limit_ns);	\
	(typeof(*ptr))_val;						\
})


#include <asm-generic/barrier.h>

#endif	/* __ASSEMBLY__ */
+17 −9
Original line number Diff line number Diff line
@@ -210,7 +210,8 @@ __CMPXCHG_GEN(_mb)

#define __CMPWAIT_CASE(w, sfx, sz)					\
static inline void __cmpwait_case_##sz(volatile void *ptr,		\
				       unsigned long val)		\
				       unsigned long val,		\
				       unsigned long time_limit_cycles)	\
{									\
	unsigned long tmp;						\
									\
@@ -220,10 +221,12 @@ static inline void __cmpwait_case_##sz(volatile void *ptr, \
	"	ldxr" #sfx "\t%" #w "[tmp], %[v]\n"			\
	"	eor	%" #w "[tmp], %" #w "[tmp], %" #w "[val]\n"	\
	"	cbnz	%" #w "[tmp], 1f\n"				\
	"	wfe\n"							\
	ALTERNATIVE("wfe\n",						\
		    "msr s0_3_c1_c0_0, %[time_limit_cycles]\n",		\
		    ARM64_HAS_WFXT)					\
	"1:"								\
	: [tmp] "=&r" (tmp), [v] "+Q" (*(u##sz *)ptr)			\
	: [val] "r" (val));						\
	: [val] "r" (val), [time_limit_cycles] "r" (time_limit_cycles));\
}

__CMPWAIT_CASE(w, b, 8);
@@ -236,17 +239,22 @@ __CMPWAIT_CASE( , , 64);
#define __CMPWAIT_GEN(sfx)						\
static __always_inline void __cmpwait##sfx(volatile void *ptr,		\
				  unsigned long val,			\
				  unsigned long time_limit_cycles,	\
				  int size)				\
{									\
	switch (size) {							\
	case 1:								\
		return __cmpwait_case##sfx##_8(ptr, (u8)val);		\
		return __cmpwait_case##sfx##_8(ptr, (u8)val,		\
					       time_limit_cycles);	\
	case 2:								\
		return __cmpwait_case##sfx##_16(ptr, (u16)val);		\
		return __cmpwait_case##sfx##_16(ptr, (u16)val,		\
						time_limit_cycles);	\
	case 4:								\
		return __cmpwait_case##sfx##_32(ptr, val);		\
		return __cmpwait_case##sfx##_32(ptr, val,		\
						time_limit_cycles);	\
	case 8:								\
		return __cmpwait_case##sfx##_64(ptr, val);		\
		return __cmpwait_case##sfx##_64(ptr, val,		\
						time_limit_cycles);	\
	default:							\
		BUILD_BUG();						\
	}								\
@@ -258,7 +266,7 @@ __CMPWAIT_GEN()

#undef __CMPWAIT_GEN

#define __cmpwait_relaxed(ptr, val) \
	__cmpwait((ptr), (unsigned long)(val), sizeof(*(ptr)))
#define __cmpwait_relaxed(ptr, val, time_limit_cycles) \
	__cmpwait((ptr), (unsigned long)(val), time_limit_cycles, sizeof(*(ptr)))

#endif	/* __ASM_CMPXCHG_H */
Loading