From: Kent Overstreet <kent.overstreet@linux.dev>
To: Suren Baghdasaryan <surenb@google.com>
Cc: akpm@linux-foundation.org, yuzhao@google.com, 00107082@163.com,
quic_zhenhuah@quicinc.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 1/2] alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
Date: Thu, 26 Dec 2024 19:43:04 -0500 [thread overview]
Message-ID: <zvihgtiazhc7rgvikplfy342bqejfnsskv6avhqtbzwufwijsd@g7azxbtjl7ud> (raw)
In-Reply-To: <20241226211639.1357704-1-surenb@google.com>
On Thu, Dec 26, 2024 at 01:16:38PM -0800, Suren Baghdasaryan wrote:
> When memory allocation profiling is disabled there is no need to update
> current->alloc_tag and these manipulations add unnecessary overhead. Fix
> the overhead by skipping these extra updates.
I did it the other way because I was concerned about the overhead of
adding a huge number of static keys. But on further thought a static key
probably isn't any bigger than an alloc tag, no?
>
> Fixes: b951aaff5035 ("mm: enable page allocation tagging")
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> Cc: stable@vger.kernel.org
> ---
> include/linux/alloc_tag.h | 11 ++++++++---
> lib/alloc_tag.c | 2 ++
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h
> index 0bbbe537c5f9..a946e0203e6d 100644
> --- a/include/linux/alloc_tag.h
> +++ b/include/linux/alloc_tag.h
> @@ -224,9 +224,14 @@ static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes) {}
>
> #define alloc_hooks_tag(_tag, _do_alloc) \
> ({ \
> - struct alloc_tag * __maybe_unused _old = alloc_tag_save(_tag); \
> - typeof(_do_alloc) _res = _do_alloc; \
> - alloc_tag_restore(_tag, _old); \
> + typeof(_do_alloc) _res; \
> + if (mem_alloc_profiling_enabled()) { \
> + struct alloc_tag * __maybe_unused _old; \
> + _old = alloc_tag_save(_tag); \
> + _res = _do_alloc; \
> + alloc_tag_restore(_tag, _old); \
> + } else \
> + _res = _do_alloc; \
> _res; \
> })
>
> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> index 7dcebf118a3e..4c373f444eb1 100644
> --- a/lib/alloc_tag.c
> +++ b/lib/alloc_tag.c
> @@ -29,6 +29,8 @@ EXPORT_SYMBOL(_shared_alloc_tag);
>
> DEFINE_STATIC_KEY_MAYBE(CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT,
> mem_alloc_profiling_key);
> +EXPORT_SYMBOL(mem_alloc_profiling_key);
> +
> DEFINE_STATIC_KEY_FALSE(mem_profiling_compressed);
>
> struct alloc_tag_kernel_section kernel_tags = { NULL, 0 };
>
> base-commit: 431614f1580a03c1a653340c55ea76bd12a9403f
> --
> 2.47.1.613.gc27f4b7a9f-goog
>
next prev parent reply other threads:[~2024-12-27 0:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-26 21:16 Suren Baghdasaryan
2024-12-26 21:16 ` [PATCH 2/2] alloc_tag: skip pgalloc_tag_swap if " Suren Baghdasaryan
2024-12-26 23:01 ` Andrew Morton
2024-12-26 23:07 ` Suren Baghdasaryan
2024-12-27 0:23 ` Andrew Morton
2024-12-27 0:56 ` Suren Baghdasaryan
2024-12-27 7:59 ` Andrew Morton
2024-12-27 17:28 ` Suren Baghdasaryan
2024-12-27 17:32 ` Suren Baghdasaryan
2025-01-14 16:38 ` Suren Baghdasaryan
2025-01-15 1:10 ` Andrew Morton
2024-12-27 0:43 ` Kent Overstreet [this message]
2024-12-27 1:07 ` [PATCH 1/2] alloc_tag: avoid current->alloc_tag manipulations when " Suren Baghdasaryan
2024-12-27 1:09 ` Suren Baghdasaryan
2024-12-27 1:46 ` Suren Baghdasaryan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=zvihgtiazhc7rgvikplfy342bqejfnsskv6avhqtbzwufwijsd@g7azxbtjl7ud \
--to=kent.overstreet@linux.dev \
--cc=00107082@163.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=quic_zhenhuah@quicinc.com \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=yuzhao@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox