On 7/6/26 08:18, Byungchul Park wrote:
> Hi Linus and folks,

Hi,

I think there was plenty of feedback from locking maintainers in the past. One
question and a comment below.

> 
> DEPT(DEPendency Tracker) is a runtime deadlock detection framework that
> sees what lockdep cannot.
> 
> I'm thrilled to share that DEPT has moved beyond theory and is now
> catching real deadlocks in the wild:
> 
>    
> https://lore.kernel.org/lkml/[email protected]/
>    
> https://lore.kernel.org/lkml/[email protected]/
>    
> https://lore.kernel.org/all/[email protected]/
> 
> I've added comprehensive documentation explaining DEPT's design and usage.
> Getting started is as simple as enabling CONFIG_DEPT and watching dmesg.
> 
> THE PROBLEM LOCKDEP CANNOT SOLVE
> --------------------------------
> 
> Lockdep has been our trusted deadlock detector for two decades, but it
> has a fundamental blind spot: it tracks lock acquisition order, not the
> actual waits and events that cause deadlocks. This means lockdep misses:
> 
>   * Deadlocks involving folio locks (not released within the context)
>   * Cross-context synchronization like wait_for_completion()/complete()
>   * DMA fence waits, RCU waits, and general waitqueue patterns
>   * Any synchronization primitive outside the classic lock/unlock model
> 
> Consider this real deadlock pattern that lockdep cannot detect:
> 
>    context X              context Y              context Z
> 
>                           mutex_lock A
>    folio_lock B
>                           folio_lock B <- DEADLOCK
>                                                  mutex_lock A <- DEADLOCK
>                                                  folio_unlock B
>                           folio_unlock B
>                           mutex_unlock A
>                                                  mutex_unlock A

But that really just boils down to folio lock being implemented as a PG_lock +
some advanced wait mechanism. And we must do that because of lack of bits in
struct page.

Willy mentioned in a previous version [1]: "I don't think it makes sense to
track lock state in the page (nor folio).  Partly because there's just so many
of them, but also because the locking rules don't really apply to individual
folios so much as they do to the mappings (or anon_vmas) that contain folios."

Given that lockdep is a debug feature, and we will at some point allocate struct
folio separately, I assume we could just squeeze a "struct lockdep_map" in there
in such debug configs and the world would not collapse.

Doing that today (one "struct lockdep_map" in each "struct page") wouldn't work
as mm_zero_struct_page() would not expect such large "struct page". But
conceptually, for a debug kernel with a special CONFIG_LOCKDEP_PAGE_LOCK, maybe
that would already be ok and we could just do that (and optimize it as we
allocate folios separately).

Not that it's ideal, but for a debug feature to at least check PG_lock, probably
an easier way to achieve it than some completely new infrastructure.

Now, Willy said "locking rules don't really apply to individual folios", I
wonder if that could just help to also let lockdep check PG_lock with less
metadata? (didn't fully wrap my head around the implications)

[1]
https://lore.kernel.org/all/[email protected]/?utm_source=chatgpt.com


It's your guiding example, that's why I mention it. You do mention other wait
cases here, I don't know anything about them, but for folios it's really just
"we used a single bit so far" AFAIKs.

[...]

> 
> Q. Why not build DEPT into lockdep?
> 
> A. Lockdep is stable, battle-tested code. I chose separation because
>    while DEPT borrows BFS and hashing ideas, the wait/event model
>    requires rebuilding from scratch. Lockdep was designed for lock
>    acquisition order — retrofitting it would risk its stability.

Why can't this just be some configurable extension to lockdep
(CONFIG_LOCKDEP_XYZ) until the feature is stable and can unconditionally be
enabled along with it?

I don't quite buy the "would risk its stability" argument. A lot of stuff we do
"risks stability", every day :)

Is there another good reason (incompatible with X, dangerous with Y, cinfusing
Z) why this really must be a separate thing?

> 
> Q. Will DEPT replace lockdep?
> 
> A. No. Lockdep validates correct lock usage — that's not going away.
>    DEPT supersedes only the dependency-checking logic when mature.

It's quite unfortunate that we'd end up with another similar-but-different
mechanism, that will just end up confusing people.


But I am not a locking maintainer. I think there was plenty of discussion in the
past, so I might just be raising points that were already discussed in the past,
but I really just read some random pieces of earlier discussions. (ideally
previous discussions would be summarized here)

Long story short: we are now in v19 and I think there was pushback in the past.
Did the opinion of locking maintainers change, or is there a way forward to
integrate this in a way that would make locking maintainers accept this?

-- 
Cheers,

David

Reply via email to