From: Suren Baghdasaryan <surenb@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, kent.overstreet@linux.dev,
yzhong@purestorage.com, Casey Chen <cachen@purestorage.com>
Subject: Re: [PATCH v5] alloc_tag: check mem_profiling_support in alloc_tag_init
Date: Tue, 13 May 2025 12:39:27 -0700 [thread overview]
Message-ID: <CAJuCfpFUtDLtuXa4jPE2rgwx+rUrrJEw690+=J33RVHsOpyotw@mail.gmail.com> (raw)
In-Reply-To: <20250513182602.121843-1-cachen@purestorage.com>
On Tue, May 13, 2025 at 11:26 AM Casey Chen <cachen@purestorage.com> wrote:
>
> If mem_profiling_support is false, for example by
> sysctl.vm.mem_profiling=never, alloc_tag_init should skip
> module tags allocation, codetag type registration and
> procfs init.
>
> Signed-off-by: Casey Chen <cachen@purestorage.com>
> Reviewed-by: Yuanyuan Zhong <yzhong@purestorage.com>
> Acked-by: Suren Baghdasaryan <surenb@google.com>
Sending to Andrew as I just noticed the patch was not sent to him initially.
I don't think we need to CC stable as IMO this is more of an
optimization than a bug fix.
> ---
> lib/alloc_tag.c | 34 +++++++++++++++++++---------------
> 1 file changed, 19 insertions(+), 15 deletions(-)
>
> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> index 25ecc1334b67..3baf19879c8e 100644
> --- a/lib/alloc_tag.c
> +++ b/lib/alloc_tag.c
> @@ -244,17 +244,6 @@ static void shutdown_mem_profiling(bool remove_file)
> mem_profiling_support = false;
> }
>
> -static void __init procfs_init(void)
> -{
> - if (!mem_profiling_support)
> - return;
> -
> - if (!proc_create_seq(ALLOCINFO_FILE_NAME, 0400, NULL, &allocinfo_seq_op)) {
> - pr_err("Failed to create %s file\n", ALLOCINFO_FILE_NAME);
> - shutdown_mem_profiling(false);
> - }
> -}
> -
> void __init alloc_tag_sec_init(void)
> {
> struct alloc_tag *last_codetag;
> @@ -762,19 +751,34 @@ static int __init alloc_tag_init(void)
> };
> int res;
>
> + sysctl_init();
> +
> + if (!mem_profiling_support) {
> + pr_info("Memory allocation profiling is not supported!\n");
> + return 0;
> + }
> +
> + if (!proc_create_seq(ALLOCINFO_FILE_NAME, 0400, NULL, &allocinfo_seq_op)) {
> + pr_err("Failed to create %s file\n", ALLOCINFO_FILE_NAME);
> + shutdown_mem_profiling(false);
> + return -ENOMEM;
> + }
> +
> res = alloc_mod_tags_mem();
> - if (res)
> + if (res) {
> + pr_err("Failed to reserve address space for module tags, errno = %d\n", res);
> + shutdown_mem_profiling(true);
> return res;
> + }
>
> alloc_tag_cttype = codetag_register_type(&desc);
> if (IS_ERR(alloc_tag_cttype)) {
> + pr_err("Allocation tags registration failed, errno = %ld\n", PTR_ERR(alloc_tag_cttype));
> free_mod_tags_mem();
> + shutdown_mem_profiling(true);
> return PTR_ERR(alloc_tag_cttype);
> }
>
> - sysctl_init();
> - procfs_init();
> -
> return 0;
> }
> module_init(alloc_tag_init);
> --
> 2.49.0
>
prev parent reply other threads:[~2025-05-13 19:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-13 18:26 Casey Chen
2025-05-13 19:39 ` Suren Baghdasaryan [this message]
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='CAJuCfpFUtDLtuXa4jPE2rgwx+rUrrJEw690+=J33RVHsOpyotw@mail.gmail.com' \
--to=surenb@google.com \
--cc=akpm@linux-foundation.org \
--cc=cachen@purestorage.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-mm@kvack.org \
--cc=yzhong@purestorage.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