Subject: [PATCH] cgroup: include missing header for struct irq_work

From: Bert Karwatzki <[email-masked]>
Date: Tue, 11 Nov 2025 18:01:43 +0100

To compile cgroup.c with PREEMPT_RT=y include header which declares
struct irq_work.

Fixes: 9311e6c29b34 ("cgroup: Fix sleeping from invalid context warning on PREEMPT_RT")

Signed-off-by: Bert Karwatzki <[email-masked]>
---
 kernel/cgroup/cgroup.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 0cabc2081e8b..dd114fda37b2 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -60,6 +60,7 @@
 #include <linux/sched/deadline.h>
 #include <linux/psi.h>
 #include <linux/nstree.h>
+#include <linux/irq_work.h>
 #include <net/sock.h>
 
 #define CREATE_TRACE_POINTS
-- 
2.47.3

For me compiling next-20251111 with PREEMPT_RT=y failed with the following
build error:

In file included from ./include/asm-generic/percpu.h:9,
                 from ./arch/x86/include/asm/percpu.h:598,
                 from ./arch/x86/include/asm/current.h:11,
                 from ./include/linux/sched.h:12,
                 from ./include/linux/cgroup.h:12,
                 from kernel/cgroup/cgroup-internal.h:5,
                 from kernel/cgroup/cgroup.c:31:
kernel/cgroup/cgroup.c: In function ‘cgroup_rt_init’:
./include/linux/percpu-defs.h:221:59: error: invalid use of undefined type ‘struct irq_work’
  221 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
      |                                                           ^
./include/linux/percpu-defs.h:239:9: note: in expansion of macro ‘__verify_pcpu_ptr’
  239 |         __verify_pcpu_ptr(ptr);                                         \
      |         ^~~~~~~~~~~~~~~~~
./include/linux/percpu-defs.h:273:35: note: in expansion of macro ‘per_cpu_ptr’
  273 | #define per_cpu(var, cpu)       (*per_cpu_ptr(&(var), cpu))
      |                                   ^~~~~~~~~~~
kernel/cgroup/cgroup.c:7059:17: note: in expansion of macro ‘per_cpu’
 7059 |                 per_cpu(cgrp_dead_tasks_iwork, cpu) =
      |                 ^~~~~~~
  CC      net/ipv6/sysctl_net_ipv6.o
kernel/cgroup/cgroup.c:7060:25: error: implicit declaration of function ‘IRQ_WORK_INIT_LAZY’ [-Wimplicit-function-declaration]
 7060 |                         IRQ_WORK_INIT_LAZY(cgrp_dead_tasks_iwork_fn);
      |                         ^~~~~~~~~~~~~~~~~~
kernel/cgroup/cgroup.c:7059:53: error: invalid use of undefined type ‘struct irq_work’
 7059 |                 per_cpu(cgrp_dead_tasks_iwork, cpu) =
      |                                                     ^
  CC      drivers/connector/cn_queue.o
kernel/cgroup/cgroup.c: In function ‘cgroup_task_dead’:
kernel/cgroup/cgroup.c:7068:9: error: implicit declaration of function ‘irq_work_queue’; did you mean ‘drain_workqueue’? [-Wimplicit-function-declaration]
 7068 |         irq_work_queue(this_cpu_ptr(&cgrp_dead_tasks_iwork));
      |         ^~~~~~~~~~~~~~
      |         drain_workqueue
./include/linux/percpu-defs.h:221:59: error: invalid use of undefined type ‘struct irq_work’
  221 |         const void __percpu *__vpp_verify = (typeof((ptr) + 0))NULL;    \
      |                                                           ^
./include/linux/percpu-defs.h:245:9: note: in expansion of macro ‘__verify_pcpu_ptr’
  245 |         __verify_pcpu_ptr(ptr);                                         \
      |         ^~~~~~~~~~~~~~~~~
./include/linux/percpu-defs.h:256:27: note: in expansion of macro ‘raw_cpu_ptr’
  256 | #define this_cpu_ptr(ptr) raw_cpu_ptr(ptr)
      |                           ^~~~~~~~~~~
kernel/cgroup/cgroup.c:7068:24: note: in expansion of macro ‘this_cpu_ptr’
 7068 |         irq_work_queue(this_cpu_ptr(&cgrp_dead_tasks_iwork));
      |                        ^~~~~~~~~~~~
kernel/cgroup/cgroup.c: At top level:
  CC [M]  fs/nls/nls_ascii.o
kernel/cgroup/cgroup.c:7039:40: error: storage size of ‘cgrp_dead_tasks_iwork’ isn’t known
 7039 | static DEFINE_PER_CPU(struct irq_work, cgrp_dead_tasks_iwork);
      |                                        ^~~~~~~~~~~~~~~~~~~~~
./include/linux/percpu-defs.h:103:44: note: in definition of macro ‘DEFINE_PER_CPU_SECTION’
  103 |         __PCPU_ATTRS(sec) __typeof__(type) name
      |                                            ^~~~
kernel/cgroup/cgroup.c:7039:8: note: in expansion of macro ‘DEFINE_PER_CPU’
 7039 | static DEFINE_PER_CPU(struct irq_work, cgrp_dead_tasks_iwork);
      |        ^~~~~~~~~~~~~~
  CC      drivers/acpi/acpica/tbdata.o
make[7]: *** [scripts/Makefile.build:287: kernel/cgroup/cgroup.o] Fehler 1

This patch fixes the error, perhaps you can squeeze this into a v3 of
your commit.

Bert Karwatzki