[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140120182019.GA26515@redhat.com>
Date: Mon, 20 Jan 2014 19:20:19 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Alan Stern <stern@...land.harvard.edu>,
Peter Zijlstra <peterz@...radead.org>
Cc: Dave Jones <davej@...hat.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ingo Molnar <mingo@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Paul McKenney <paulmck@...ux.vnet.ibm.com>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org
Subject: [PATCH 5/5] lockdep: pack subclass/trylock/read/check into a
single argument
lock_acquire() takes 7 arguments, we can pack 4 "short" enums into
the single "unsigned long acqf" to help the callers which mostly
use the constant values of subclass/trylock/read/check,
$ size vmlinux
text data bss dec hex filename
- 5262832 2970280 10125312 18358424 1182098 vmlinux
+ 5255131 2974376 10125312 18354819 1181283 vmlinux
Signed-off-by: Oleg Nesterov <oleg@...hat.com>
---
include/linux/lockdep.h | 29 ++++++++++++++++++++++++++---
kernel/locking/lockdep.c | 17 +++++++++++++----
2 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 060e513..23a8af3 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -329,9 +329,32 @@ static inline int lockdep_match_key(struct lockdep_map *lock,
* 0: simple checks (freeing, held-at-exit-time, etc.)
* 1: full validation
*/
-extern void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
- int trylock, int read, int check,
- struct lockdep_map *nest_lock, unsigned long ip);
+#define ACQF_SUBCLASS_SHIFT 0
+#define ACQF_SUBCLASS_BITS 3
+
+#define ACQF_TRYLOCK_SHIFT (ACQF_SUBCLASS_SHIFT + ACQF_SUBCLASS_BITS)
+#define ACQF_TRYLOCK_BITS 1
+
+#define ACQF_READ_SHIFT (ACQF_TRYLOCK_SHIFT + ACQF_TRYLOCK_BITS)
+#define ACQF_READ_BITS 2
+
+#define ACQF_CHECK_SHIFT (ACQF_READ_SHIFT + ACQF_READ_BITS)
+#define ACQF_CHECK_BITS 1
+
+extern void do_lock_acquire(struct lockdep_map *lock, unsigned long acqf,
+ struct lockdep_map *nest_lock, unsigned long ip);
+
+static inline void lock_acquire(struct lockdep_map *lock,
+ unsigned int subclass, int trylock, int read, int check,
+ struct lockdep_map *nest_lock, unsigned long ip)
+{
+ unsigned long acqf = (subclass << ACQF_SUBCLASS_SHIFT) |
+ (trylock << ACQF_TRYLOCK_SHIFT) |
+ (read << ACQF_READ_SHIFT) |
+ (check << ACQF_CHECK_SHIFT);
+
+ do_lock_acquire(lock, acqf, nest_lock, ip);
+}
extern void lock_release(struct lockdep_map *lock, int nested,
unsigned long ip);
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index 28e41c0..8826557 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -3581,10 +3581,19 @@ EXPORT_SYMBOL_GPL(lock_set_class);
* We are not always called with irqs disabled - do that here,
* and also avoid lockdep recursion:
*/
-void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
- int trylock, int read, int check,
- struct lockdep_map *nest_lock, unsigned long ip)
+void do_lock_acquire(struct lockdep_map *lock, unsigned long acqf,
+ struct lockdep_map *nest_lock, unsigned long ip)
{
+ #define ACQF(bits, what) \
+ ((bits >> ACQF_ ## what ## _SHIFT) & \
+ ((1 << ACQF_ ## what ## _BITS) - 1))
+
+ unsigned int subclass = ACQF(acqf, SUBCLASS);
+ unsigned int trylock = ACQF(acqf, TRYLOCK);
+ unsigned int read = ACQF(acqf, READ);
+ unsigned int check = ACQF(acqf, CHECK);
+ #undef ACQF
+
unsigned long flags;
if (unlikely(current->lockdep_recursion))
@@ -3600,7 +3609,7 @@ void lock_acquire(struct lockdep_map *lock, unsigned int subclass,
current->lockdep_recursion = 0;
raw_local_irq_restore(flags);
}
-EXPORT_SYMBOL_GPL(lock_acquire);
+EXPORT_SYMBOL_GPL(do_lock_acquire);
void lock_release(struct lockdep_map *lock, int nested,
unsigned long ip)
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists