Skip to content

Commit a7967bc

Browse files
lgebyungchulparkIngo Molnar
authored andcommitted
sched/completions: Add support for initializing completions with lockdep_map
Sometimes we want to initialize completions with sparate lockdep maps to assign lock classes as desired. For example, the workqueue code needs to directly manage lockdep maps, since only the code is aware of how to classify lockdep maps properly. Provide additional macros initializing completions in that way. Signed-off-by: Byungchul Park <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent e121d64 commit a7967bc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/linux/completion.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ static inline void complete_release_commit(struct completion *x)
4949
lock_commit_crosslock((struct lockdep_map *)&x->map);
5050
}
5151

52+
#define init_completion_map(x, m) \
53+
do { \
54+
lockdep_init_map_crosslock((struct lockdep_map *)&(x)->map, \
55+
(m)->name, (m)->key, 0); \
56+
__init_completion(x); \
57+
} while (0)
58+
5259
#define init_completion(x) \
5360
do { \
5461
static struct lock_class_key __key; \
@@ -58,6 +65,7 @@ do { \
5865
__init_completion(x); \
5966
} while (0)
6067
#else
68+
#define init_completion_map(x, m) __init_completion(x)
6169
#define init_completion(x) __init_completion(x)
6270
static inline void complete_acquire(struct completion *x) {}
6371
static inline void complete_release(struct completion *x) {}
@@ -73,6 +81,9 @@ static inline void complete_release_commit(struct completion *x) {}
7381
{ 0, __WAIT_QUEUE_HEAD_INITIALIZER((work).wait) }
7482
#endif
7583

84+
#define COMPLETION_INITIALIZER_ONSTACK_MAP(work, map) \
85+
(*({ init_completion_map(&(work), &(map)); &(work); }))
86+
7687
#define COMPLETION_INITIALIZER_ONSTACK(work) \
7788
(*({ init_completion(&work); &work; }))
7889

@@ -102,8 +113,11 @@ static inline void complete_release_commit(struct completion *x) {}
102113
#ifdef CONFIG_LOCKDEP
103114
# define DECLARE_COMPLETION_ONSTACK(work) \
104115
struct completion work = COMPLETION_INITIALIZER_ONSTACK(work)
116+
# define DECLARE_COMPLETION_ONSTACK_MAP(work, map) \
117+
struct completion work = COMPLETION_INITIALIZER_ONSTACK_MAP(work, map)
105118
#else
106119
# define DECLARE_COMPLETION_ONSTACK(work) DECLARE_COMPLETION(work)
120+
# define DECLARE_COMPLETION_ONSTACK_MAP(work, map) DECLARE_COMPLETION(work)
107121
#endif
108122

109123
/**

0 commit comments

Comments
 (0)