[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250513100730.12664-39-byungchul@sk.com>
Date: Tue, 13 May 2025 19:07:25 +0900
From: Byungchul Park <byungchul@...com>
To: linux-kernel@...r.kernel.org
Cc: kernel_team@...ynix.com,
torvalds@...ux-foundation.org,
damien.lemoal@...nsource.wdc.com,
linux-ide@...r.kernel.org,
adilger.kernel@...ger.ca,
linux-ext4@...r.kernel.org,
mingo@...hat.com,
peterz@...radead.org,
will@...nel.org,
tglx@...utronix.de,
rostedt@...dmis.org,
joel@...lfernandes.org,
sashal@...nel.org,
daniel.vetter@...ll.ch,
duyuyang@...il.com,
johannes.berg@...el.com,
tj@...nel.org,
tytso@....edu,
willy@...radead.org,
david@...morbit.com,
amir73il@...il.com,
gregkh@...uxfoundation.org,
kernel-team@....com,
linux-mm@...ck.org,
akpm@...ux-foundation.org,
mhocko@...nel.org,
minchan@...nel.org,
hannes@...xchg.org,
vdavydov.dev@...il.com,
sj@...nel.org,
jglisse@...hat.com,
dennis@...nel.org,
cl@...ux.com,
penberg@...nel.org,
rientjes@...gle.com,
vbabka@...e.cz,
ngupta@...are.org,
linux-block@...r.kernel.org,
josef@...icpanda.com,
linux-fsdevel@...r.kernel.org,
jack@...e.cz,
jlayton@...nel.org,
dan.j.williams@...el.com,
hch@...radead.org,
djwong@...nel.org,
dri-devel@...ts.freedesktop.org,
rodrigosiqueiramelo@...il.com,
melissa.srw@...il.com,
hamohammed.sa@...il.com,
harry.yoo@...cle.com,
chris.p.wilson@...el.com,
gwan-gyeong.mun@...el.com,
max.byungchul.park@...il.com,
boqun.feng@...il.com,
longman@...hat.com,
yskelg@...il.com,
yunseong.kim@...csson.com,
yeoreum.yun@....com,
netdev@...r.kernel.org,
matthew.brost@...el.com,
her0gyugyu@...il.com
Subject: [PATCH v15 38/43] completion, dept: introduce init_completion_dmap() API
Currently, dept uses dept's map embedded in task_struct to track
dependencies related to wait_for_completion() and its family. So it
doesn't need an explicit map basically.
However, for those who want to set the maps with customized class or
key, introduce a new API to use external maps.
Signed-off-by: Byungchul Park <byungchul@...com>
---
include/linux/completion.h | 40 +++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/include/linux/completion.h b/include/linux/completion.h
index 4d8fb1d95c0a..e50f7d9b4b97 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -27,17 +27,15 @@
struct completion {
unsigned int done;
struct swait_queue_head wait;
+ struct dept_map *dmap;
};
-#define init_completion(x) \
-do { \
- __init_completion(x); \
-} while (0)
+#define init_completion(x) init_completion_dmap(x, NULL)
/*
- * XXX: No use cases for now. Fill the body when needed.
+ * XXX: This usage using lockdep's map should be deprecated.
*/
-#define init_completion_map(x, m) init_completion(x)
+#define init_completion_map(x, m) init_completion_dmap(x, NULL)
static inline void complete_acquire(struct completion *x, long timeout)
{
@@ -48,8 +46,11 @@ static inline void complete_release(struct completion *x)
}
#define COMPLETION_INITIALIZER(work) \
- { 0, __SWAIT_QUEUE_HEAD_INITIALIZER((work).wait), }
+ { 0, __SWAIT_QUEUE_HEAD_INITIALIZER((work).wait), .dmap = NULL, }
+/*
+ * XXX: This usage using lockdep's map should be deprecated.
+ */
#define COMPLETION_INITIALIZER_ONSTACK_MAP(work, map) \
(*({ init_completion_map(&(work), &(map)); &(work); }))
@@ -90,15 +91,18 @@ static inline void complete_release(struct completion *x)
#endif
/**
- * __init_completion - Initialize a dynamically allocated completion
+ * init_completion_dmap - Initialize a dynamically allocated completion
* @x: pointer to completion structure that is to be initialized
+ * @dmap: pointer to external dept's map to be used as a separated map
*
* This inline function will initialize a dynamically created completion
* structure.
*/
-static inline void __init_completion(struct completion *x)
+static inline void init_completion_dmap(struct completion *x,
+ struct dept_map *dmap)
{
x->done = 0;
+ x->dmap = dmap;
init_swait_queue_head(&x->wait);
}
@@ -136,13 +140,13 @@ extern void complete_all(struct completion *);
#define wait_for_completion(x) \
({ \
- sdt_might_sleep_start_timeout(NULL, -1L); \
+ sdt_might_sleep_start_timeout((x)->dmap, -1L); \
__wait_for_completion(x); \
sdt_might_sleep_end(); \
})
#define wait_for_completion_io(x) \
({ \
- sdt_might_sleep_start_timeout(NULL, -1L); \
+ sdt_might_sleep_start_timeout((x)->dmap, -1L); \
__wait_for_completion_io(x); \
sdt_might_sleep_end(); \
})
@@ -150,7 +154,7 @@ extern void complete_all(struct completion *);
({ \
int __ret; \
\
- sdt_might_sleep_start_timeout(NULL, -1L); \
+ sdt_might_sleep_start_timeout((x)->dmap, -1L); \
__ret = __wait_for_completion_interruptible(x); \
sdt_might_sleep_end(); \
__ret; \
@@ -159,7 +163,7 @@ extern void complete_all(struct completion *);
({ \
int __ret; \
\
- sdt_might_sleep_start_timeout(NULL, -1L); \
+ sdt_might_sleep_start_timeout((x)->dmap, -1L); \
__ret = __wait_for_completion_killable(x); \
sdt_might_sleep_end(); \
__ret; \
@@ -168,7 +172,7 @@ extern void complete_all(struct completion *);
({ \
int __ret; \
\
- sdt_might_sleep_start_timeout(NULL, -1L); \
+ sdt_might_sleep_start_timeout((x)->dmap, -1L); \
__ret = __wait_for_completion_state(x, s); \
sdt_might_sleep_end(); \
__ret; \
@@ -177,7 +181,7 @@ extern void complete_all(struct completion *);
({ \
unsigned long __ret; \
\
- sdt_might_sleep_start_timeout(NULL, t); \
+ sdt_might_sleep_start_timeout((x)->dmap, t); \
__ret = __wait_for_completion_timeout(x, t); \
sdt_might_sleep_end(); \
__ret; \
@@ -186,7 +190,7 @@ extern void complete_all(struct completion *);
({ \
unsigned long __ret; \
\
- sdt_might_sleep_start_timeout(NULL, t); \
+ sdt_might_sleep_start_timeout((x)->dmap, t); \
__ret = __wait_for_completion_io_timeout(x, t); \
sdt_might_sleep_end(); \
__ret; \
@@ -195,7 +199,7 @@ extern void complete_all(struct completion *);
({ \
long __ret; \
\
- sdt_might_sleep_start_timeout(NULL, t); \
+ sdt_might_sleep_start_timeout((x)->dmap, t); \
__ret = __wait_for_completion_interruptible_timeout(x, t); \
sdt_might_sleep_end(); \
__ret; \
@@ -204,7 +208,7 @@ extern void complete_all(struct completion *);
({ \
long __ret; \
\
- sdt_might_sleep_start_timeout(NULL, t); \
+ sdt_might_sleep_start_timeout((x)->dmap, t); \
__ret = __wait_for_completion_killable_timeout(x, t); \
sdt_might_sleep_end(); \
__ret; \
--
2.17.1
Powered by blists - more mailing lists