linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] locking/mutex: Move mutex flag macros to linux/mutex.h
@ 2019-07-29 10:52 Mukesh Ojha
  2019-07-29 10:52 ` [PATCH 2/2] locking/mutex: Use mutex flags macro instead of hard code value Mukesh Ojha
  0 siblings, 1 reply; 10+ messages in thread
From: Mukesh Ojha @ 2019-07-29 10:52 UTC (permalink / raw)
  To: peterz, mingo, will, linux-kernel; +Cc: Mukesh Ojha

There exist a place where we use hard code value for mutex
flag(e.g in mutex.h __mutex_owner()). Let's move the mutex
flag macros to header linux/mutex.h, so that it could be
reused at other places as well.

Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
---
 include/linux/mutex.h  | 15 +++++++++++++++
 kernel/locking/mutex.c | 15 ---------------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index dcd03fe..79b28be 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -20,6 +20,21 @@
 #include <linux/osq_lock.h>
 #include <linux/debug_locks.h>
 
+/*
+ * @owner: contains: 'struct task_struct *' to the current lock owner,
+ * NULL means not owned. Since task_struct pointers are aligned at
+ * at least L1_CACHE_BYTES, we have low bits to store extra state.
+ *
+ * Bit0 indicates a non-empty waiter list; unlock must issue a wakeup.
+ * Bit1 indicates unlock needs to hand the lock to the top-waiter
+ * Bit2 indicates handoff has been done and we're waiting for pickup.
+ */
+#define MUTEX_FLAG_WAITERS	0x01
+#define MUTEX_FLAG_HANDOFF	0x02
+#define MUTEX_FLAG_PICKUP	0x04
+
+#define MUTEX_FLAGS		0x07
+
 struct ww_acquire_ctx;
 
 /*
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c
index 5e06973..b74c87d 100644
--- a/kernel/locking/mutex.c
+++ b/kernel/locking/mutex.c
@@ -50,21 +50,6 @@
 }
 EXPORT_SYMBOL(__mutex_init);
 
-/*
- * @owner: contains: 'struct task_struct *' to the current lock owner,
- * NULL means not owned. Since task_struct pointers are aligned at
- * at least L1_CACHE_BYTES, we have low bits to store extra state.
- *
- * Bit0 indicates a non-empty waiter list; unlock must issue a wakeup.
- * Bit1 indicates unlock needs to hand the lock to the top-waiter
- * Bit2 indicates handoff has been done and we're waiting for pickup.
- */
-#define MUTEX_FLAG_WAITERS	0x01
-#define MUTEX_FLAG_HANDOFF	0x02
-#define MUTEX_FLAG_PICKUP	0x04
-
-#define MUTEX_FLAGS		0x07
-
 static inline struct task_struct *__owner_task(unsigned long owner)
 {
 	return (struct task_struct *)(owner & ~MUTEX_FLAGS);
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-07-30 16:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-29 10:52 [PATCH 1/2] locking/mutex: Move mutex flag macros to linux/mutex.h Mukesh Ojha
2019-07-29 10:52 ` [PATCH 2/2] locking/mutex: Use mutex flags macro instead of hard code value Mukesh Ojha
2019-07-29 11:07   ` Peter Zijlstra
2019-07-30  7:53     ` Mukesh Ojha
2019-07-30  8:03       ` Peter Zijlstra
2019-07-30 12:40         ` Mukesh Ojha
2019-07-30 16:02           ` Peter Zijlstra
2019-07-30 16:25             ` Mukesh Ojha
2019-07-30 15:49         ` [PATCH 1/2 v2] locking/mutex: Make __mutex_owner static to mutex.c Mukesh Ojha
2019-07-30 15:49           ` [PATCH 2/2 v2] locking/mutex: Use mutex flags macro instead of hard code value Mukesh Ojha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).