From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59526330B2D for ; Thu, 12 Feb 2026 21:58:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770933509; cv=none; b=jmZISQeaLCWIGS9JOE/JbyFYX/Thn9BFtIjY4Hfo/hwIxwx/ppZo9/Vyi9tEMiQLce6nFUU+GZLt1hccSbpdOX1rLD8tmuVgWiZn3vItxUww5juTrBHcMep2j1myvBgWquw5FhLjRmowug8HWNxhjRl80GG2m+XO7O3tEof3t3U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770933509; c=relaxed/simple; bh=rvm09WjgPTpfJFIcHNYOPR/b9d2nODdgLBbyUw3INaM=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=WZao0xa17VugmM4S4qhdh4vz96On3i45rj/ffuJJWsgyxJfx5Mi7N61bV80+FbMImpAJPCuuYc1xXCimd7eJgP6llnRtaSztqtdAC/0XJaeAog6O/hpXyZM8IE7BadqsbREbkHnLJxCLNVCGSZEXPiimYCBVLU/ENYahY2MvODI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tjmercier.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Qd4lARPX; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tjmercier.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Qd4lARPX" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2a90510a6d1so2046595ad.0 for ; Thu, 12 Feb 2026 13:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770933507; x=1771538307; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=IGPiVsRR2IN2A+m6Bv8PgAftkVsRzQaURBceo4FlM+o=; b=Qd4lARPXXYTjmgUxKfAK+erBQzcm9KfCzmheAg4Qmu7YB88cLBiZ672Ep7ecI3vCAp u+UrRA+vkUKQ9baBOEDUNFaTyjRxlc5WZf4yGjXjynjnDEZjplUbpQimWu2gNLKn8uTF 6GvmjEVO8HhFzGxdX5NiPDvfNpz6H393ucan9SQgjN4/eJcwFKvRUytpOVDfkCum1JgR JIHeVTa43hMqx5MIvIkaaHX5NAfSiBWB1lbLzB5m8eu51Ia/WxXJS4oDTE09AwB8PUqD P2fx4YQiYnCHVHPZIXRF6zO8dzVL7kfz1e9qSIBZctbqNntvd3vANUZRhgv52Cve9tIP Z4vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770933507; x=1771538307; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=IGPiVsRR2IN2A+m6Bv8PgAftkVsRzQaURBceo4FlM+o=; b=isBT1l01ZcgiB/va3qHuDZMoi+/oN5EkcF91dmg79egaqPJWn/3c4tRVzJR3LS2qNs oaLbejxqVn9+PBrUcMLGtwydGinCQtye5BiUUSY9Q62FN/SbqymOE2TIwWkQ975luqt7 F4qQxNxF0OV5rwtp8Zry3uj9BKqrQvCF12kxaou8qlegcQEU/ih9SJZNabwOYgizURfP 1DinyFZBIOvmwChqQhELvY4DS9o0bMRiWgWWYp4xEb+9o9EJHOm0aRc1Kd17UORgq5fU lcl1VEFtHX34uJtqI3j28QQLu0IfhEJxawrBXJojdsohpSO9x2UPNl2YLnIlbLzWNFb8 1Ilw== X-Forwarded-Encrypted: i=1; AJvYcCUm9Va6nqZxQwCFHyHCIRA5lyTweDOBTK3ZnW50/IfNEDYOZ2hafqWQfV5Rzci1Z8X4mBkGOhocOmLKUvc=@vger.kernel.org X-Gm-Message-State: AOJu0YxA0EimcbVqr3jBPk9e+nHMFDUe1RzWGgfpOW1tc4UdVqiwubNu sXjohp+07qYSjwU/enHCOMeKPyylH/3umKENSo3e2TFN9YrygmtLvvJCSHWZ3pG0t4MooNUUr49 AmER6mlSqlubkAV37GA== X-Received: from plbkn7.prod.google.com ([2002:a17:903:787:b0:2a7:73f7:74d6]) (user=tjmercier job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:b47:b0:2a9:327f:ac57 with SMTP id d9443c01a7336-2ab3ac3ea7dmr43993265ad.28.1770933506507; Thu, 12 Feb 2026 13:58:26 -0800 (PST) Date: Thu, 12 Feb 2026 13:58:11 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.273.g2a3d683680-goog Message-ID: <20260212215814.629709-1-tjmercier@google.com> Subject: [PATCH v2 0/3] kernfs: Add inotify IN_DELETE_SELF, IN_IGNORED support for files From: "T.J. Mercier" To: gregkh@linuxfoundation.org, tj@kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: "T.J. Mercier" Content-Type: text/plain; charset="UTF-8" This series adds support for IN_DELETE_SELF and IN_IGNORED inotify events to kernfs files. 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 refactors kernfs_elem_attr to support arbitrary event types. Patch 2 implements the logic to generate DELETE_SELF and IGNORED events on file removal. Patch 3 adds selftests to verify the new behavior. --- 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: allow passing fsnotify event types kernfs: send IN_DELETE_SELF and IN_IGNORED on file deletion selftests: memcg: Add tests IN_DELETE_SELF and IN_IGNORED on memory.events fs/kernfs/dir.c | 21 +++ fs/kernfs/file.c | 20 ++- fs/kernfs/kernfs-internal.h | 3 + include/linux/kernfs.h | 1 + .../selftests/cgroup/test_memcontrol.c | 122 ++++++++++++++++++ 5 files changed, 161 insertions(+), 6 deletions(-) base-commit: ba268514ea14b44570030e8ed2aef92a38679e85 -- 2.53.0.273.g2a3d683680-goog