Re: [PATCH v19 00/40] DEPT(DEPendency Tracker)

From: David Hildenbrand (Arm)

Date: Fri Aug 21 2026 - 03:57:30 EST



[...]

> Exactly. That's why we use classification e.g. lock class - DEPT also
> makes use of the concept.
>
> DEPT doesn't use a full map in each page but uses a minimum space for a
> timestamp in each to track when each starts to wait so as to use the
> recorded timestamp when the event occurs e.g. folio_unlock().

Thanks for that information!

>
>> 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.
>
> That's a good news for lockdep. (And even for DEPT :)

He :) Where do you currently store the additional per-page information?

>
>> 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).
>
> Sounds great.
>
>> 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.
>
> I understand what you are going to tell.
>
> However, it's worth noting that lockdep tracks dependencies basically
> based on **lock acqusition orders** in the system. To make it track
> even rwlock and general synchronization mechanism as well, lockdep has
> no choice but to get more complicated.

Well, yes, sure :)

>
> Focusing on only the dependency checking, the most parts of lockdep are
> for the tricky things, so the reusable parts are not that big.
>
>> 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)
>
> That's what DEPT did and what brought external wgen introduced in DEPT.
> I was considering the exactly same thing :)
>
> Again, lockdep that tracks lock acquisition orders can't do that.
>
>> [1]
>> https://lore.kernel.org/all/aR3WHf9QZ_dizNun@xxxxxxxxxxxxxxxxxxxx/?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.
>
> It doesn't matter whether it's implemented using bit or not. folio lock
> is quite special since it's allowed to be released other than the
> acquisition context that makes lockdep impossible to track them.

Does that really make lockdep *impossible* to track them? IOW, there is no way
to extend lockdep to support lock release in different context?

I guess there is a way, but the question is at which price (I seriously have no
idea, maybe this was already discussed and people have a pointer for me).

>
>> [...]
>>
>>>
>>> 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?
>
> Answered?

Not quite. I don't understand why this must be a completely separate machinery,
even if, conceptually, it would do more than traditional lockdep.

Is it either DEPT or LOCKDEP in current configurations? Can both run at the same
time?

>
>> I don't quite buy the "would risk its stability" argument. A lot of stuff we do
>> "risks stability", every day :)
>
> That's awsome anyway :)
>
>> Is there another good reason (incompatible with X, dangerous with Y, cinfusing
>> Z) why this really must be a separate thing?
>
> Roughly:
>
> 1. Similar or less effort is needed for the new one - retrofitting
> lockdep is not easy and big changes are required since the
> reusable parts are not that big.
>
> 2. Even though you didn't agree, retrofitting it would risk its
> stability.

Well, I don't buy the stability argument, really :)

Retrofitting effort for lockdep is an interesting point, though. Lockdep
maintainers would have to make the call here regarding direction and feasibility.

[...]

>> 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?
>
> One of locking maintainers who I met in an LPC told me that he agrees
> with the direction of DEPT and supports DEPT, not officially tho.

Hm.

>
> What he and other people are concerning w.r.t DEPT the most is, false
> positives, which is the most important issue for now.

Thanks for highlighting that. What's the main reason for false positives? Is it
something conceptual that is mostly impossible to solve, or rather just
implementation work to cover all edge cases?

>
> At the same time, I think the most important thing is to make DEPT
> useful in practice especially with folio locks involved. Actually, I'm
> planning to share DEPT's true reports periodically to LKML and work with
> people who believe DEPT can make things better.
>
> Any advices will be welcome. Thanks for your opinions.

I think we must come to some conclusion on how to proceed with DEPT. I see the
following options:

(1) Don't merge it and carry it OOT. Shame if it delivers real value.

(2) Merge it (after proper review and acks from relevant maintainers ;) ),
keeping it entirely separate from lockdep.

(3) Integrate it with lockdep on a high level, giving us a single locking
dependency checker, but mostly letting dept have a separate implementation.
Look into possible merging afterwards.

(4) Retrofit and extend lockdep to really have one mechanism.

As the saying goes, it's hard to teach old dogs new tricks, but in the end
taking care of two dogs is likely harder than only a single dog? :)

I tend to favor (4) (or 3 with possible future work to achieve 4), but I am not
a locking maintainer, so really they have to voice what to do.

I do see value in DEPT (even if the folio lock might be handled differently).

--
Cheers,

David