Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: dri-devel@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>
Cc: linaro-mm-sig@lists.linaro.org, intel-gfx@lists.freedesktop.org,
	Christian Koenig <christian.koenig@amd.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [RFC PATCH] dma-buf/dma-fence: Use a successful read_trylock() annotation for dma_fence_begin_signalling()
Date: Fri, 26 May 2023 13:11:28 +0200	[thread overview]
Message-ID: <be9b192a-a125-6774-bb4f-8b9fb517ce0d@linux.intel.com> (raw)
In-Reply-To: <20230428125233.228353-1-thomas.hellstrom@linux.intel.com>

Daniel,

On 4/28/23 14:52, Thomas Hellström wrote:
> Condsider the following call sequence:
>
> /* Upper layer */
> dma_fence_begin_signalling();
> lock(tainted_shared_lock);
> /* Driver callback */
> dma_fence_begin_signalling();
> ...
>
> The driver might here use a utility that is annotated as intended for the
> dma-fence signalling critical path. Now if the upper layer isn't correctly
> annotated yet for whatever reason, resulting in
>
> /* Upper layer */
> lock(tainted_shared_lock);
> /* Driver callback */
> dma_fence_begin_signalling();
>
> We will receive a false lockdep locking order violation notification from
> dma_fence_begin_signalling(). However entering a dma-fence signalling
> critical section itself doesn't block and could not cause a deadlock.
>
> So use a successful read_trylock() annotation instead for
> dma_fence_begin_signalling(). That will make sure that the locking order
> is correctly registered in the first case, and doesn't register any
> locking order in the second case.
>
> The alternative is of course to make sure that the "Upper layer" is always
> correctly annotated. But experience shows that's not easily achievable
> in all cases.
>
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

Resurrecting the discussion on this one. I can't see a situation where 
we would miss *relevant* locking
order violation warnings with this patch. Ofc if we have a scheduler 
annotation patch that would work fine as well, but the lack of 
annotation in the scheduler callbacks is really starting to hurt us.

Thanks,

Thomas



> ---
>   drivers/dma-buf/dma-fence.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index f177c56269bb..17f632768ef9 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -308,8 +308,8 @@ bool dma_fence_begin_signalling(void)
>   	if (in_atomic())
>   		return true;
>   
> -	/* ... and non-recursive readlock */
> -	lock_acquire(&dma_fence_lockdep_map, 0, 0, 1, 1, NULL, _RET_IP_);
> +	/* ... and non-recursive successful read_trylock */
> +	lock_acquire(&dma_fence_lockdep_map, 0, 1, 1, 1, NULL, _RET_IP_);
>   
>   	return false;
>   }
> @@ -340,7 +340,7 @@ void __dma_fence_might_wait(void)
>   	lock_map_acquire(&dma_fence_lockdep_map);
>   	lock_map_release(&dma_fence_lockdep_map);
>   	if (tmp)
> -		lock_acquire(&dma_fence_lockdep_map, 0, 0, 1, 1, NULL, _THIS_IP_);
> +		lock_acquire(&dma_fence_lockdep_map, 0, 1, 1, 1, NULL, _THIS_IP_);
>   }
>   #endif
>   

  parent reply	other threads:[~2023-05-26 11:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-28 12:52 [Intel-xe] [RFC PATCH] dma-buf/dma-fence: Use a successful read_trylock() annotation for dma_fence_begin_signalling() Thomas Hellström
2023-04-28 12:56 ` [Intel-xe] ✓ CI.Patch_applied: success for " Patchwork
2023-04-28 12:57 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-04-28 13:01 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-04-28 13:03 ` [Intel-xe] [RFC PATCH] " Thomas Hellström
2023-04-28 13:25 ` [Intel-xe] ○ CI.BAT: info for " Patchwork
2023-05-26 11:11 ` Thomas Hellström [this message]
2024-08-14  7:10   ` [RFC PATCH] " Daniel Vetter
2024-08-14  8:37     ` Thomas Hellström
2024-09-18 12:34       ` RESEND " Thomas Hellström
2024-09-18 13:18         ` Christian König
2024-09-20  7:46           ` Thomas Hellström
2024-09-19  9:16 ` ✓ CI.Patch_applied: success for dma-buf/dma-fence: Use a successful read_trylock() annotation for dma_fence_begin_signalling() (rev2) Patchwork
2024-09-19  9:17 ` ✓ CI.checkpatch: " Patchwork
2024-09-19  9:18 ` ✓ CI.KUnit: " Patchwork
2024-09-19  9:29 ` ✓ CI.Build: " Patchwork
2024-09-19  9:32 ` ✓ CI.Hooks: " Patchwork
2024-09-19  9:33 ` ✓ CI.checksparse: " Patchwork
2024-09-19  9:52 ` ✓ CI.BAT: " Patchwork
2024-09-19 18:35 ` ✗ CI.FULL: failure " Patchwork

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=be9b192a-a125-6774-bb4f-8b9fb517ce0d@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    /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