Skip to contentSkip to conversation

mm/memcg: add missed warning in mem_cgroup_lruvec

PATCH In review Alex Shi 2 participants 3 messages Nov 20, 2020 memcg

lore
Share & tools
lore

Alex Shi

author
#0 lore raw

PATCH 1/1 mm/memcg: add missed warning in mem_cgroup_lruvec

commit "(mm/memcontrol:rewrite mem_cgroup_page_lruvec())" on mm tree use mem_cgroup_lruvec to rewrite mem_cgroup_page_lruvec, but it missed a DEBUG_VM warning as following, since we always charge a page before return from allocation. Add back this warning is helpful:

	VM_WARN_ON_ONCE_PAGE(!memcg, page);
Cc Andrew Morton <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Shakeel Butt <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Yafang Shao <[email protected]>
Cc Alexander Duyck <[email protected]>
Cc Hui Su <[email protected]>
Cc Wei Yang <[email protected]>
---
 include/linux/memcontrol.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/memcontrol.h +1 -0
index 925b09ace986..7809020ef7bd 100644
@@ -618,6 +618,7 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
 		goto out;
 	}
 
+	VM_WARN_ON_ONCE_PAGE(!memcg, page);
 	if (!memcg)
 		memcg = root_mem_cgroup;
 
Signature · 1 line
2.29.GIT
author
#1 lore raw

include/linux/memcontrol.h static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg, · line 621

Quoted 9 lines · Alex Shi
include/linux/memcontrol.h +1 -0
index 925b09ace986..7809020ef7bd 100644
@@ -618,6 +618,7 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
 		goto out;
 	}
 
+	VM_WARN_ON_ONCE_PAGE(!memcg, page);

Very sorry for typo above! please use the updated patch.

From 68d69172f21f39928cf8ff204f5ff5cd62ac7776 Mon Sep 17 00:00:00 2001
From: Alex Shi <[email protected]>
Date: Fri, 20 Nov 2020 17:02:41 +0800
Subject: [PATCH] mm/memcg: add missed warning in mem_cgroup_lruvec

commit "(mm/memcontrol:rewrite mem_cgroup_page_lruvec())" on mm tree use mem_cgroup_lruvec to rewrite mem_cgroup_page_lruvec, but it missed a DEBUG_VM warning as following, since we always charge a page before return from allocation. Add back this warning is helpful:

	VM_WARN_ON_ONCE(!memcg);
Cc Andrew Morton <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Shakeel Butt <[email protected]>
Cc Roman Gushchin <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Yafang Shao <[email protected]>
Cc Alexander Duyck <[email protected]>
Cc Hui Su <[email protected]>
Cc Wei Yang <[email protected]>
---
 include/linux/memcontrol.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/memcontrol.h +1 -0
index 925b09ace986..303438822818 100644
@@ -618,6 +618,7 @@ static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
 		goto out;
 	}
 
+	VM_WARN_ON_ONCE(!memcg);
 	if (!memcg)
 		memcg = root_mem_cgroup;
 
Signature · 1 line
2.29.GIT
#2 lore raw
In reply to Alex Shi
I love your patch! Yet something to improve:

Hi Alex,

I love your patch! Yet something to improve:

[auto build test ERROR on linux/master]
[also build test ERROR on linus/master hnaz-linux-mm/master v5.10-rc4 next-20201120] [cannot apply to mmotm/master]
[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]

url:    https://github.com/0day-ci/linux/commits/Alex-Shi/mm-memcg-add-missed-warning-in-mem_cgroup_lruvec/20201120-173445
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 09162bc32c880a791c6c0668ce0745cf7958f576
config: arm64-randconfig-r024-20201120 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 3ded927cf80ac519f9f9c4664fef08787f7c537d)

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
# install arm64 cross compiling tool for clang build
# apt-get install binutils-aarch64-linux-gnu
# https://github.com/0day-ci/linux/commit/f580d4709882cff6450e1b1cab47ea1c7d7c1e79
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Alex-Shi/mm-memcg-add-missed-warning-in-mem_cgroup_lruvec/20201120-173445 git checkout f580d4709882cff6450e1b1cab47ea1c7d7c1e79
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from arch/arm64/kernel/asm-offsets.c:16:
In file included from include/linux/suspend.h:5:
In file included from include/linux/swap.h:9:
include/linux/memcontrol.h:476:2: error: implicit declaration of function 'VM_WARN_ON_ONCE_PAGE' [-Werror,-Wimplicit-function-declaration]

           VM_WARN_ON_ONCE_PAGE(!memcg, page);
           ^
>> include/linux/memcontrol.h:476:31: error: use of undeclared identifier 'page'
           VM_WARN_ON_ONCE_PAGE(!memcg, page);
                                        ^

2 errors generated.
make[2]: *** [scripts/Makefile.build:117: arch/arm64/kernel/asm-offsets.s] Error 1 make[2]: Target '__build' not remade because of errors.
make[1]: *** [Makefile:1200: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

vim +/page +476 include/linux/memcontrol.h

456
457 /**
458 * mem_cgroup_lruvec - get the lru list vector for a memcg & node
459 * @memcg: memcg of the wanted lruvec
460 *
461 * Returns the lru list vector holding pages for a given @memcg &
462 * @node combination. This can be the node lruvec, if the memory
463 * controller is disabled.
464 */
465 static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg,
466 struct pglist_data *pgdat)
467 {
468 struct mem_cgroup_per_node *mz;
469 struct lruvec *lruvec;
470
471 if (mem_cgroup_disabled()) {
472 lruvec = &pgdat->__lruvec;
473 goto out;
474 }
475

 > 476		VM_WARN_ON_ONCE_PAGE(!memcg, page);

477 if (!memcg)
478 memcg = root_mem_cgroup;
479
480 mz = mem_cgroup_nodeinfo(memcg, pgdat->node_id);
481 lruvec = &mz->lruvec;
482 out:
483 /*
484 * Since a node can be onlined after the mem_cgroup was created,
485 * we have to be prepared to initialize lruvec->pgdat here;
486 * and if offlined then reonlined, we need to reinitialize it.
487 */
488 if (unlikely(lruvec->pgdat != pgdat))
489 lruvec->pgdat = pgdat;
490 return lruvec;
491 }
492

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org