From: liangdongxu 00014050 <liangdongxu@hihonor.com>
To: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"arve@android.com" <arve@android.com>,
"tkjos@android.com" <tkjos@android.com>,
"maco@android.com" <maco@android.com>,
"joel@joelfernandes.org" <joel@joelfernandes.org>,
"christian@brauner.io" <christian@brauner.io>,
"hridya@google.com" <hridya@google.com>,
"surenb@google.com" <surenb@google.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"mingo@redhat.com" <mingo@redhat.com>,
"will@kernel.org" <will@kernel.org>,
"longman@redhat.com" <longman@redhat.com>,
"boqun.feng@gmail.com" <boqun.feng@gmail.com>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"sangmoon.kim@samsung.com" <sangmoon.kim@samsung.com>,
"saravanak@google.com" <saravanak@google.com>
Subject: [PATCH] ANDROID: mutex: Add vendor hook and oem data to the mutex
Date: Fri, 13 May 2022 13:45:34 +0000 [thread overview]
Message-ID: <c5b5bd5f3bea4a17a66b115a16a628d5@hihonor.com> (raw)
Add hooks and oem data to apply oem's optimization of mutex.
Signed-off-by: Dezhi Huang <huangdezhi@hihonor.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);
reply other threads:[~2022-05-13 14:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c5b5bd5f3bea4a17a66b115a16a628d5@hihonor.com \
--to=liangdongxu@hihonor.com \
--cc=arve@android.com \
--cc=boqun.feng@gmail.com \
--cc=christian@brauner.io \
--cc=gregkh@linuxfoundation.org \
--cc=hridya@google.com \
--cc=joel@joelfernandes.org \
--cc=longman@redhat.com \
--cc=maco@android.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sangmoon.kim@samsung.com \
--cc=saravanak@google.com \
--cc=surenb@google.com \
--cc=tkjos@android.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®