Re: [PATCH v7 4/5] locking/qspinlock: Introduce starvation avoidance into CNA
From: Waiman Long <longman@redhat.com>
Date: 2019-12-06 18:09:52
Also in:
linux-arch, lkml
On 11/25/19 4:07 PM, Alex Kogan wrote:
quoted hunk ↗ jump to hunk
Keep track of the number of intra-node lock handoffs, and force inter-node handoff once this number reaches a preset threshold. The default value for the threshold can be overridden with the new kernel boot command-line option "numa_spinlock_threshold". Signed-off-by: Alex Kogan <redacted> Reviewed-by: Steve Sistare <redacted> --- .../admin-guide/kernel-parameters.txt | 8 ++++++ arch/x86/kernel/alternative.c | 27 +++++++++++++++++++ kernel/locking/qspinlock.c | 3 +++ kernel/locking/qspinlock_cna.h | 27 ++++++++++++++++--- 4 files changed, 62 insertions(+), 3 deletions(-)diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 904cb32f592d..887fbfce701d 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt@@ -3185,6 +3185,14 @@ Not specifying this option is equivalent to numa_spinlock=auto. + numa_spinlock_threshold= [NUMA, PV_OPS] + Set the threshold 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. + Valid values are in the [0..31] range. Smaller values + result in a more fair, but less performant spinlock, and + vice versa. The default value is 16. + cpu0_hotplug [X86] Turn on CPU0 hotplug feature when CONFIG_BOOTPARAM_HOTPLUG_CPU0 is off. Some features depend on CPU0. Known dependencies are:diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 6a4ccbf4e09c..28552e0491b5 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c@@ -723,6 +723,33 @@ static int __init numa_spinlock_setup(char *str) __setup("numa_spinlock=", numa_spinlock_setup); +/* + * Controls the threshold for the number of intra-node lock hand-offs before + * the NUMA-aware variant of spinlock is forced to be passed to a thread on + * another NUMA node. By default, the chosen value provides reasonable + * long-term fairness without sacrificing performance compared to a lock + * that does not have any fairness guarantees. + */ +int intra_node_handoff_threshold = 1 << 16;
^ __ro_after_init
+
+static int __init numa_spinlock_threshold_setup(char *str)
+{
+ int new_threshold_param;
+
+ if (get_option(&str, &new_threshold_param)) {
+ /* valid value is between 0 and 31 */
+ if (new_threshold_param < 0 || new_threshold_param > 31)
+ return 0;
+
+ intra_node_handoff_threshold = 1 << new_threshold_param;
+ return 1;
+ }
+
+ return 0;
+}
+
+__setup("numa_spinlock_threshold=", numa_spinlock_threshold_setup);
+
#endif
Against, this should be in qspinlock_can.h not in alternative.c. Cheers, Longman _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel