Re: [PATCH v2 4/4] mm/slub: Fix sysfs shrink circular locking dependency

From: Waiman Long
Date: Tue Apr 28 2020 - 10:07:06 EST


On 4/27/20 10:11 PM, Qian Cai wrote:

On Apr 27, 2020, at 9:39 PM, Waiman Long <longman@xxxxxxxxxx> wrote:

The sequence that was prevented by this patch is "kn->count --> mem_hotplug_lock.rwsem". This sequence isn't directly in the splat. Once this link is broken, the 3-lock circular loop cannot be formed. Maybe I should modify the commit log to make this point more clear.
I donât know what you are talking about. Once trylock succeed once, you will have kn->count â> cpu/memory_hotplug_lock.

Trylock is handled differently from lockdep's perspective as trylock can failed. When trylock succeeds, the critical section is executed. As long as it doesn't try to acquire another lock in the circular chain, the execution will finish at some point and release the lock. On the other hand, if another task has already held all those locks, the trylock will fail and held locks should be released. Again, no deadlock will happen.

Regards,
Longman