[v4,3/3] mm,page_owner: Filter out stacks by a threshold counter
Commit Message
We want to be able to filter out the output on a threshold basis,
in this way we can get rid of a lot of noise and focus only on those
stacks which have an allegedly high counter.
We can control the threshold value by a new file called
'page_owner_threshold', which is 0 by default.
Signed-off-by: Oscar Salvador <osalvador@suse.de>
---
include/linux/stackdepot.h | 3 +++
lib/stackdepot.c | 17 ++++++++++++++++-
mm/page_owner.c | 5 +++++
3 files changed, 24 insertions(+), 1 deletion(-)
Comments
Hi Oscar,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.3-rc7]
[cannot apply to akpm-mm/mm-everything next-20230420]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709
base: linus/master
patch link: https://lore.kernel.org/r/20230421101415.5734-4-osalvador%40suse.de
patch subject: [PATCH v4 3/3] mm,page_owner: Filter out stacks by a threshold counter
config: x86_64-randconfig-a013 (https://download.01.org/0day-ci/archive/20230422/202304220331.FdXghWlY-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/716d3f03add56cf9ed9ae5e49d73cf7e0cbfcb19
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709
git checkout 716d3f03add56cf9ed9ae5e49d73cf7e0cbfcb19
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 olddefconfig
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304220331.FdXghWlY-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/debugfs.h:15,
from mm/page_owner.c:2:
mm/page_owner.c: In function 'proc_page_owner_threshold_open':
>> mm/page_owner.c:747:52: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int' [-Wformat=]
747 | &page_owner_threshold_set, "%lu");
| ^~~~~
include/linux/fs.h:3066:36: note: in definition of macro 'DEFINE_SIMPLE_ATTRIBUTE_XSIGNED'
3066 | __simple_attr_check_format(__fmt, 0ull); \
| ^~~~~
mm/page_owner.c:746:1: note: in expansion of macro 'DEFINE_SIMPLE_ATTRIBUTE'
746 | DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get,
| ^~~~~~~~~~~~~~~~~~~~~~~
mm/page_owner.c:747:55: note: format string is defined here
747 | &page_owner_threshold_set, "%lu");
| ~~^
| |
| long unsigned int
| %llu
vim +747 mm/page_owner.c
745
746 DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get,
> 747 &page_owner_threshold_set, "%lu");
748
Hi Oscar,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.3-rc7]
[cannot apply to akpm-mm/mm-everything next-20230420]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709
base: linus/master
patch link: https://lore.kernel.org/r/20230421101415.5734-4-osalvador%40suse.de
patch subject: [PATCH v4 3/3] mm,page_owner: Filter out stacks by a threshold counter
config: x86_64-randconfig-a012 (https://download.01.org/0day-ci/archive/20230422/202304220312.gCQb3BRX-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/716d3f03add56cf9ed9ae5e49d73cf7e0cbfcb19
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Oscar-Salvador/lib-stackdepot-Add-a-refcount-field-in-stack_record/20230421-181709
git checkout 716d3f03add56cf9ed9ae5e49d73cf7e0cbfcb19
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304220312.gCQb3BRX-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> mm/page_owner.c:746:1: warning: format specifies type 'unsigned long' but the argument has type 'unsigned long long' [-Wformat]
DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/fs.h:3079:2: note: expanded from macro 'DEFINE_SIMPLE_ATTRIBUTE'
DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/fs.h:3066:36: note: expanded from macro 'DEFINE_SIMPLE_ATTRIBUTE_XSIGNED'
__simple_attr_check_format(__fmt, 0ull); \
~~~~~ ^~~~
1 warning generated.
vim +746 mm/page_owner.c
745
> 746 DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get,
747 &page_owner_threshold_set, "%lu");
748
@@ -120,6 +120,9 @@ depot_stack_handle_t stack_depot_save_action(unsigned long *entries,
void *stack_start(struct seq_file *m, loff_t *ppos);
void *stack_next(struct seq_file *m, void *v, loff_t *ppos);
int stack_print(struct seq_file *m, void *v);
+
+int page_owner_threshold_get(void *data, u64 *val);
+int page_owner_threshold_set(void *data, u64 val);
#endif
/**
@@ -502,6 +502,9 @@ static struct stack_record *stack_depot_getstack(depot_stack_handle_t handle)
}
#ifdef CONFIG_PAGE_OWNER
+
+static unsigned long page_owner_stack_threshold = 0;
+
void *stack_start(struct seq_file *m, loff_t *ppos)
{
unsigned long *table = m->private;
@@ -557,7 +560,7 @@ int stack_print(struct seq_file *m, void *v)
if (!stack->size || stack->size < 0 ||
stack->size > PAGE_SIZE || stack->handle.valid != 1 ||
- refcount_read(&stack->count) < 1)
+ refcount_read(&stack->count) < page_owner_stack_threshold)
return 0;
buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
@@ -570,6 +573,18 @@ int stack_print(struct seq_file *m, void *v)
return 0;
}
+
+int page_owner_threshold_get(void *data, u64 *val)
+{
+ *val = page_owner_stack_threshold;
+ return 0;
+}
+
+int page_owner_threshold_set(void *data, u64 val)
+{
+ page_owner_stack_threshold = val;
+ return 0;
+}
#endif
unsigned int stack_depot_fetch(depot_stack_handle_t handle,
@@ -743,6 +743,9 @@ const struct file_operations page_owner_stack_operations = {
.release = seq_release,
};
+DEFINE_SIMPLE_ATTRIBUTE(proc_page_owner_threshold, &page_owner_threshold_get,
+ &page_owner_threshold_set, "%lu");
+
static int __init pageowner_init(void)
{
if (!static_branch_unlikely(&page_owner_inited)) {
@@ -755,6 +758,8 @@ static int __init pageowner_init(void)
debugfs_create_file("page_owner_stacks", S_IRUSR, NULL, NULL,
&page_owner_stack_operations);
+ debugfs_create_file("page_owner_threshold", 0600, NULL, NULL,
+ &proc_page_owner_threshold);
return 0;
}