From: "T.J. Mercier" <tjmercier@google.com>
To: gregkh@linuxfoundation.org, tj@kernel.org,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org,
jack@suse.cz, amir73il@gmail.com, shuah@kernel.org,
linux-kselftest@vger.kernel.org
Cc: "T.J. Mercier" <tjmercier@google.com>
Subject: [PATCH v4 0/3] kernfs: Add inotify IN_DELETE_SELF, IN_IGNORED support
Date: Thu, 19 Feb 2026 21:54:45 -0800 [thread overview]
Message-ID: <20260220055449.3073-1-tjmercier@google.com> (raw)
This series adds support for IN_DELETE_SELF and IN_IGNORED inotify
events to kernfs files and directories.
Currently, kernfs (used by cgroup and others) supports IN_MODIFY events
but fails to notify watchers when the file is removed (e.g. during
cgroup destruction). This forces userspace monitors to maintain resource
intensive side-channels like pidfds, procfs polling, or redundant
directory watches to detect when a cgroup dies and a watched file is
removed.
By generating IN_DELETE_SELF events on destruction, we allow watchers to
rely on a single watch descriptor for the entire lifecycle of the
monitored file, reducing resource usage (file descriptors, CPU cycles)
and complexity in userspace.
The series is structured as follows:
Patch 1 preemptively addresses a race to set/clear i_nlink that would
arise in patch 2.
Patch 2 implements the logic to generate DELETE_SELF and IGNORED events
on file / dir removal.
Patch 3 adds selftests to verify the new behavior.
---
Changes in v4:
Clear inode i_nlink upon kernfs removal instead of calling fsnotify
from kernfs per Jan. This adds support for directories.
Abandon support for files removed from vfs_writes.
Add selftest for directory watch per Amir.
Add Amir's Ack to selftests.
Changes in v3:
Remove parent IN_DELETE notification per Amir.
Refactored kernfs_notify_workfn to avoid grabbing parent when
unnecessary for DELETE events as a result.
Use notify_event for fsnotify_inode call per Amir
Initialize memcg pointers to NULL in selftests
Add Amir's Ack
Add Tejun's Acks to the series
Changes in v2:
Remove unused variables from new selftests per kernel test robot
Fix kernfs_type argument per Tejun
Inline checks for FS_MODIFY, FS_DELETE in kernfs_notify_workfn per Tejun
T.J. Mercier (3):
kernfs: Don't set_nlink for directories being removed
kernfs: Send IN_DELETE_SELF and IN_IGNORED
selftests: memcg: Add tests for IN_DELETE_SELF and IN_IGNORED
fs/kernfs/dir.c | 32 ++++-
fs/kernfs/inode.c | 2 +-
.../selftests/cgroup/test_memcontrol.c | 112 ++++++++++++++++++
3 files changed, 144 insertions(+), 2 deletions(-)
base-commit: ba268514ea14b44570030e8ed2aef92a38679e85
--
2.53.0.414.gf7e9f6c205-goog
next reply other threads:[~2026-02-20 5:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 5:54 T.J. Mercier [this message]
2026-02-20 5:54 ` [PATCH v4 1/3] kernfs: Don't set_nlink for directories being removed T.J. Mercier
2026-02-20 5:54 ` [PATCH v4 2/3] kernfs: Send IN_DELETE_SELF and IN_IGNORED T.J. Mercier
2026-02-20 15:32 ` Tejun Heo
2026-02-20 17:15 ` Amir Goldstein
2026-02-20 19:50 ` Tejun Heo
2026-02-20 20:11 ` Amir Goldstein
2026-02-20 23:32 ` Tejun Heo
2026-02-21 16:11 ` Amir Goldstein
2026-02-23 16:27 ` Tejun Heo
2026-02-24 11:03 ` Christian Brauner
2026-03-03 14:27 ` Amir Goldstein
2026-03-04 13:26 ` Christian Brauner
2026-02-20 5:54 ` [PATCH v4 3/3] selftests: memcg: Add tests for " T.J. Mercier
2026-02-20 17:43 ` Amir Goldstein
2026-02-20 17:46 ` T.J. Mercier
2026-02-20 17:53 ` T.J. Mercier
2026-02-20 18:01 ` Amir Goldstein
2026-02-20 10:14 ` [syzbot ci] Re: kernfs: Add inotify IN_DELETE_SELF, IN_IGNORED support syzbot ci
2026-02-20 18:41 ` T.J. Mercier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260220055449.3073-1-tjmercier@google.com \
--to=tjmercier@google.com \
--cc=amir73il@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox