alloc_tag: check mem_profiling_support in alloc_tag_init
Subsystems (2)
PATCH v2 1/1 alloc_tag: check mem_profiling_support in alloc_tag_init
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.
--- lib/alloc_tag.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
lib/alloc_tag.c +10 -8
@@ -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 ();
Signature · 1 line
2.49.0
Quoted 7 lines · Casey Chen
Allocate module tags and register codetag type only when
mem_profiling_supportis true. If it is set as false, for example by sysctl.vm.mem_profiling=never, skip them.Signed-off-by Casey Chen <[email protected]>Reviewed-by Yuanyuan Zhong <[email protected]>
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.
Quoted 36 lines
--- lib/alloc_tag.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)lib/alloc_tag.c +10
-9@@ -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
Quoted 7 lines · Suren Baghdasaryan
Quoted 5 lines · Casey Chen
Allocate module tags and register codetag type only when
mem_profiling_supportis true. If it is set as false, for example by sysctl.vm.mem_profiling=never, skip them.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Casey Chen <[email protected]>Reviewed-by Yuanyuan Zhong <[email protected]>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.
Quoted 37 lines
Quoted 37 lines
--- lib/alloc_tag.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)lib/alloc_tag.c +10
-9@@ -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