From: Qi Zheng <zhengqi.arch@bytedance.com>
The nr_pages parameter of mem_cgroup_update_lru_size() should clearly
be long instead of int, let's correct it.
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
---
include/linux/memcontrol.h | 2 +-
mm/memcontrol.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 0861589695298..dc3fa687759b4 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -878,7 +878,7 @@ static inline bool mem_cgroup_online(struct mem_cgroup *memcg)
}
void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
- int zid, int nr_pages);
+ int zid, long nr_pages);
static inline
unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec,
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 4a78550f6174e..6491ca74b3398 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1466,7 +1466,7 @@ struct lruvec *folio_lruvec_lock_irqsave(struct folio *folio,
* to or just after a page is removed from an lru list.
*/
void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
- int zid, int nr_pages)
+ int zid, long nr_pages)
{
struct mem_cgroup_per_node *mz;
unsigned long *lru_size;
--
2.20.1
Hi Qi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on next-20260325]
[cannot apply to trace/for-next linus/master v7.0-rc5]
[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/Qi-Zheng/mm-memcontrol-correct-the-type-of-stats_updates-to-unsigned-long/20260325-230337
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/2cf06f9faf51900ce6acbb4740fc60355a2842ed.1774342371.git.zhengqi.arch%40bytedance.com
patch subject: [PATCH 3/3] mm: memcontrol: correct the nr_pages parameter type of mem_cgroup_update_lru_size()
config: riscv-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20260326/202603260338.GfCrsaVO-lkp@intel.com/config)
compiler: riscv64-linux-gnu-gcc (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260326/202603260338.GfCrsaVO-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603260338.GfCrsaVO-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from ./arch/riscv/include/asm/bug.h:90,
from ./include/linux/bug.h:5,
from ./arch/riscv/include/asm/cmpxchg.h:9,
from ./arch/riscv/include/asm/barrier.h:14,
from ./include/linux/list.h:11,
from ./include/linux/cgroup-defs.h:12,
from mm/memcontrol.c:28:
mm/memcontrol.c: In function 'mem_cgroup_update_lru_size':
>> mm/memcontrol.c:1486:17: warning: format '%d' expects argument of type 'int', but argument 5 has type 'long int' [-Wformat=]
1486 | "%s(%p, %d, %d): lru_size %ld\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1487 | __func__, lruvec, lru, nr_pages, size)) {
| ~~~~~~~~
| |
| long int
./include/asm-generic/bug.h:133:31: note: in definition of macro '__WARN_printf'
133 | __warn_printk(arg); \
| ^~~
./include/linux/once_lite.h:31:25: note: in expansion of macro 'WARN'
31 | func(__VA_ARGS__); \
| ^~~~
./include/asm-generic/bug.h:185:9: note: in expansion of macro 'DO_ONCE_LITE_IF'
185 | DO_ONCE_LITE_IF(condition, WARN, 1, format)
| ^~~~~~~~~~~~~~~
mm/memcontrol.c:1485:13: note: in expansion of macro 'WARN_ONCE'
1485 | if (WARN_ONCE(size < 0,
| ^~~~~~~~~
mm/memcontrol.c:1486:30: note: format string is defined here
1486 | "%s(%p, %d, %d): lru_size %ld\n",
| ~^
| |
| int
| %ld
vim +1486 mm/memcontrol.c
6168d0da2b479ce Alex Shi 2020-12-15 1457
925b7673cce3911 Johannes Weiner 2012-01-12 1458 /**
fa9add641b1b1c5 Hugh Dickins 2012-05-29 1459 * mem_cgroup_update_lru_size - account for adding or removing an lru page
fa9add641b1b1c5 Hugh Dickins 2012-05-29 1460 * @lruvec: mem_cgroup per zone lru vector
fa9add641b1b1c5 Hugh Dickins 2012-05-29 1461 * @lru: index of lru list the page is sitting on
b4536f0c829c858 Michal Hocko 2017-01-10 1462 * @zid: zone id of the accounted pages
fa9add641b1b1c5 Hugh Dickins 2012-05-29 1463 * @nr_pages: positive when adding or negative when removing
925b7673cce3911 Johannes Weiner 2012-01-12 1464 *
ca707239e8a7958 Hugh Dickins 2016-05-19 1465 * This function must be called under lru_lock, just before a page is added
07ca760673088f2 Hugh Dickins 2022-02-14 1466 * to or just after a page is removed from an lru list.
925b7673cce3911 Johannes Weiner 2012-01-12 1467 */
fa9add641b1b1c5 Hugh Dickins 2012-05-29 1468 void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
6a3cda9fd4d0f0b Qi Zheng 2026-03-24 1469 int zid, long nr_pages)
08e552c69c6930d KAMEZAWA Hiroyuki 2009-01-07 1470 {
ef8f2327996b5c2 Mel Gorman 2016-07-28 1471 struct mem_cgroup_per_node *mz;
fa9add641b1b1c5 Hugh Dickins 2012-05-29 1472 unsigned long *lru_size;
ca707239e8a7958 Hugh Dickins 2016-05-19 1473 long size;
08e552c69c6930d KAMEZAWA Hiroyuki 2009-01-07 1474
f8d665422603ee1 Hirokazu Takahashi 2009-01-07 1475 if (mem_cgroup_disabled())
08e552c69c6930d KAMEZAWA Hiroyuki 2009-01-07 1476 return;
6d12e2d8ddbe653 KAMEZAWA Hiroyuki 2008-02-07 1477
ef8f2327996b5c2 Mel Gorman 2016-07-28 1478 mz = container_of(lruvec, struct mem_cgroup_per_node, lruvec);
b4536f0c829c858 Michal Hocko 2017-01-10 1479 lru_size = &mz->lru_zone_size[zid][lru];
ca707239e8a7958 Hugh Dickins 2016-05-19 1480
ca707239e8a7958 Hugh Dickins 2016-05-19 1481 if (nr_pages < 0)
ca707239e8a7958 Hugh Dickins 2016-05-19 1482 *lru_size += nr_pages;
ca707239e8a7958 Hugh Dickins 2016-05-19 1483
ca707239e8a7958 Hugh Dickins 2016-05-19 1484 size = *lru_size;
b4536f0c829c858 Michal Hocko 2017-01-10 1485 if (WARN_ONCE(size < 0,
b4536f0c829c858 Michal Hocko 2017-01-10 @1486 "%s(%p, %d, %d): lru_size %ld\n",
b4536f0c829c858 Michal Hocko 2017-01-10 1487 __func__, lruvec, lru, nr_pages, size)) {
ca707239e8a7958 Hugh Dickins 2016-05-19 1488 VM_BUG_ON(1);
ca707239e8a7958 Hugh Dickins 2016-05-19 1489 *lru_size = 0;
ca707239e8a7958 Hugh Dickins 2016-05-19 1490 }
ca707239e8a7958 Hugh Dickins 2016-05-19 1491
ca707239e8a7958 Hugh Dickins 2016-05-19 1492 if (nr_pages > 0)
fa9add641b1b1c5 Hugh Dickins 2012-05-29 1493 *lru_size += nr_pages;
08e552c69c6930d KAMEZAWA Hiroyuki 2009-01-07 1494 }
544122e5e0ee27d KAMEZAWA Hiroyuki 2009-01-07 1495
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Thu, 26 Mar 2026 03:35:39 +0100 kernel test robot <lkp@intel.com> wrote: > Hi Qi, > > kernel test robot noticed the following build warnings: > > [auto build test WARNING on akpm-mm/mm-everything] > [also build test WARNING on next-20260325] > [cannot apply to trace/for-next linus/master v7.0-rc5] > [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/Qi-Zheng/mm-memcontrol-correct-the-type-of-stats_updates-to-unsigned-long/20260325-230337 > base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything > patch link: https://lore.kernel.org/r/2cf06f9faf51900ce6acbb4740fc60355a2842ed.1774342371.git.zhengqi.arch%40bytedance.com > patch subject: [PATCH 3/3] mm: memcontrol: correct the nr_pages parameter type of mem_cgroup_update_lru_size() > config: riscv-allnoconfig-bpf (https://download.01.org/0day-ci/archive/20260326/202603260338.GfCrsaVO-lkp@intel.com/config) > compiler: riscv64-linux-gnu-gcc (Debian 14.2.0-19) 14.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260326/202603260338.GfCrsaVO-lkp@intel.com/reproduce) Thanks. Can't reproduce. (there are meds for this!) > b4536f0c829c858 Michal Hocko 2017-01-10 @1486 "%s(%p, %d, %d): lru_size %ld\n", We presently have "%s(%p, %d, %ld): lru_size %ld\n", so it appears we fixed this recently.
On Tue, Mar 24, 2026 at 07:31:29PM +0800, Qi Zheng wrote:
> From: Qi Zheng <zhengqi.arch@bytedance.com>
>
> The nr_pages parameter of mem_cgroup_update_lru_size() should clearly
> be long instead of int, let's correct it.
Hmm, but are you ever going to be adding that many pages? I guess technically
correct though.
You should list all the callers and how they use long or unsigned long,
e.g. update_lru_sizes(), lruvec_reparent_lru(), lru_gen_reparent_memcg().
And maybe look a bit into why this was int, if there's any reason for it at
all :)
I'm assuming there's no weird 'let's intentionally let this overflow'
behaviour here.
>
> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
This one looks correct overall, so, with commit message improved:
Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
> ---
> include/linux/memcontrol.h | 2 +-
> mm/memcontrol.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
> index 0861589695298..dc3fa687759b4 100644
> --- a/include/linux/memcontrol.h
> +++ b/include/linux/memcontrol.h
> @@ -878,7 +878,7 @@ static inline bool mem_cgroup_online(struct mem_cgroup *memcg)
> }
>
> void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
> - int zid, int nr_pages);
> + int zid, long nr_pages);
>
> static inline
> unsigned long mem_cgroup_get_zone_lru_size(struct lruvec *lruvec,
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 4a78550f6174e..6491ca74b3398 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -1466,7 +1466,7 @@ struct lruvec *folio_lruvec_lock_irqsave(struct folio *folio,
> * to or just after a page is removed from an lru list.
> */
> void mem_cgroup_update_lru_size(struct lruvec *lruvec, enum lru_list lru,
> - int zid, int nr_pages)
> + int zid, long nr_pages)
> {
> struct mem_cgroup_per_node *mz;
> unsigned long *lru_size;
> --
> 2.20.1
>
On Tue, Mar 24, 2026 at 12:28:08PM +0000, Lorenzo Stoakes (Oracle) wrote: > On Tue, Mar 24, 2026 at 07:31:29PM +0800, Qi Zheng wrote: > > From: Qi Zheng <zhengqi.arch@bytedance.com> > > > > The nr_pages parameter of mem_cgroup_update_lru_size() should clearly > > be long instead of int, let's correct it. > > Hmm, but are you ever going to be adding that many pages? I guess technically > correct though. It has been fine as-is, but reparenting changes that. Reparenting in theory could add billions of pages at once! And yeah the commit message could be improved. -- Cheers, Harry / Hyeonggon
On 3/25/26 8:27 AM, Harry Yoo (Oracle) wrote: > On Tue, Mar 24, 2026 at 12:28:08PM +0000, Lorenzo Stoakes (Oracle) wrote: >> On Tue, Mar 24, 2026 at 07:31:29PM +0800, Qi Zheng wrote: >>> From: Qi Zheng <zhengqi.arch@bytedance.com> >>> >>> The nr_pages parameter of mem_cgroup_update_lru_size() should clearly >>> be long instead of int, let's correct it. >> >> Hmm, but are you ever going to be adding that many pages? I guess technically >> correct though. > > It has been fine as-is, but reparenting changes that. > Reparenting in theory could add billions of pages at once! Right. Thanks for the explanation! > > And yeah the commit message could be improved. Yes, I've omitted a lot of background information, which might seem abrupt to some reviewers unfamiliar with it. I will improve this in the next version. Thanks, Qi >
© 2016 - 2026 Red Hat, Inc.