lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200210204651.21674-3-longman@redhat.com>
Date:   Mon, 10 Feb 2020 15:46:50 -0500
From:   Waiman Long <longman@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
        Christoph Lameter <cl@...ux.com>,
        Pekka Enberg <penberg@...nel.org>,
        David Rientjes <rientjes@...gle.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        Waiman Long <longman@...hat.com>
Subject: [PATCH 2/3] locking/mutex: Enable some lock event counters

Add a preliminary set of mutex locking event counters.

Signed-off-by: Waiman Long <longman@...hat.com>
---
 kernel/locking/lock_events_list.h | 9 +++++++++
 kernel/locking/mutex.c            | 9 ++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/lock_events_list.h b/kernel/locking/lock_events_list.h
index 239039d0ce21..90db996f0608 100644
--- a/kernel/locking/lock_events_list.h
+++ b/kernel/locking/lock_events_list.h
@@ -69,3 +69,12 @@ LOCK_EVENT(rwsem_rlock_handoff)	/* # of read lock handoffs		*/
 LOCK_EVENT(rwsem_wlock)		/* # of write locks acquired		*/
 LOCK_EVENT(rwsem_wlock_fail)	/* # of failed write lock acquisitions	*/
 LOCK_EVENT(rwsem_wlock_handoff)	/* # of write lock handoffs		*/
+
+/*
+ * Locking events for  mutex
+ */
+LOCK_EVENT(mutex_slowpath)	/* # of mutex sleeping slowpaths	*/
+LOCK_EVENT(mutex_optspin)	/* # of successful optimistic spinnings	*/
+LOCK_EVENT(mutex_timeout)	/* # of mutex timeouts			*/
+LOCK_EVENT(mutex_sleep)		/* # of mutex sleeps			*/
+LOCK_EVENT(mutex_handoff)	/* # of mutex lock handoffs		*/
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 976179a4ed9e..1c5c252ce6fb 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -36,6 +36,7 @@
 #else
 # include "mutex.h"
 #endif
+#include "lock_events.h"
 
 void
 __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key)
@@ -996,10 +997,12 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 		lock_acquired(&lock->dep_map, ip);
 		if (use_ww_ctx && ww_ctx)
 			ww_mutex_set_context_fastpath(ww, ww_ctx);
+		lockevent_inc(mutex_optspin);
 		preempt_enable();
 		return 0;
 	}
 
+	lockevent_inc(mutex_slowpath);
 	spin_lock(&lock->wait_lock);
 	/*
 	 * After waiting to acquire the wait_lock, try again.
@@ -1069,12 +1072,14 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 				to = mutex_setup_hrtimer(&timer_sleeper,
 							 timeout);
 			if (!to || !to->task) {
+				lockevent_inc(mutex_timeout);
 				ret = -ETIMEDOUT;
 				goto err;
 			}
 		}
 
 		spin_unlock(&lock->wait_lock);
+		lockevent_inc(mutex_sleep);
 		schedule_preempt_disabled();
 
 		/*
@@ -1083,8 +1088,10 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 		 */
 		if ((use_ww_ctx && ww_ctx) || !first) {
 			first = __mutex_waiter_is_first(lock, &waiter);
-			if (first)
+			if (first) {
 				__mutex_set_flag(lock, MUTEX_FLAG_HANDOFF);
+				lockevent_inc(mutex_handoff);
+			}
 		}
 
 		set_current_state(state);
-- 
2.18.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ