[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251002081247.51255-33-byungchul@sk.com>
Date: Thu, 2 Oct 2025 17:12:32 +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,
yunseong.kim@...csson.com,
ysk@...lloc.com,
yeoreum.yun@....com,
netdev@...r.kernel.org,
matthew.brost@...el.com,
her0gyugyu@...il.com,
corbet@....net,
catalin.marinas@....com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
x86@...nel.org,
hpa@...or.com,
luto@...nel.org,
sumit.semwal@...aro.org,
gustavo@...ovan.org,
christian.koenig@....com,
andi.shyti@...nel.org,
arnd@...db.de,
lorenzo.stoakes@...cle.com,
Liam.Howlett@...cle.com,
rppt@...nel.org,
surenb@...gle.com,
mcgrof@...nel.org,
petr.pavlu@...e.com,
da.gomez@...nel.org,
samitolvanen@...gle.com,
paulmck@...nel.org,
frederic@...nel.org,
neeraj.upadhyay@...nel.org,
joelagnelf@...dia.com,
josh@...htriplett.org,
urezki@...il.com,
mathieu.desnoyers@...icios.com,
jiangshanlai@...il.com,
qiang.zhang@...ux.dev,
juri.lelli@...hat.com,
vincent.guittot@...aro.org,
dietmar.eggemann@....com,
bsegall@...gle.com,
mgorman@...e.de,
vschneid@...hat.com,
chuck.lever@...cle.com,
neil@...wn.name,
okorniev@...hat.com,
Dai.Ngo@...cle.com,
tom@...pey.com,
trondmy@...nel.org,
anna@...nel.org,
kees@...nel.org,
bigeasy@...utronix.de,
clrkwllms@...nel.org,
mark.rutland@....com,
ada.coupriediaz@....com,
kristina.martsenko@....com,
wangkefeng.wang@...wei.com,
broonie@...nel.org,
kevin.brodsky@....com,
dwmw@...zon.co.uk,
shakeel.butt@...ux.dev,
ast@...nel.org,
ziy@...dia.com,
yuzhao@...gle.com,
baolin.wang@...ux.alibaba.com,
usamaarif642@...il.com,
joel.granados@...nel.org,
richard.weiyang@...il.com,
geert+renesas@...der.be,
tim.c.chen@...ux.intel.com,
linux@...blig.org,
alexander.shishkin@...ux.intel.com,
lillian@...r-ark.net,
chenhuacai@...nel.org,
francesco@...la.it,
guoweikang.kernel@...il.com,
link@...o.com,
jpoimboe@...nel.org,
masahiroy@...nel.org,
brauner@...nel.org,
thomas.weissschuh@...utronix.de,
oleg@...hat.com,
mjguzik@...il.com,
andrii@...nel.org,
wangfushuai@...du.com,
linux-doc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-media@...r.kernel.org,
linaro-mm-sig@...ts.linaro.org,
linux-i2c@...r.kernel.org,
linux-arch@...r.kernel.org,
linux-modules@...r.kernel.org,
rcu@...r.kernel.org,
linux-nfs@...r.kernel.org,
linux-rt-devel@...ts.linux.dev
Subject: [PATCH v17 32/47] dept: assign unique dept_key to each distinct dma fence caller
dma fence can be used at various points in the code and it's very hard
to distinguish dma fences between different usages. Using a single
dept_key for all the dma fences could trigger false positive reports.
Assign unique dept_key to each distinct dma fence wait to avoid false
positive reports.
Signed-off-by: Byungchul Park <byungchul@...com>
---
drivers/dma-buf/dma-fence.c | 18 ++++-----
include/linux/dma-fence.h | 74 +++++++++++++++++++++++++++++--------
2 files changed, 68 insertions(+), 24 deletions(-)
diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 0a4b519e3351..df52a7ae336a 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -481,7 +481,7 @@ int dma_fence_signal(struct dma_fence *fence)
EXPORT_SYMBOL(dma_fence_signal);
/**
- * dma_fence_wait_timeout - sleep until the fence gets signaled
+ * __dma_fence_wait_timeout - sleep until the fence gets signaled
* or until timeout elapses
* @fence: the fence to wait on
* @intr: if true, do an interruptible wait
@@ -499,7 +499,7 @@ EXPORT_SYMBOL(dma_fence_signal);
* See also dma_fence_wait() and dma_fence_wait_any_timeout().
*/
signed long
-dma_fence_wait_timeout(struct dma_fence *fence, bool intr, signed long timeout)
+__dma_fence_wait_timeout(struct dma_fence *fence, bool intr, signed long timeout)
{
signed long ret;
@@ -528,7 +528,7 @@ dma_fence_wait_timeout(struct dma_fence *fence, bool intr, signed long timeout)
}
return ret;
}
-EXPORT_SYMBOL(dma_fence_wait_timeout);
+EXPORT_SYMBOL(__dma_fence_wait_timeout);
/**
* dma_fence_release - default release function for fences
@@ -764,7 +764,7 @@ dma_fence_default_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
}
/**
- * dma_fence_default_wait - default sleep until the fence gets signaled
+ * __dma_fence_default_wait - default sleep until the fence gets signaled
* or until timeout elapses
* @fence: the fence to wait on
* @intr: if true, do an interruptible wait
@@ -776,7 +776,7 @@ dma_fence_default_wait_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
* functions taking a jiffies timeout.
*/
signed long
-dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
+__dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
{
struct default_wait_cb cb;
unsigned long flags;
@@ -825,7 +825,7 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
spin_unlock_irqrestore(fence->lock, flags);
return ret;
}
-EXPORT_SYMBOL(dma_fence_default_wait);
+EXPORT_SYMBOL(__dma_fence_default_wait);
static bool
dma_fence_test_signaled_any(struct dma_fence **fences, uint32_t count,
@@ -845,7 +845,7 @@ dma_fence_test_signaled_any(struct dma_fence **fences, uint32_t count,
}
/**
- * dma_fence_wait_any_timeout - sleep until any fence gets signaled
+ * __dma_fence_wait_any_timeout - sleep until any fence gets signaled
* or until timeout elapses
* @fences: array of fences to wait on
* @count: number of fences to wait on
@@ -865,7 +865,7 @@ dma_fence_test_signaled_any(struct dma_fence **fences, uint32_t count,
* See also dma_fence_wait() and dma_fence_wait_timeout().
*/
signed long
-dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count,
+__dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count,
bool intr, signed long timeout, uint32_t *idx)
{
struct default_wait_cb *cb;
@@ -933,7 +933,7 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, uint32_t count,
return ret;
}
-EXPORT_SYMBOL(dma_fence_wait_any_timeout);
+EXPORT_SYMBOL(__dma_fence_wait_any_timeout);
/**
* DOC: deadline hints
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index 64639e104110..1062fbb637e5 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -369,8 +369,22 @@ int dma_fence_signal_locked(struct dma_fence *fence);
int dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp);
int dma_fence_signal_timestamp_locked(struct dma_fence *fence,
ktime_t timestamp);
-signed long dma_fence_default_wait(struct dma_fence *fence,
+signed long __dma_fence_default_wait(struct dma_fence *fence,
bool intr, signed long timeout);
+
+/*
+ * Associate every caller with its own dept map.
+ */
+#define dma_fence_default_wait(f, intr, t) \
+({ \
+ signed long __ret; \
+ \
+ sdt_might_sleep_start_timeout(NULL, t); \
+ __ret = __dma_fence_default_wait(f, intr, t); \
+ sdt_might_sleep_end(); \
+ __ret; \
+})
+
int dma_fence_add_callback(struct dma_fence *fence,
struct dma_fence_cb *cb,
dma_fence_func_t func);
@@ -607,12 +621,37 @@ static inline ktime_t dma_fence_timestamp(struct dma_fence *fence)
return fence->timestamp;
}
-signed long dma_fence_wait_timeout(struct dma_fence *,
+signed long __dma_fence_wait_timeout(struct dma_fence *,
bool intr, signed long timeout);
-signed long dma_fence_wait_any_timeout(struct dma_fence **fences,
+signed long __dma_fence_wait_any_timeout(struct dma_fence **fences,
uint32_t count,
bool intr, signed long timeout,
uint32_t *idx);
+/*
+ * Associate every caller with its own dept map.
+ */
+#define dma_fence_wait_timeout(f, intr, t) \
+({ \
+ signed long __ret; \
+ \
+ sdt_might_sleep_start_timeout(NULL, t); \
+ __ret = __dma_fence_wait_timeout(f, intr, t); \
+ sdt_might_sleep_end(); \
+ __ret; \
+})
+
+/*
+ * Associate every caller with its own dept map.
+ */
+#define dma_fence_wait_any_timeout(fpp, count, intr, t, idx) \
+({ \
+ signed long __ret; \
+ \
+ sdt_might_sleep_start_timeout(NULL, t); \
+ __ret = __dma_fence_wait_any_timeout(fpp, count, intr, t, idx); \
+ sdt_might_sleep_end(); \
+ __ret; \
+})
/**
* dma_fence_wait - sleep until the fence gets signaled
@@ -628,19 +667,24 @@ signed long dma_fence_wait_any_timeout(struct dma_fence **fences,
* fence might be freed before return, resulting in undefined behavior.
*
* See also dma_fence_wait_timeout() and dma_fence_wait_any_timeout().
+ *
+ * Associate every caller with its own dept map.
*/
-static inline signed long dma_fence_wait(struct dma_fence *fence, bool intr)
-{
- signed long ret;
-
- /* Since dma_fence_wait_timeout cannot timeout with
- * MAX_SCHEDULE_TIMEOUT, only valid return values are
- * -ERESTARTSYS and MAX_SCHEDULE_TIMEOUT.
- */
- ret = dma_fence_wait_timeout(fence, intr, MAX_SCHEDULE_TIMEOUT);
-
- return ret < 0 ? ret : 0;
-}
+#define dma_fence_wait(f, intr) \
+({ \
+ signed long __ret; \
+ \
+ sdt_might_sleep_start_timeout(NULL, MAX_SCHEDULE_TIMEOUT); \
+ __ret = __dma_fence_wait_timeout(f, intr, MAX_SCHEDULE_TIMEOUT);\
+ sdt_might_sleep_end(); \
+ \
+ /* \
+ * Since dma_fence_wait_timeout cannot timeout with \
+ * MAX_SCHEDULE_TIMEOUT, only valid return values are \
+ * -ERESTARTSYS and MAX_SCHEDULE_TIMEOUT. \
+ */ \
+ __ret < 0 ? __ret : 0; \
+})
void dma_fence_set_deadline(struct dma_fence *fence, ktime_t deadline);
--
2.17.1
Powered by blists - more mailing lists