mm/memprofiling: explicitly include irqflags.h in alloc_tag.h
PATCH 1/1 mm/memprofiling: explicitly include irqflags.h in alloc_tag.h
linux/alloc_tag.h uses the macro this_cpu_inc which eventually expands to:
#define this_cpu_generic_to_op(pcp, val, op) \
do { \
unsigned long __flags; \
raw_local_irq_save(__flags); \
raw_cpu_generic_to_op(pcp, val, op); \
raw_local_irq_restore(__flags); \
} while (0)
The macros raw_local_irq_save and raw_local_irq_restore are defined in linux/irqflags.h which is not included implicitly on all configs. Therefore, include it explicitly.
--- include/linux/alloc_tag.h | 1 + 1 file changed, 1 insertion(+)
include/linux/alloc_tag.h +1 -0
@@ -12,6 +12,7 @@#include <asm/percpu.h> #include <linux/cpumask.h> #include <linux/static_key.h> +#include <linux/irqflags.h> struct alloc_tag_counters {u64 bytes;
base-commit: f43b3aae94511d62174c3b29239da0dd22d0eeb3
Signature · 1 line
2.44.0
Quoted 26 lines · Klara Modin
linux/alloc_tag.huses the macrothis_cpu_incwhich eventually expands to:#define
this_cpu_generic_to_op(pcp, val, op)\
do { \(quoted diff) +0
-0unsigned long __flags; \ raw_local_irq_save(__flags); \ raw_cpu_generic_to_op(pcp, val, op); \ raw_local_irq_restore(__flags); \ } while (0)The macros
raw_local_irq_saveandraw_local_irq_restoreare defined inlinux/irqflags.hwhich is not included implicitly on all configs. Therefore, include it explicitly.Fixes ac906a377c67 ("lib: add allocation tagging support for memory allocation profiling")Signed-off-by Klara Modin <[email protected]>--- include/linux/alloc_tag.h | 1 + 1 file changed, 1 insertion(+)include/linux/alloc_tag.h +0
-0
include/linux/alloc_tag.h line 15
Quoted 4 lines
include/linux/alloc_tag.h +1
-0@@ -12,6 +12,7 @@#include <asm/percpu.h> #include <linux/cpumask.h> #include <linux/static_key.h> +#include <linux/irqflags.h>
Actually, shouldn't this end up in a percpu header? Or was there a problem with that?
Quoted 22 lines · Kent Overstreet
Quoted 21 lines · Klara Modin
linux/alloc_tag.huses the macrothis_cpu_incwhich eventually expands to:#define this_cpu_generic_to_op(pcp, val, op) \ do { \ unsigned long __flags; \ raw_local_irq_save(__flags); \ raw_cpu_generic_to_op(pcp, val, op); \ raw_local_irq_restore(__flags); \ } while (0)The macros
raw_local_irq_saveandraw_local_irq_restoreare defined inlinux/irqflags.hwhich is not included implicitly on all configs. Therefore, include it explicitly.Fixes ac906a377c67 ("lib: add allocation tagging support for memory allocation profiling")Signed-off-by Klara Modin <[email protected]>--- include/linux/alloc_tag.h | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
include/linux/alloc_tag.h line 15
Quoted 9 lines
include/linux/alloc_tag.h +1
-0@@ -12,6 +12,7 @@#include <asm/percpu.h> #include <linux/cpumask.h> #include <linux/static_key.h> +#include <linux/irqflags.h> Actually, shouldn't this end up in a percpu header? Or was there a problem with that?
If I understand it correctly, linux/alloc_tag.h does not include linux/percpu.h (which has that include) to avoid a circular dependency as linux/percpu.h includes linux/alloc_tag.h. It instead includes arch-specific asm/percpu.h, and as a consequence it doesn't always get linux/irqflags.h.
It's also entirely possible that I've mixed something up, I really don't have much experience developing for the kernel.
Kent Overstreet
Acked-byQuoted 38 lines · Klara Modin
Quoted 22 lines · Kent Overstreet
Quoted 21 lines · Klara Modin
linux/alloc_tag.huses the macrothis_cpu_incwhich eventually expands to:#define this_cpu_generic_to_op(pcp, val, op) \ do { \ unsigned long __flags; \ raw_local_irq_save(__flags); \ raw_cpu_generic_to_op(pcp, val, op); \ raw_local_irq_restore(__flags); \ } while (0)The macros
raw_local_irq_saveandraw_local_irq_restoreare defined inlinux/irqflags.hwhich is not included implicitly on all configs. Therefore, include it explicitly.Fixes ac906a377c67 ("lib: add allocation tagging support for memory allocation profiling")Signed-off-by Klara Modin <[email protected]>--- include/linux/alloc_tag.h | 1 + 1 file changed, 1 insertion(+)Quoted 12 lines
include/linux/alloc_tag.h line 15
Quoted 9 lines
include/linux/alloc_tag.h +1
-0@@ -12,6 +12,7 @@#include <asm/percpu.h> #include <linux/cpumask.h> #include <linux/static_key.h> +#include <linux/irqflags.h> Actually, shouldn't this end up in a percpu header? Or was there a problem with that?
Quoted 7 lines
If I understand it correctly,
linux/alloc_tag.hdoes not includelinux/percpu.h(which has that include) to avoid a circular dependency aslinux/percpu.hincludeslinux/alloc_tag.h. It instead includes arch-specificasm/percpu.h, and as a consequence it doesn't always getlinux/irqflags.h.It's also entirely possible that I've mixed something up, I really don't have much experience developing for the kernel.
Gotcha