From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755917AbcEaRCH (ORCPT ); Tue, 31 May 2016 13:02:07 -0400 Received: from g2t1383g.austin.hpe.com ([15.233.16.89]:39601 "EHLO g2t1383g.austin.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755872AbcEaRCC (ORCPT ); Tue, 31 May 2016 13:02:02 -0400 From: Waiman Long To: Peter Zijlstra , Ingo Molnar Cc: linux-kernel@vger.kernel.org, Pan Xinhui , Boqun Feng , Scott J Norton , Douglas Hatch , Waiman Long Subject: [PATCH v2 4/5] locking/pvstat: Add stat counter to track _Q_SLOW_VAL race Date: Tue, 31 May 2016 12:53:50 -0400 Message-Id: <1464713631-1066-5-git-send-email-Waiman.Long@hpe.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1464713631-1066-1-git-send-email-Waiman.Long@hpe.com> References: <1464713631-1066-1-git-send-email-Waiman.Long@hpe.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds a new stat counter to track if the _Q_SLOW_VAL race between lock owner running pv_kick_node() and queue head running pv_wait_head_or_lock() is happening. Signed-off-by: Waiman Long --- kernel/locking/qspinlock_paravirt.h | 4 +++- kernel/locking/qspinlock_stat.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/locking/qspinlock_paravirt.h b/kernel/locking/qspinlock_paravirt.h index 54e03b9..3d57296 100644 --- a/kernel/locking/qspinlock_paravirt.h +++ b/kernel/locking/qspinlock_paravirt.h @@ -468,8 +468,10 @@ pv_wait_head_or_lock(struct qspinlock *lock, struct mcs_spinlock *node) WRITE_ONCE(l->locked, _Q_LOCKED_VAL); clear_pending(lock); goto gotlock; + } else { + /* old == _Q_SLOW_VAL. */ + qstat_inc(qstat_pv_slow_race, true); } - /* old == _Q_SLOW_VAL. */ } } clear_pending(lock); /* Enable lock stealing */ diff --git a/kernel/locking/qspinlock_stat.h b/kernel/locking/qspinlock_stat.h index 3cd07a9..a40262e 100644 --- a/kernel/locking/qspinlock_stat.h +++ b/kernel/locking/qspinlock_stat.h @@ -24,6 +24,7 @@ * pv_latency_wake - average latency (ns) from vCPU kick to wakeup * pv_lock_slowpath - # of locking operations via the slowpath * pv_lock_stealing - # of lock stealing operations + * pv_slow_race - # of _Q_SLOW_VAL races between lock owner & qhead * pv_spurious_wakeup - # of spurious wakeups in non-head vCPUs * pv_wait_again - # of wait's after a queue head vCPU kick * pv_wait_early - # of early vCPU wait's @@ -48,6 +49,7 @@ enum qlock_stats { qstat_pv_latency_wake, qstat_pv_lock_slowpath, qstat_pv_lock_stealing, + qstat_pv_slow_race, qstat_pv_spurious_wakeup, qstat_pv_wait_again, qstat_pv_wait_early, @@ -69,11 +71,12 @@ static const char * const qstat_names[qstat_num + 1] = { [qstat_pv_hash_hops] = "pv_hash_hops", [qstat_pv_kick_unlock] = "pv_kick_unlock", [qstat_pv_kick_wake] = "pv_kick_wake", - [qstat_pv_spurious_wakeup] = "pv_spurious_wakeup", [qstat_pv_latency_kick] = "pv_latency_kick", [qstat_pv_latency_wake] = "pv_latency_wake", [qstat_pv_lock_slowpath] = "pv_lock_slowpath", [qstat_pv_lock_stealing] = "pv_lock_stealing", + [qstat_pv_slow_race] = "pv_slow_race", + [qstat_pv_spurious_wakeup] = "pv_spurious_wakeup", [qstat_pv_wait_again] = "pv_wait_again", [qstat_pv_wait_early] = "pv_wait_early", [qstat_pv_wait_head] = "pv_wait_head", -- 1.7.1