mm: percpu: add codetag reference into pcpuobj_ext
To store codetag for every per-cpu allocation, a codetag reference is embedded into pcpuobj_ext when CONFIG_MEM_ALLOC_PROFILING=y. Hooks to use the newly introduced codetag are added. Link: https://lkml.kernel.org/r/20240321163705.3067592-29-surenb@google.com Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> Signed-off-by: Suren Baghdasaryan <surenb@google.com> Tested-by: Kees Cook <keescook@chromium.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Alex Gaynor <alex.gaynor@gmail.com> Cc: Alice Ryhl <aliceryhl@google.com> Cc: Andreas Hindborg <a.hindborg@samsung.com> Cc: Benno Lossin <benno.lossin@proton.me> Cc: "Björn Roy Baron" <bjorn3_gh@protonmail.com> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Christoph Lameter <cl@linux.com> Cc: Dennis Zhou <dennis@kernel.org> Cc: Gary Guo <gary@garyguo.net> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Pasha Tatashin <pasha.tatashin@soleen.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tejun Heo <tj@kernel.org> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Wedson Almeida Filho <wedsonaf@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
8f30d2660a
commit
60fa4a9e23
@ -36,9 +36,12 @@ struct pcpuobj_ext {
|
|||||||
#ifdef CONFIG_MEMCG_KMEM
|
#ifdef CONFIG_MEMCG_KMEM
|
||||||
struct obj_cgroup *cgroup;
|
struct obj_cgroup *cgroup;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_MEM_ALLOC_PROFILING
|
||||||
|
union codetag_ref tag;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_MEMCG_KMEM
|
#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MEM_ALLOC_PROFILING)
|
||||||
#define NEED_PCPUOBJ_EXT
|
#define NEED_PCPUOBJ_EXT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -86,7 +89,11 @@ struct pcpu_chunk {
|
|||||||
|
|
||||||
static inline bool need_pcpuobj_ext(void)
|
static inline bool need_pcpuobj_ext(void)
|
||||||
{
|
{
|
||||||
return !mem_cgroup_kmem_disabled();
|
if (IS_ENABLED(CONFIG_MEM_ALLOC_PROFILING))
|
||||||
|
return true;
|
||||||
|
if (!mem_cgroup_kmem_disabled())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern spinlock_t pcpu_lock;
|
extern spinlock_t pcpu_lock;
|
||||||
|
26
mm/percpu.c
26
mm/percpu.c
@ -1699,6 +1699,32 @@ static void pcpu_memcg_free_hook(struct pcpu_chunk *chunk, int off, size_t size)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_MEMCG_KMEM */
|
#endif /* CONFIG_MEMCG_KMEM */
|
||||||
|
|
||||||
|
#ifdef CONFIG_MEM_ALLOC_PROFILING
|
||||||
|
static void pcpu_alloc_tag_alloc_hook(struct pcpu_chunk *chunk, int off,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
if (mem_alloc_profiling_enabled() && likely(chunk->obj_exts)) {
|
||||||
|
alloc_tag_add(&chunk->obj_exts[off >> PCPU_MIN_ALLOC_SHIFT].tag,
|
||||||
|
current->alloc_tag, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pcpu_alloc_tag_free_hook(struct pcpu_chunk *chunk, int off, size_t size)
|
||||||
|
{
|
||||||
|
if (mem_alloc_profiling_enabled() && likely(chunk->obj_exts))
|
||||||
|
alloc_tag_sub(&chunk->obj_exts[off >> PCPU_MIN_ALLOC_SHIFT].tag, size);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void pcpu_alloc_tag_alloc_hook(struct pcpu_chunk *chunk, int off,
|
||||||
|
size_t size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pcpu_alloc_tag_free_hook(struct pcpu_chunk *chunk, int off, size_t size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pcpu_alloc - the percpu allocator
|
* pcpu_alloc - the percpu allocator
|
||||||
* @size: size of area to allocate in bytes
|
* @size: size of area to allocate in bytes
|
||||||
|
Loading…
Reference in New Issue
Block a user