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>] [day] [month] [year] [list]
Message-ID: <c5b5bd5f3bea4a17a66b115a16a628d5@hihonor.com>
Date:   Fri, 13 May 2022 13:45:34 +0000
From:   liangdongxu 00014050 <liangdongxu@...onor.com>
To:     "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        "arve@...roid.com" <arve@...roid.com>,
        "tkjos@...roid.com" <tkjos@...roid.com>,
        "maco@...roid.com" <maco@...roid.com>,
        "joel@...lfernandes.org" <joel@...lfernandes.org>,
        "christian@...uner.io" <christian@...uner.io>,
        "hridya@...gle.com" <hridya@...gle.com>,
        "surenb@...gle.com" <surenb@...gle.com>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "will@...nel.org" <will@...nel.org>,
        "longman@...hat.com" <longman@...hat.com>,
        "boqun.feng@...il.com" <boqun.feng@...il.com>,
        "rostedt@...dmis.org" <rostedt@...dmis.org>,
        "sangmoon.kim@...sung.com" <sangmoon.kim@...sung.com>,
        "saravanak@...gle.com" <saravanak@...gle.com>
Subject: [PATCH] ANDROID: mutex: Add vendor hook and oem data to the mutex


Add hooks and oem data to apply oem's optimization of mutex.

Signed-off-by: Dezhi Huang <huangdezhi@...onor.com>
---

diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c
index 8ffa2fb..db972d1 100644
--- a/drivers/android/vendor_hooks.c
+++ b/drivers/android/vendor_hooks.c
@@ -91,6 +91,10 @@
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_futex_plist_add);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_wait_start);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_wait_finish);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_waiter_list_add);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_unlock_slowpath);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_waiting);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_init);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rtmutex_wait_start);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rtmutex_wait_finish);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_read_wait_start);
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index 8f226d4..93a5bf0 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -19,6 +19,7 @@
 #include <asm/processor.h>
 #include <linux/osq_lock.h>
 #include <linux/debug_locks.h>
+#include <linux/android_vendor.h>
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 # define __DEP_MAP_MUTEX_INITIALIZER(lockname)			\
@@ -73,6 +74,7 @@
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 	struct lockdep_map	dep_map;
 #endif
+	ANDROID_OEM_DATA(1);
 };
 
 #ifdef CONFIG_DEBUG_MUTEXES
diff --git a/include/trace/hooks/dtask.h b/include/trace/hooks/dtask.h
index 6f005d4..3c4277f 100644
--- a/include/trace/hooks/dtask.h
+++ b/include/trace/hooks/dtask.h
@@ -11,12 +11,28 @@
  * mechanism for vendor modules to hook and extend functionality
  */
 struct mutex;
+struct mutex_waiter;
 DECLARE_HOOK(android_vh_mutex_wait_start,
 	TP_PROTO(struct mutex *lock),
 	TP_ARGS(lock));
 DECLARE_HOOK(android_vh_mutex_wait_finish,
 	TP_PROTO(struct mutex *lock),
 	TP_ARGS(lock));
+DECLARE_HOOK(android_vh_mutex_waiter_list_add,
+		TP_PROTO(struct mutex *lock,
+			struct mutex_waiter *waiter,
+			struct list_head *list,
+			bool *add_finish),
+		TP_ARGS(lock, waiter, list, add_finish));
+DECLARE_HOOK(android_vh_mutex_unlock_slowpath,
+		TP_PROTO(struct mutex *lock),
+		TP_ARGS(lock));
+DECLARE_HOOK(android_vh_mutex_waiting,
+	TP_PROTO(struct mutex *lock),
+	TP_ARGS(lock));
+DECLARE_HOOK(android_vh_mutex_init,
+	TP_PROTO(struct mutex *lock),
+	TP_ARGS(lock));
 
 struct rt_mutex_base;
 DECLARE_HOOK(android_vh_rtmutex_wait_start,
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 77fa3dc..37f6316 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -51,6 +51,7 @@
 	osq_lock_init(&lock->osq);
 #endif
 
+	trace_android_vh_mutex_init(lock);
 	debug_mutex_init(lock, name, key);
 }
 EXPORT_SYMBOL(__mutex_init);
@@ -201,9 +202,12 @@
 __mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
 		   struct list_head *list)
 {
+	bool add_finish = false;
 	debug_mutex_add_waiter(lock, waiter, current);
 
-	list_add_tail(&waiter->list, list);
+	trace_android_vh_mutex_waiter_list_add(lock, waiter, list, &add_finish);
+	if (!add_finish)
+		list_add_tail(&waiter->list, list);
 	if (__mutex_waiter_is_first(lock, waiter))
 		__mutex_set_flag(lock, MUTEX_FLAG_WAITERS);
 }
@@ -668,6 +672,7 @@
 				goto err;
 		}
 
+		trace_android_vh_mutex_waiting(lock);
 		raw_spin_unlock(&lock->wait_lock);
 		schedule_preempt_disabled();
 
@@ -895,6 +900,7 @@
 	if (owner & MUTEX_FLAG_HANDOFF)
 		__mutex_handoff(lock, next);
 
+	trace_android_vh_mutex_unlock_slowpath(lock);
 	raw_spin_unlock(&lock->wait_lock);
 
 	wake_up_q(&wake_q);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ