cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v2 bpf-next 0/3] bpf: cgroup: support writing and freezing cgroups from BPF
@ 2025-08-18  9:04 Djalal Harouni
  2025-08-18  9:04 ` [RFC PATCH v2 bpf-next 1/3] kernfs: cgroup: support writing cgroup interfaces from a kernfs node Djalal Harouni
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Djalal Harouni @ 2025-08-18  9:04 UTC (permalink / raw)
  To: tj, hannes, mkoutny, ast, daniel, andrii, martin.lau, eddyz87,
	song, yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa,
	mykolal, shuah, cgroups, bpf, linux-kselftest, tixxdz
  Cc: Djalal Harouni

This patch series add support to write cgroup interfaces from BPF.

It is useful to freeze a cgroup hierarchy on suspicious activity for
a more thorough analysis before killing it. Planned users of this
feature are: systemd and BPF tools where the cgroup hierarchy could
be a system service, user session, k8s pod or a container.

The writing happens via kernfs nodes and the cgroup must be on the
default hierarchy. It implements the requests and feedback from v1 [1]
where now we use a unified path for cgroup user space and BPF writing.

So I want to validate that this is the right approach first.

Todo:
* Limit size of data to be written.
* Further tests.
* Add cgroup kill support.


# RFC v1 -> v2

* Implemented Alexei and Tejun requests [1].
* Unified path where user space or BPF writing end up taking directly
  a kernfs_node with an example on the "cgroup.freeze" interface.

[1] https://lore.kernel.org/bpf/20240327225334.58474-1-tixxdz@gmail.com/


Djalal Harouni (3):
      kernfs: cgroup: support writing cgroup interfaces from a kernfs node
      bpf: cgroup: Add BPF Kfunc to write cgroup interfaces
      selftests/bpf: add selftest for bpf_cgroup_write_interface

 include/linux/cgroup.h                                      |   3 ++
 kernel/bpf/helpers.c                                        |  45 +++++
 kernel/cgroup/cgroup.c                                      | 102 +++++++
 tools/testing/selftests/bpf/prog_tests/task_freeze_cgroup.c | 172 ++++++++++++
 tools/testing/selftests/bpf/progs/test_task_freeze_cgroup.c | 155 ++++++++++
 5 files changed, 471 insertions(+), 6 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/task_freeze_cgroup.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_task_freeze_cgroup.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-09-01 19:53 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18  9:04 [RFC PATCH v2 bpf-next 0/3] bpf: cgroup: support writing and freezing cgroups from BPF Djalal Harouni
2025-08-18  9:04 ` [RFC PATCH v2 bpf-next 1/3] kernfs: cgroup: support writing cgroup interfaces from a kernfs node Djalal Harouni
2025-08-18  9:04 ` [RFC PATCH v2 bpf-next 2/3] bpf: cgroup: Add BPF Kfunc to write and freeze a cgroup Djalal Harouni
2025-08-18  9:04 ` [RFC PATCH v2 bpf-next 3/3] selftests/bpf: add selftest for bpf_cgroup_write_interface Djalal Harouni
2025-08-18 17:32 ` [RFC PATCH v2 bpf-next 0/3] bpf: cgroup: support writing and freezing cgroups from BPF Tejun Heo
2025-08-19 23:31   ` Djalal Harouni
2025-08-19 23:36     ` Djalal Harouni
2025-08-20  1:14     ` Tejun Heo
2025-08-22 18:16       ` Djalal Harouni
2025-08-25 18:48         ` Tejun Heo
2025-08-26  3:45           ` Alexei Starovoitov
2025-08-26 10:23           ` Djalal Harouni
2025-08-26 14:18 ` Michal Koutný
2025-08-26 23:27   ` Djalal Harouni
2025-08-28 14:38     ` Michal Koutný
2025-09-01 19:53       ` Djalal Harouni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).