Commit 2dfbfabf authored by Wei Li's avatar Wei Li
Browse files

locking/qspinlock: Add CNA support for ARM64 without pvspinlock

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8T8XV


CVE: NA

-------------------------------------------------

The CNA spinlock is enabled base on 'pv_ops' of pvspinlock, and is only
supported on x86_64 now, add support for arm64 without pvspinlock.

Signed-off-by: default avatarWei Li <liwei391@huawei.com>
parent e86cbfc1
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1545,6 +1545,21 @@ config NODES_SHIFT
	  Specify the maximum number of NUMA Nodes available on the target
	  system.  Increases memory reserved to accommodate various tables.

config NUMA_AWARE_SPINLOCKS
	bool "Numa-aware spinlocks"
	depends on NUMA
	depends on QUEUED_SPINLOCKS
	default n
	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.

source "kernel/Kconfig.hz"

config ARCH_SPARSEMEM_ENABLE
+0 −1
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@
generic-y += early_ioremap.h
generic-y += mcs_spinlock.h
generic-y += qrwlock.h
generic-y += qspinlock.h
generic-y += parport.h
generic-y += user.h

+38 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_ARM64_QSPINLOCK_H
#define _ASM_ARM64_QSPINLOCK_H

#ifdef CONFIG_NUMA_AWARE_SPINLOCKS
#include <asm-generic/qspinlock_types.h>

extern void cna_configure_spin_lock_slowpath(void);

extern void (*cna_queued_spin_lock_slowpath)(struct qspinlock *lock, u32 val);
extern void native_queued_spin_lock_slowpath(struct qspinlock *lock, u32 val);

#define	queued_spin_unlock queued_spin_unlock
/**
 * queued_spin_unlock - release a queued spinlock
 * @lock : Pointer to queued spinlock structure
 *
 * A smp_store_release() on the least-significant byte.
 */
static inline void native_queued_spin_unlock(struct qspinlock *lock)
{
	smp_store_release(&lock->locked, 0);
}

static inline void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
{
	cna_queued_spin_lock_slowpath(lock, val);
}

static inline void queued_spin_unlock(struct qspinlock *lock)
{
	native_queued_spin_unlock(lock);
}
#endif

#include <asm-generic/qspinlock.h>

#endif /* _ASM_ARM64_QSPINLOCK_H */
+0 −4
Original line number Diff line number Diff line
@@ -1612,10 +1612,6 @@ void __init alternative_instructions(void)
	 */
	paravirt_set_cap();

#if defined(CONFIG_NUMA_AWARE_SPINLOCKS)
	cna_configure_spin_lock_slowpath();
#endif

	/*
	 * First patch paravirt functions, such that we overwrite the indirect
	 * call with the direct call.
+3 −1
Original line number Diff line number Diff line
@@ -1013,7 +1013,9 @@ void start_kernel(void)
		      panic_param);

	lockdep_init();

#if defined(CONFIG_NUMA_AWARE_SPINLOCKS)
	cna_configure_spin_lock_slowpath();
#endif
	/*
	 * Need to run this when irqs are enabled, because it wants
	 * to self-test [hard/soft]-irqs on/off lock inversion bugs
Loading