* [PATCH v2] alloc_tag: check mem_profiling_support in alloc_tag_init
@ 2025-05-08 23:47 Casey Chen
2025-05-09 16:11 ` Suren Baghdasaryan
0 siblings, 1 reply; 3+ messages in thread
From: Casey Chen @ 2025-05-08 23:47 UTC (permalink / raw)
To: linux-mm; +Cc: surenb, kent.overstreet, yzhong, Casey Chen
Allocate module tags and register codetag type only when
mem_profiling_support is true. If it is set as false,
for example by sysctl.vm.mem_profiling=never, skip them.
Signed-off-by: Casey Chen <cachen@purestorage.com>
Reviewed-by: Yuanyuan Zhong <yzhong@purestorage.com>
---
lib/alloc_tag.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
index 25ecc1334b67..fbf128072c7e 100644
--- a/lib/alloc_tag.c
+++ b/lib/alloc_tag.c
@@ -762,14 +762,16 @@ static int __init alloc_tag_init(void)
};
int res;
- res = alloc_mod_tags_mem();
- if (res)
- return res;
-
- alloc_tag_cttype = codetag_register_type(&desc);
- if (IS_ERR(alloc_tag_cttype)) {
- free_mod_tags_mem();
- return PTR_ERR(alloc_tag_cttype);
+ if (mem_profiling_support) {
+ res = alloc_mod_tags_mem();
+ if (res)
+ return res;
+
+ alloc_tag_cttype = codetag_register_type(&desc);
+ if (IS_ERR(alloc_tag_cttype)) {
+ free_mod_tags_mem();
+ return PTR_ERR(alloc_tag_cttype);
+ }
}
sysctl_init();
--
2.49.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] alloc_tag: check mem_profiling_support in alloc_tag_init
2025-05-08 23:47 [PATCH v2] alloc_tag: check mem_profiling_support in alloc_tag_init Casey Chen
@ 2025-05-09 16:11 ` Suren Baghdasaryan
2025-05-12 16:48 ` Suren Baghdasaryan
0 siblings, 1 reply; 3+ messages in thread
From: Suren Baghdasaryan @ 2025-05-09 16:11 UTC (permalink / raw)
To: Casey Chen; +Cc: linux-mm, kent.overstreet, yzhong
On Thu, May 8, 2025 at 4:47 PM Casey Chen <cachen@purestorage.com> wrote:
>
> Allocate module tags and register codetag type only when
> mem_profiling_support is true. If it is set as false,
> for example by sysctl.vm.mem_profiling=never, skip them.
>
> Signed-off-by: Casey Chen <cachen@purestorage.com>
> Reviewed-by: Yuanyuan Zhong <yzhong@purestorage.com>
Thanks! Looks good to me but let me take a closer look over the
weekend to make sure we do not break anything by skipping this
allocation.
> ---
> lib/alloc_tag.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> index 25ecc1334b67..fbf128072c7e 100644
> --- a/lib/alloc_tag.c
> +++ b/lib/alloc_tag.c
> @@ -762,14 +762,16 @@ static int __init alloc_tag_init(void)
> };
> int res;
>
> - res = alloc_mod_tags_mem();
> - if (res)
> - return res;
> -
> - alloc_tag_cttype = codetag_register_type(&desc);
> - if (IS_ERR(alloc_tag_cttype)) {
> - free_mod_tags_mem();
> - return PTR_ERR(alloc_tag_cttype);
> + if (mem_profiling_support) {
> + res = alloc_mod_tags_mem();
> + if (res)
> + return res;
> +
> + alloc_tag_cttype = codetag_register_type(&desc);
> + if (IS_ERR(alloc_tag_cttype)) {
> + free_mod_tags_mem();
> + return PTR_ERR(alloc_tag_cttype);
> + }
> }
>
> sysctl_init();
> --
> 2.49.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] alloc_tag: check mem_profiling_support in alloc_tag_init
2025-05-09 16:11 ` Suren Baghdasaryan
@ 2025-05-12 16:48 ` Suren Baghdasaryan
0 siblings, 0 replies; 3+ messages in thread
From: Suren Baghdasaryan @ 2025-05-12 16:48 UTC (permalink / raw)
To: Casey Chen; +Cc: linux-mm, kent.overstreet, yzhong
On Fri, May 9, 2025 at 4:11 PM Suren Baghdasaryan <surenb@google.com> wrote:
>
> On Thu, May 8, 2025 at 4:47 PM Casey Chen <cachen@purestorage.com> wrote:
> >
> > Allocate module tags and register codetag type only when
> > mem_profiling_support is true. If it is set as false,
> > for example by sysctl.vm.mem_profiling=never, skip them.
> >
> > Signed-off-by: Casey Chen <cachen@purestorage.com>
> > Reviewed-by: Yuanyuan Zhong <yzhong@purestorage.com>
>
> Thanks! Looks good to me but let me take a closer look over the
> weekend to make sure we do not break anything by skipping this
> allocation.
I tested the patch and it works as expected. One thing I noticed is
the extra mem_profiling_support check inside procfs_init(). Please
move procfs_init() call into the "if (mem_profiling_support)" block
you added and remove the extra mem_profiling_support check from
procfs_init(). Actually, since procfs_init() becomes just one call
after the extra check removal, I would suggest just moving the
proc_create_seq() into alloc_tag_init() directly and eliminating the
procfs_init() function completely.
>
> > ---
> > lib/alloc_tag.c | 18 ++++++++++--------
> > 1 file changed, 10 insertions(+), 8 deletions(-)
> >
> > diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> > index 25ecc1334b67..fbf128072c7e 100644
> > --- a/lib/alloc_tag.c
> > +++ b/lib/alloc_tag.c
> > @@ -762,14 +762,16 @@ static int __init alloc_tag_init(void)
> > };
> > int res;
> >
> > - res = alloc_mod_tags_mem();
> > - if (res)
> > - return res;
> > -
> > - alloc_tag_cttype = codetag_register_type(&desc);
> > - if (IS_ERR(alloc_tag_cttype)) {
> > - free_mod_tags_mem();
> > - return PTR_ERR(alloc_tag_cttype);
> > + if (mem_profiling_support) {
> > + res = alloc_mod_tags_mem();
> > + if (res)
> > + return res;
> > +
> > + alloc_tag_cttype = codetag_register_type(&desc);
> > + if (IS_ERR(alloc_tag_cttype)) {
> > + free_mod_tags_mem();
> > + return PTR_ERR(alloc_tag_cttype);
> > + }
> > }
> >
> > sysctl_init();
> > --
> > 2.49.0
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-12 16:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-08 23:47 [PATCH v2] alloc_tag: check mem_profiling_support in alloc_tag_init Casey Chen
2025-05-09 16:11 ` Suren Baghdasaryan
2025-05-12 16:48 ` Suren Baghdasaryan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox