Re: [PATCH v6 13/37] lib: add allocation tagging support for memory allocation profiling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024-04-07 15:44, Klara Modin wrote:
On 2024-04-06 23:47, Kent Overstreet wrote:
On Fri, Apr 05, 2024 at 03:54:45PM +0200, Klara Modin wrote:
Hi,

On 2024-03-21 17:36, Suren Baghdasaryan wrote:
Introduce CONFIG_MEM_ALLOC_PROFILING which provides definitions to easily
instrument memory allocators. It registers an "alloc_tags" codetag type
with /proc/allocinfo interface to output allocation tag information when
the feature is enabled.
CONFIG_MEM_ALLOC_PROFILING_DEBUG is provided for debugging the memory
allocation profiling instrumentation.
Memory allocation profiling can be enabled or disabled at runtime using
/proc/sys/vm/mem_profiling sysctl when CONFIG_MEM_ALLOC_PROFILING_DEBUG=n.
CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT enables memory allocation
profiling by default.

Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx>
Co-developed-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>

With this commit (9e2dcefa791e9d14006b360fba3455510fd3325d in
next-20240404), randconfig with KCONFIG_SEED=0xE6264236 fails to build
with the attached error. The following patch fixes the build error for me,
but I don't know if it's correct.

Looks good - if you sound out an official patch I'll ack it.


I gave it a try and sent out a patch [1]. This is my first time doing that and it's likely not without mistakes.

1. https://lore.kernel.org/lkml/20240407133252.173636-1-klarasmodin@xxxxxxxxx/T/#u

linux/smp.h may be needed as well. I tried cross-compiling the randconfig for riscv which complains of missing raw_smp_processor_id() and including linux/smp.h resolves that.

Does this look reasonable, and if so, should I send it as well?

diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h
index afc9e259a2d3..7fe1cbdab0b0 100644
--- a/include/linux/alloc_tag.h
+++ b/include/linux/alloc_tag.h
@@ -13,6 +13,7 @@
 #include <linux/cpumask.h>
 #include <linux/static_key.h>
 #include <linux/irqflags.h>
+#include <linux/smp.h>

 struct alloc_tag_counters {
        u64 bytes;

Attachment: randconfig-riscv.gz
Description: application/gzip

In file included from ././include/linux/compiler_types.h:151,
                 from <command-line>:
./include/linux/alloc_tag.h: In function ‘__alloc_tag_ref_set’:
./include/asm-generic/percpu.h:31:40: error: implicit declaration of function ‘raw_smp_processor_id’ [-Wimplicit-function-declaration]
   31 | #define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
      |                                        ^~~~~~~~~~~~~~~~~~~~
./include/linux/compiler-gcc.h:35:33: note: in definition of macro ‘RELOC_HIDE’
   35 |         (typeof(ptr)) (__ptr + (off));                                  \
      |                                 ^~~
./include/asm-generic/percpu.h:44:31: note: in expansion of macro ‘SHIFT_PERCPU_PTR’
   44 | #define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
      |                               ^~~~~~~~~~~~~~~~
./include/asm-generic/percpu.h:31:25: note: in expansion of macro ‘per_cpu_offset’
   31 | #define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
      |                         ^~~~~~~~~~~~~~
./include/asm-generic/percpu.h:44:53: note: in expansion of macro ‘__my_cpu_offset’
   44 | #define arch_raw_cpu_ptr(ptr) SHIFT_PERCPU_PTR(ptr, __my_cpu_offset)
      |                                                     ^~~~~~~~~~~~~~~
./include/linux/percpu-defs.h:242:9: note: in expansion of macro ‘arch_raw_cpu_ptr’
  242 |         arch_raw_cpu_ptr(ptr);                                          \
      |         ^~~~~~~~~~~~~~~~
./include/asm-generic/percpu.h:72:10: note: in expansion of macro ‘raw_cpu_ptr’
   72 |         *raw_cpu_ptr(&(pcp)) op val;                                    \
      |          ^~~~~~~~~~~
./include/asm-generic/percpu.h:156:9: note: in expansion of macro ‘raw_cpu_generic_to_op’
  156 |         raw_cpu_generic_to_op(pcp, val, op);                            \
      |         ^~~~~~~~~~~~~~~~~~~~~
./include/asm-generic/percpu.h:401:41: note: in expansion of macro ‘this_cpu_generic_to_op’
  401 | #define this_cpu_add_1(pcp, val)        this_cpu_generic_to_op(pcp, val, +=)
      |                                         ^~~~~~~~~~~~~~~~~~~~~~
./include/linux/percpu-defs.h:365:25: note: in expansion of macro ‘this_cpu_add_1’
  365 |                 case 1: stem##1(variable, __VA_ARGS__);break;           \
      |                         ^~~~
./include/linux/percpu-defs.h:491:41: note: in expansion of macro ‘__pcpu_size_call’
  491 | #define this_cpu_add(pcp, val)          __pcpu_size_call(this_cpu_add_, pcp, val)
      |                                         ^~~~~~~~~~~~~~~~
./include/linux/percpu-defs.h:501:41: note: in expansion of macro ‘this_cpu_add’
  501 | #define this_cpu_inc(pcp)               this_cpu_add(pcp, 1)
      |                                         ^~~~~~~~~~~~
./include/linux/alloc_tag.h:146:9: note: in expansion of macro ‘this_cpu_inc’
  146 |         this_cpu_inc(tag->counters->calls);
      |         ^~~~~~~~~~~~
make[4]: *** [scripts/Makefile.build:244: arch/riscv/kernel/irq.o] Error 1
make[3]: *** [scripts/Makefile.build:485: arch/riscv/kernel] Error 2
make[2]: *** [scripts/Makefile.build:485: arch/riscv] Error 2
make[1]: *** [/home/klara/git/linux/Makefile:1919: .] Error 2
make: *** [Makefile:240: __sub-make] Error 2

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux