Commit 4616120
cgroup: add lockless fast-path checks to cgroup_file_notify()
Add lockless checks before acquiring cgroup_file_kn_lock:
1. READ_ONCE(cfile->kn) NULL check to skip torn-down files.
2. READ_ONCE(cfile->notified_at) rate-limit check to skip when
within the notification interval. If within the interval, arm
the deferred timer via timer_reduce() and confirm it is pending
before returning -- if the timer fired in between, fall through
to the lock path so the notification is not lost.
Both checks have safe error directions -- a stale read can only
cause unnecessary lock acquisition, never a missed notification.
The critical section is simplified to just taking a kernfs_get()
reference and updating notified_at.
Annotate cfile->kn and cfile->notified_at write sites with
WRITE_ONCE() to pair with the lockless readers.
Reported-by: Jakub Kicinski <[email protected]>
Signed-off-by: Shakeel Butt <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>1 parent 05070cd commit 4616120
1 file changed
Lines changed: 17 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1694 | 1694 | | |
1695 | 1695 | | |
1696 | 1696 | | |
1697 | | - | |
| 1697 | + | |
1698 | 1698 | | |
1699 | 1699 | | |
1700 | 1700 | | |
| |||
4375 | 4375 | | |
4376 | 4376 | | |
4377 | 4377 | | |
4378 | | - | |
| 4378 | + | |
4379 | 4379 | | |
4380 | 4380 | | |
4381 | 4381 | | |
| |||
4631 | 4631 | | |
4632 | 4632 | | |
4633 | 4633 | | |
4634 | | - | |
| 4634 | + | |
4635 | 4635 | | |
4636 | 4636 | | |
| 4637 | + | |
| 4638 | + | |
| 4639 | + | |
| 4640 | + | |
| 4641 | + | |
| 4642 | + | |
| 4643 | + | |
| 4644 | + | |
| 4645 | + | |
| 4646 | + | |
| 4647 | + | |
4637 | 4648 | | |
4638 | 4649 | | |
4639 | | - | |
4640 | | - | |
4641 | | - | |
4642 | | - | |
4643 | | - | |
4644 | | - | |
4645 | | - | |
4646 | | - | |
4647 | | - | |
4648 | | - | |
| 4650 | + | |
| 4651 | + | |
| 4652 | + | |
4649 | 4653 | | |
4650 | 4654 | | |
4651 | 4655 | | |
| |||
0 commit comments