Re: [RFC PATCH bpf-next v2 1/9] cgroup: Make operations on the cgroup root_list RCU safe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/19/23 15:08, Tejun Heo wrote:
On Thu, Oct 19, 2023 at 02:38:52PM +0800, Yafang Shao wrote:
-     BUG_ON(!res_cgroup);
+     WARN_ON_ONCE(!res_cgroup && lockdep_is_held(&cgroup_mutex));
This doesn't work. lockdep_is_held() is always true if !PROVE_LOCKING.
will use mutex_is_locked() instead.
But then, someone else can hold the lock and trigger the condition
spuriously. The kernel doesn't track who's holding the lock unless lockdep
is enabled.

It is actually possible to detect if the current process is the owner of a mutex since there is a owner field in the mutex structure. However, the owner field also contains additional information which need to be masked off before comparing with "current". If such a functionality is really needed, we will have to add a helper function mutex_is_held(), for example, to kernel/locking/mutex.c.

Cheers,
Longman





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux