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

!3744 Add NUMA-awareness to qspinlock

Merge Pull Request from: @ci-robot 
 
PR sync from: Wei Li <liwei391@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/SOAPZPBZQYKUG5MH3GORAV7SMMLDC5VR/ 
Backport compact NUMA-aware lock feature v15 from linux maillist.

bugzilla: https://gitee.com/openeuler/kernel/issues/I8T8XV
Reference: https://lore.kernel.org/linux-arm-kernel/20210514200743.3026725-1-alex.kogan@oracle.com

Alex Kogan (6):
  locking/qspinlock: Rename mcs lock/unlock macros and make them more
    generic
  locking/qspinlock: Refactor the qspinlock slow path
  locking/qspinlock: Introduce CNA into the slow path of qspinlock
  locking/qspinlock: Introduce starvation avoidance into CNA
  locking/qspinlock: Avoid moving certain threads between waiting queues
    in CNA
  locking/qspinlock: Introduce the shuffle reduction optimization into
    CNA

Wei Li (2):
  locking/qspinlock: Disable CNA by default
  config: Enable CONFIG_NUMA_AWARE_SPINLOCKS on x86


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/I8T8XV 
 
Link:https://gitee.com/openeuler/kernel/pulls/3744

 

Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Reviewed-by: default avatarLiu Chao <liuchao173@huawei.com>
Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parents c42a1dba 63599080
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -4024,6 +4024,16 @@
			NUMA balancing.
			Allowed values are enable and disable

	numa_spinlock=	[NUMA, PV_OPS] Select the NUMA-aware variant
			of spinlock. The options are:
			auto - Enable this variant if running on a multi-node
			machine in native environment.
			on  - Unconditionally enable this variant.
			off - Unconditionally disable this variant.

			Not specifying this option is equivalent to
			numa_spinlock=auto.

	numa_zonelist_order= [KNL, BOOT] Select zonelist order for NUMA.
			'node', 'default' can be specified
			This can be set from sysctl after boot.
@@ -4704,6 +4714,14 @@
			[KNL] Number of legacy pty's. Overwrites compiled-in
			default number.

	qspinlock.numa_spinlock_threshold_ns=	[NUMA, PV_OPS]
			Set the time threshold in nanoseconds for the
			number of intra-node lock hand-offs before the
			NUMA-aware spinlock is forced to be passed to
			a thread on another NUMA node. Smaller values
			result in a more fair, but less performant spinlock,
			and vice versa. The default value is 1000000 (=1ms).

	quiet		[KNL] Disable most log messages

	r128=		[HW,DRM]
+3 −3
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
#include <asm/spinlock.h>

/* MCS spin-locking. */
#define arch_mcs_spin_lock_contended(lock)				\
#define arch_mcs_spin_wait(lock)					\
do {									\
	/* Ensure prior stores are observed before we enter wfe. */	\
	smp_mb();							\
@@ -14,9 +14,9 @@ do { \
		wfe();							\
} while (0)								\

#define arch_mcs_spin_unlock_contended(lock)				\
#define arch_mcs_lock_handoff(lock, val)				\
do {									\
	smp_store_release(lock, 1);					\
	smp_store_release((lock), (val));				\
	dsb_sev();							\
} while (0)

+20 −0
Original line number Diff line number Diff line
@@ -1550,6 +1550,26 @@ config NUMA

	  Otherwise, you should say N.

config NUMA_AWARE_SPINLOCKS
	bool "Numa-aware spinlocks"
	depends on NUMA
	depends on QUEUED_SPINLOCKS
	depends on 64BIT
	# For now, we depend on PARAVIRT_SPINLOCKS to make the patching work.
	# This is awkward, but hopefully would be resolved once static_call()
	# is available.
	depends on PARAVIRT_SPINLOCKS
	default y
	help
	  Introduce NUMA (Non Uniform Memory Access) awareness into
	  the slow path of spinlocks.

	  In this variant of qspinlock, the kernel will try to keep the lock
	  on the same node, thus reducing the number of remote cache misses,
	  while trading some of the short term fairness for better performance.

	  Say N if you want absolute first come first serve fairness.

config AMD_NUMA
	def_bool y
	prompt "Old style AMD Opteron NUMA detection"
+1 −0
Original line number Diff line number Diff line
@@ -444,6 +444,7 @@ CONFIG_X86_MEM_ENCRYPT=y
CONFIG_AMD_MEM_ENCRYPT=y
# CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT is not set
CONFIG_NUMA=y
CONFIG_NUMA_AWARE_SPINLOCKS=y
CONFIG_AMD_NUMA=y
CONFIG_X86_64_ACPI_NUMA=y
CONFIG_NUMA_EMU=y
+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,10 @@ static __always_inline u32 queued_fetch_set_pending_acquire(struct qspinlock *lo
	return val;
}

#ifdef CONFIG_NUMA_AWARE_SPINLOCKS
extern void cna_configure_spin_lock_slowpath(void);
#endif

#ifdef CONFIG_PARAVIRT_SPINLOCKS
extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);
extern void __pv_init_lock_hash(void);
Loading