* [PATCH 1/1] fixup! fix missing vmalloc.h includes
@ 2024-04-02 18:09 Suren Baghdasaryan
2024-04-02 18:09 ` [PATCH 1/1] lib: do limited memory accounting for modules with ARCH_NEEDS_WEAK_PER_CPU Suren Baghdasaryan
0 siblings, 1 reply; 4+ messages in thread
From: Suren Baghdasaryan @ 2024-04-02 18:09 UTC (permalink / raw)
To: akpm
Cc: sfr, kent.overstreet, surenb, linux-mm, linux-kernel, kernel test robot
vmalloc.h header refactoring missed vmalloc.h inclusion required for
__vmalloc_start_set symbol. Add missing inclusion.
Fixes: 07aecea15cc8 ("fix missing vmalloc.h includes")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403290536.7f9zGl5Q-lkp@intel.com/
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
arch/x86/mm/numa_32.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/mm/numa_32.c b/arch/x86/mm/numa_32.c
index 104544359d69..e25e08ba4531 100644
--- a/arch/x86/mm/numa_32.c
+++ b/arch/x86/mm/numa_32.c
@@ -24,6 +24,7 @@
#include <linux/memblock.h>
#include <linux/init.h>
+#include <linux/vmalloc.h>
#include "numa_internal.h"
base-commit: d4cd6840d1dc25963aa10ef5e5b1d01876baebf2
--
2.44.0.478.gd926399ef9-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/1] lib: do limited memory accounting for modules with ARCH_NEEDS_WEAK_PER_CPU
2024-04-02 18:09 [PATCH 1/1] fixup! fix missing vmalloc.h includes Suren Baghdasaryan
@ 2024-04-02 18:09 ` Suren Baghdasaryan
2024-04-03 21:57 ` Andrew Morton
0 siblings, 1 reply; 4+ messages in thread
From: Suren Baghdasaryan @ 2024-04-02 18:09 UTC (permalink / raw)
To: akpm
Cc: sfr, kent.overstreet, surenb, linux-mm, linux-kernel, kernel test robot
ARCH_NEEDS_WEAK_PER_CPU does not allow percpu variable definitions inside
a function, therefore memory allocation profiling can't use it. This
definition is used only for modules, so we still can account core kernel
allocations and for modules we can do limited allocation accounting by
charging all of them to a single counter. This is not ideal but better
than no accounting at all.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403290334.USWrYrMw-lkp@intel.com/
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
include/linux/alloc_tag.h | 14 ++++++++++++--
lib/alloc_tag.c | 3 +++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h
index 100ddf66eb8e..e867461585ff 100644
--- a/include/linux/alloc_tag.h
+++ b/include/linux/alloc_tag.h
@@ -68,9 +68,17 @@ static inline struct alloc_tag *ct_to_alloc_tag(struct codetag *ct)
/*
* When percpu variables are required to be defined as weak, static percpu
* variables can't be used inside a function (see comments for DECLARE_PER_CPU_SECTION).
+ * Instead we will accound all module allocations to a single counter.
*/
-#error "Memory allocation profiling is incompatible with ARCH_NEEDS_WEAK_PER_CPU"
-#endif
+DECLARE_PER_CPU(struct alloc_tag_counters, _shared_alloc_tag);
+
+#define DEFINE_ALLOC_TAG(_alloc_tag) \
+ static struct alloc_tag _alloc_tag __used __aligned(8) \
+ __section("alloc_tags") = { \
+ .ct = CODE_TAG_INIT, \
+ .counters = &_shared_alloc_tag };
+
+#else /* ARCH_NEEDS_WEAK_PER_CPU */
#define DEFINE_ALLOC_TAG(_alloc_tag) \
static DEFINE_PER_CPU(struct alloc_tag_counters, _alloc_tag_cntr); \
@@ -79,6 +87,8 @@ static inline struct alloc_tag *ct_to_alloc_tag(struct codetag *ct)
.ct = CODE_TAG_INIT, \
.counters = &_alloc_tag_cntr };
+#endif /* ARCH_NEEDS_WEAK_PER_CPU */
+
DECLARE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,
mem_alloc_profiling_key);
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
index e24830c44783..b37e3430ed92 100644
--- a/lib/alloc_tag.c
+++ b/lib/alloc_tag.c
@@ -10,6 +10,9 @@
static struct codetag_type *alloc_tag_cttype;
+DEFINE_PER_CPU(struct alloc_tag_counters, _shared_alloc_tag);
+EXPORT_SYMBOL(_shared_alloc_tag);
+
DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,
mem_alloc_profiling_key);
base-commit: d4cd6840d1dc25963aa10ef5e5b1d01876baebf2
--
2.44.0.478.gd926399ef9-goog
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] lib: do limited memory accounting for modules with ARCH_NEEDS_WEAK_PER_CPU
2024-04-02 18:09 ` [PATCH 1/1] lib: do limited memory accounting for modules with ARCH_NEEDS_WEAK_PER_CPU Suren Baghdasaryan
@ 2024-04-03 21:57 ` Andrew Morton
2024-04-03 22:31 ` Suren Baghdasaryan
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2024-04-03 21:57 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: sfr, kent.overstreet, linux-mm, linux-kernel, kernel test robot
On Tue, 2 Apr 2024 11:09:33 -0700 Suren Baghdasaryan <surenb@google.com> wrote:
> ARCH_NEEDS_WEAK_PER_CPU does not allow percpu variable definitions inside
> a function, therefore memory allocation profiling can't use it. This
> definition is used only for modules, so we still can account core kernel
> allocations and for modules we can do limited allocation accounting by
> charging all of them to a single counter. This is not ideal but better
I'll queue this as a to-be-squashed fix against "lib: add allocation
tagging support for memory allocation profiling", OK?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] lib: do limited memory accounting for modules with ARCH_NEEDS_WEAK_PER_CPU
2024-04-03 21:57 ` Andrew Morton
@ 2024-04-03 22:31 ` Suren Baghdasaryan
0 siblings, 0 replies; 4+ messages in thread
From: Suren Baghdasaryan @ 2024-04-03 22:31 UTC (permalink / raw)
To: Andrew Morton
Cc: sfr, kent.overstreet, linux-mm, linux-kernel, kernel test robot
On Wed, Apr 3, 2024 at 2:57 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Tue, 2 Apr 2024 11:09:33 -0700 Suren Baghdasaryan <surenb@google.com> wrote:
>
> > ARCH_NEEDS_WEAK_PER_CPU does not allow percpu variable definitions inside
> > a function, therefore memory allocation profiling can't use it. This
> > definition is used only for modules, so we still can account core kernel
> > allocations and for modules we can do limited allocation accounting by
> > charging all of them to a single counter. This is not ideal but better
>
> I'll queue this as a to-be-squashed fix against "lib: add allocation
> tagging support for memory allocation profiling", OK?
Yes, that would be ideal. Thank you!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-03 22:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 18:09 [PATCH 1/1] fixup! fix missing vmalloc.h includes Suren Baghdasaryan
2024-04-02 18:09 ` [PATCH 1/1] lib: do limited memory accounting for modules with ARCH_NEEDS_WEAK_PER_CPU Suren Baghdasaryan
2024-04-03 21:57 ` Andrew Morton
2024-04-03 22:31 ` Suren Baghdasaryan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox