On 10/16/19 12:29 AM, Alex Kogan wrote: > Keep track of the number of intra-node lock handoffs, and force > inter-node handoff once this number reaches a preset threshold. > > Signed-off-by: Alex Kogan <alex.kogan@xxxxxxxxxx> > Reviewed-by: Steve Sistare <steven.sistare@xxxxxxxxxx> > --- > kernel/locking/qspinlock.c | 3 +++ > kernel/locking/qspinlock_cna.h | 30 +++++++++++++++++++++++++++--- > 2 files changed, 30 insertions(+), 3 deletions(-) > > diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c > index 6d8c4a52e44e..1d0d884308ef 100644 > --- a/kernel/locking/qspinlock.c > +++ b/kernel/locking/qspinlock.c > @@ -597,6 +597,9 @@ EXPORT_SYMBOL(queued_spin_lock_slowpath); > #if !defined(_GEN_CNA_LOCK_SLOWPATH) && defined(CONFIG_NUMA_AWARE_SPINLOCKS) > #define _GEN_CNA_LOCK_SLOWPATH > > +#undef pv_init_node > +#define pv_init_node cna_init_node > + > #undef pv_wait_head_or_lock > #define pv_wait_head_or_lock cna_pre_scan > > diff --git a/kernel/locking/qspinlock_cna.h b/kernel/locking/qspinlock_cna.h > index 4d095f742d31..b92a6f9a19db 100644 > --- a/kernel/locking/qspinlock_cna.h > +++ b/kernel/locking/qspinlock_cna.h > @@ -50,9 +50,19 @@ struct cna_node { > struct mcs_spinlock mcs; > int numa_node; > u32 encoded_tail; > - u32 pre_scan_result; /* 0 or an encoded tail */ > + u32 pre_scan_result; /* 0, 1 or an encoded tail */ > + u32 intra_count; > }; > > +/* > + * Controls the threshold for the number of intra-node lock hand-offs. It can > + * be tuned and depend, e.g., on the number of CPUs per node. For now, > + * choose a value that provides reasonable long-term fairness without > + * sacrificing performance compared to a version that does not have any > + * fairness guarantees. > + */ > +#define INTRA_NODE_HANDOFF_THRESHOLD (1 << 16) I think 64k is too high. I will be more comfortable with a number like (1 << 8). The worst case latency for a lock waiter from the other node is just not acceptable. Cheers, Longman