public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Thomas Graf <tgraf@suug.ch>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Hao Luo <haoluo@google.com>, Josh Don <joshdon@google.com>,
	Barret Rhoden <brho@google.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rhashtable: Fix potential deadlock by moving schedule_work outside lock
Date: Tue, 3 Dec 2024 10:16:24 -1000	[thread overview]
Message-ID: <Z09nGHvk5YJABZ1d@slm.duckdns.org> (raw)
In-Reply-To: <20241128-scx_lockdep-v1-1-2315b813b36b@debian.org>

On Thu, Nov 28, 2024 at 04:16:25AM -0800, Breno Leitao wrote:
> Move the hash table growth check and work scheduling outside the
> rht lock to prevent a possible circular locking dependency.
> 
> The original implementation could trigger a lockdep warning due to
> a potential deadlock scenario involving nested locks between
> rhashtable bucket, rq lock, and dsq lock. By relocating the
> growth check and work scheduling after releasing the rth lock, we break
> this potential deadlock chain.
> 
> This change expands the flexibility of rhashtable by removing
> restrictive locking that previously limited its use in scheduler
> and workqueue contexts.
> 
> Import to say that this calls rht_grow_above_75(), which reads from
> struct rhashtable without holding the lock, if this is a problem, we can
> move the check to the lock, and schedule the workqueue after the lock.
> 
> Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
> Suggested-by: Tejun Heo <tj@kernel.org>
> Signed-off-by: Breno Leitao <leitao@debian.org>

  Acked-by: Tejun Heo <tj@kernel.org>

This solves a possible deadlock for sched_ext and makes rhashtable more
useful and I don't see any downsides.

Andrew, can you please pick up this one?

Thanks.

-- 
tejun

  parent reply	other threads:[~2024-12-03 20:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-28 12:16 [PATCH] rhashtable: Fix potential deadlock by moving schedule_work outside lock Breno Leitao
2024-11-29  5:47 ` Herbert Xu
2024-12-02 20:16   ` Breno Leitao
2024-12-03 20:16 ` Tejun Heo [this message]
2024-12-04  1:34   ` Herbert Xu
2024-12-12 12:33 ` Herbert Xu
2024-12-21  9:06   ` Herbert Xu
2025-01-02 10:15     ` Breno Leitao
2025-01-09  3:16       ` Michael Kelley
2025-01-09 10:15         ` Breno Leitao
2025-01-10  9:27           ` Herbert Xu
2025-01-10  9:49             ` Breno Leitao
2025-01-10 10:07               ` Herbert Xu
2025-01-10 14:46             ` Zaslonko Mikhail
2025-01-10 16:59             ` Michael Kelley
2025-01-10 17:24               ` [v2 PATCH] rhashtable: Fix rhashtable_try_insert test Herbert Xu
2025-01-10 18:22                 ` Michael Kelley
2025-01-14  3:15                   ` [v3 " Herbert Xu
2025-01-14 11:58                     ` Michael Kelley
2025-01-15 15:15                     ` Breno Leitao
2025-01-16  9:10                       ` Herbert Xu
2025-01-16 11:48                     ` Alexander Gordeev
2025-01-17 13:20                     ` Zaslonko Mikhail
2025-01-13 19:50 ` [PATCH] rhashtable: Fix potential deadlock by moving schedule_work outside lock Guenter Roeck
2025-01-14  3:23   ` Herbert Xu

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=Z09nGHvk5YJABZ1d@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=brho@google.com \
    --cc=haoluo@google.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=joshdon@google.com \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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