mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yunseong Kim <ysk@kzalloc.com>
To: linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	"kernel_team @ skhynix . com" <kernel_team@skhynix.com>
Cc: "Nathan Chancellor" <nathan@kernel.org>,
	"Christian König" <christian.koenig@amd.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Mikhail Gavrilov" <mikhail.v.gavrilov@gmail.com>,
	"Dave Airlie" <airlied@redhat.com>,
	"Marco Elver" <elver@google.com>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Yeoreum Yun" <yeoreum.yun@arm.com>,
	"Yeoreum Yun" <ppbuk5246@gmail.com>,
	"Byungchul Park" <byungchul@sk.com>,
	"Byungchul Park" <max.byungchul.park@gmail.com>
Subject: Re: [PATCH v19 28/40] dept: assign unique dept_key to each distinct dma fence caller
Date: Tue, 25 Aug 2026 14:33:14 +0200	[thread overview]
Message-ID: <61f8b60e-3477-465c-b6e9-c5a76de210f3@kzalloc.com> (raw)
In-Reply-To: <20260706061928.66713-29-byungchul@sk.com>

Hi Nathan,

After reading your thoughtful comments, I tested the Clang build issue
related to "indirect goto" on a v7.2 kernel with DEPT enabled:

 $ clang -v
 Debian clang version 21.1.8 (10)

 $ vng --arch arm64 --build LLVM=1 --configitem CONFIG_DEPT=y \
       --configitem CONFIG_DRM_XE=m --configitem CONFIG_ARCH_QCOM=y \
       --configitem CONFIG_DRM_MSM=m

Tested branch is here: https://github.com/yskzalloc/linux-dept/tree/dept19_v7.2

Since the update to the dma_fence_wait() usage in the 7.2 rc, Clang has no
longer reported the "indirect goto" issue.

Link: https://github.com/llvm/llvm-project/issues/138272#issuecomment-5404767476
Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4e28aa8f7ee26d67a4addee6e3980f1cbf861b49
Tested-by: Yunseong Kim <yunseong.kim@est.tech>

On 06/07/2026 8:19 am, Byungchul Park wrote:
> 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@sk.com>
> ---
>  drivers/dma-buf/dma-fence.c | 18 ++++-----
>  include/linux/dma-fence.h   | 74 +++++++++++++++++++++++++++++--------
>  2 files changed, 68 insertions(+), 24 deletions(-)
> 
[snip...]
> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
> index d4c92fd35092..3732849a30b7 100644
> --- a/include/linux/dma-fence.h
> +++ b/include/linux/dma-fence.h
> @@ -370,8 +370,22 @@ bool dma_fence_check_and_signal_locked(struct dma_fence *fence);
>  void dma_fence_signal_locked(struct dma_fence *fence);
>  void dma_fence_signal_timestamp(struct dma_fence *fence, ktime_t timestamp);
>  void 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);
> @@ -628,12 +642,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
> @@ -649,19 +688,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;						\
> +})

Thank you all! :)

Best regards,
Yunseong

  parent reply	other threads:[~2026-08-25 12:33 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06  6:18 [PATCH v19 00/40] DEPT(DEPendency Tracker) Byungchul Park
2026-07-06  6:18 ` [PATCH v19 01/40] dept: implement " Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:18 ` [PATCH v19 02/40] dept: add single event dependency tracker APIs Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:18 ` [PATCH v19 03/40] dept: add lock " Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:18 ` [PATCH v19 04/40] dept: tie to lockdep and IRQ tracing Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-10  6:54     ` Byungchul Park
2026-07-06  6:18 ` [PATCH v19 05/40] dept: add proc knobs to show stats and dependency graph Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:18 ` [PATCH v19 06/40] dept: distinguish each kernel context from another Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:18 ` [PATCH v19 07/40] dept: distinguish each work " Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-10  6:40     ` Byungchul Park
2026-07-06  6:18 ` [PATCH v19 08/40] dept: add a mechanism to refill the internal memory pools on running out Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:18 ` [PATCH v19 09/40] dept: record the latest one out of consecutive waits of the same class Byungchul Park
2026-07-06  6:18 ` [PATCH v19 10/40] dept: apply sdt_might_sleep_{start,end}() to wait_for_completion()/complete() Byungchul Park
2026-07-07  7:33   ` [PATCH v19 10/40] dept: apply sdt_might_sleep_{start, end}() " sashiko-bot
2026-07-06  6:18 ` [PATCH v19 11/40] dept: apply sdt_might_sleep_{start,end}() to swait Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 12/40] dept: apply sdt_might_sleep_{start,end}() to waitqueue wait Byungchul Park
2026-07-07  7:33   ` [PATCH v19 12/40] dept: apply sdt_might_sleep_{start, end}() " sashiko-bot
2026-07-06  6:19 ` [PATCH v19 13/40] dept: apply sdt_might_sleep_{start,end}() to hashed-waitqueue wait Byungchul Park
2026-07-07  7:33   ` [PATCH v19 13/40] dept: apply sdt_might_sleep_{start, end}() " sashiko-bot
2026-07-10  6:42     ` Byungchul Park
2026-07-06  6:19 ` [PATCH v19 14/40] dept: apply sdt_might_sleep_{start,end}() to dma fence Byungchul Park
2026-07-06  6:19 ` [PATCH v19 15/40] dept: track timeout waits separately with a new Kconfig Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 16/40] dept: apply timeout consideration to wait_for_completion()/complete() Byungchul Park
2026-07-06  6:19 ` [PATCH v19 17/40] dept: apply timeout consideration to swait Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 18/40] dept: apply timeout consideration to waitqueue wait Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 19/40] dept: apply timeout consideration to hashed-waitqueue wait Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-10  6:41     ` Byungchul Park
2026-07-06  6:19 ` [PATCH v19 20/40] dept: apply timeout consideration to dma fence wait Byungchul Park
2026-07-06  6:19 ` [PATCH v19 21/40] dept: make dept able to work with an external wgen Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 22/40] dept: track PG_locked with dept Byungchul Park
2026-07-06 18:05   ` Matthew Wilcox
2026-07-07  2:35     ` Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 23/40] dept: print staged wait's stacktrace on report Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 24/40] locking/lockdep: prevent various lockdep assertions when lockdep_off()'ed Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 25/40] dept: add documents for dept Byungchul Park
2026-07-06  6:19 ` [PATCH v19 26/40] cpu/hotplug: use a weaker annotation in AP thread Byungchul Park
2026-07-06  6:19 ` [PATCH v19 27/40] dept: assign dept map to mmu notifier invalidation synchronization Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 28/40] dept: assign unique dept_key to each distinct dma fence caller Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-10  6:24     ` Byungchul Park
2026-08-25 12:33   ` Yunseong Kim [this message]
2026-07-06  6:19 ` [PATCH v19 29/40] dept: make dept aware of lockdep_set_lock_cmp_fn() annotation Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-10  6:04     ` Byungchul Park
2026-07-06  6:19 ` [PATCH v19 30/40] dept: make dept stop from working on debug_locks_off() Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 31/40] dept: assign unique dept_key to each distinct wait_for_completion() caller Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-07 14:18   ` Gary Guo
2026-07-10  5:53     ` Byungchul Park
2026-07-06  6:19 ` [PATCH v19 32/40] completion, dept: introduce init_completion_dmap() API Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-10  6:12     ` Byungchul Park
2026-07-06  6:19 ` [PATCH v19 33/40] dept: call dept_hardirqs_off() in local_irq_*() regardless of irq state Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 34/40] rcu/update: fix same dept key collision between various types of RCU Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-10  6:20     ` Byungchul Park
2026-07-06  6:19 ` [PATCH v19 35/40] dept: introduce APIs to set page usage and use subclasses_evt for the usage Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 36/40] dept: track PG_writeback with dept Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-06  6:19 ` [PATCH v19 37/40] SUNRPC: relocate struct rcu_head to the first field of struct rpc_xprt Byungchul Park
2026-07-06  6:19 ` [PATCH v19 38/40] mm: percpu: increase PERCPU_DYNAMIC_SIZE_SHIFT on DEPT and large PAGE_SIZE Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-07-10  5:55     ` Byungchul Park
2026-07-06  6:19 ` [PATCH v19 39/40] rust: completion: Add __rust_helper to rust_helper_wait_for_completion() Byungchul Park
2026-07-11 12:13   ` Miguel Ojeda
2026-07-13  3:36     ` Byungchul Park
2026-07-06  6:19 ` [PATCH v19 40/40] dept: implement a basic unit test for dept Byungchul Park
2026-07-07  7:33   ` sashiko-bot
2026-08-20 17:16 ` [PATCH v19 00/40] DEPT(DEPendency Tracker) David Hildenbrand (Arm)
2026-08-20 17:51   ` Matthew Wilcox
2026-08-21  4:51     ` Byungchul Park
2026-08-21  7:37     ` David Hildenbrand (Arm)
2026-08-21  4:21   ` Byungchul Park
2026-08-21  7:56     ` David Hildenbrand (Arm)
2026-08-21  9:48       ` NeilBrown
2026-08-24 14:12         ` David Hildenbrand (Arm)
2026-08-24 23:37           ` NeilBrown
2026-08-25  2:40             ` Matthew Wilcox
2026-08-25  3:41               ` NeilBrown
2026-08-25 10:12               ` David Hildenbrand (Arm)
2026-08-25 10:15             ` David Hildenbrand (Arm)
2026-08-25 13:08         ` Byungchul Park
2026-08-25 12:13       ` Byungchul Park
2026-08-25 13:10         ` David Hildenbrand (Arm)
2026-08-25 13:19           ` Byungchul Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61f8b60e-3477-465c-b6e9-c5a76de210f3@kzalloc.com \
    --to=ysk@kzalloc.com \
    --cc=airlied@redhat.com \
    --cc=byungchul@sk.com \
    --cc=christian.koenig@amd.com \
    --cc=elver@google.com \
    --cc=kernel_team@skhynix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=max.byungchul.park@gmail.com \
    --cc=mikhail.v.gavrilov@gmail.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=ppbuk5246@gmail.com \
    --cc=yeoreum.yun@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®