[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aH+boS+lxLapI796@yjaykim-PowerEdge-T330>
Date: Tue, 22 Jul 2025 23:09:37 +0900
From: YoungJun Park <youngjun.park@....com>
To: kernel test robot <lkp@...el.com>
Cc: akpm@...ux-foundation.org, hannes@...xchg.org,
oe-kbuild-all@...ts.linux.dev, mhocko@...nel.org,
roman.gushchin@...ux.dev, shakeel.butt@...ux.dev,
muchun.song@...ux.dev, shikemeng@...weicloud.com,
kasong@...cent.com, nphamcs@...il.com, bhe@...hat.com,
baohua@...nel.org, chrisl@...nel.org, cgroups@...r.kernel.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org, gunho.lee@....com,
iamjoonsoo.kim@....com, taejoon.song@....com,
Michal Koutný <mkoutny@...e.com>
Subject: Re: [PATCH 1/4] mm/swap, memcg: Introduce infrastructure for
cgroup-based swap priority
On Thu, Jul 17, 2025 at 07:20:58PM +0800, kernel test robot wrote:
> Hi Youngjun,
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on 347e9f5043c89695b01e66b3ed111755afcf1911]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Youngjun-Park/mm-swap-memcg-Introduce-infrastructure-for-cgroup-based-swap-priority/20250717-042648
> base: 347e9f5043c89695b01e66b3ed111755afcf1911
> patch link: https://lore.kernel.org/r/20250716202006.3640584-2-youngjun.park%40lge.com
> patch subject: [PATCH 1/4] mm/swap, memcg: Introduce infrastructure for cgroup-based swap priority
> config: loongarch-allyesconfig (https://download.01.org/0day-ci/archive/20250717/202507171936.fGW4muEc-lkp@intel.com/config)
> compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 16534d19bf50bde879a83f0ae62875e2c5120e64)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250717/202507171936.fGW4muEc-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@...el.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202507171936.fGW4muEc-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> >> mm/memcontrol.c:5462:12: warning: variable 'id' is uninitialized when used here [-Wuninitialized]
> 5462 | memcg, id, SWAP_PRIORITY_GLOBAL);
> | ^~
> mm/memcontrol.c:5414:8: note: initialize the variable 'id' to silence this warning
> 5414 | u64 id;
> | ^
> | = 0
> 1 warning generated.
>
>
> vim +/id +5462 mm/memcontrol.c
>
> 5408
> 5409 #ifdef CONFIG_SWAP_CGROUP_PRIORITY
> 5410 static ssize_t swap_cgroup_priority_write(struct kernfs_open_file *of,
> 5411 char *buf, size_t nbytes, loff_t off)
> 5412 {
> 5413 struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of));
> 5414 u64 id;
> 5415 int prio;
> 5416 int ret;
> 5417 char first_token[32];
> 5418 char second_token[32];
> 5419 char dummy[2];
> 5420 char *stripped_buf;
> 5421 int num_parsed;
> 5422
> 5423 stripped_buf = strstrip(buf);
> 5424 num_parsed = sscanf(stripped_buf, "%31s %31s %1s", first_token,
> 5425 second_token, dummy);
> 5426 if (num_parsed == 2) {
> 5427 if (strcmp(first_token, "default") == 0) {
> 5428 if (strcmp(second_token, "none") == 0)
> 5429 ret = apply_swap_cgroup_priority(
> 5430 memcg, DEFAULT_ID, SWAP_PRIORITY_GLOBAL);
> 5431 else if (strcmp(second_token, "disabled") == 0)
> 5432 ret = apply_swap_cgroup_priority(
> 5433 memcg, DEFAULT_ID, SWAP_PRIORITY_DISABLE);
> 5434 else
> 5435 ret = -EINVAL;
> 5436 } else {
> 5437 ret = kstrtoull(first_token, 10, &id);
> 5438 if (ret)
> 5439 return -EINVAL;
> 5440
> 5441 if (strcmp(second_token, "none") == 0) {
> 5442 ret = apply_swap_cgroup_priority(
> 5443 memcg, id, SWAP_PRIORITY_GLOBAL);
> 5444 } else if (strcmp(second_token, "disabled") == 0) {
> 5445 ret = apply_swap_cgroup_priority(
> 5446 memcg, id, SWAP_PRIORITY_DISABLE);
> 5447 } else {
> 5448 ret = kstrtoint(second_token, 10, &prio);
> 5449 if (ret)
> 5450 return -EINVAL;
> 5451 if (prio == -1)
> 5452 return -EINVAL;
> 5453 else if (prio > SHRT_MAX || prio < SHRT_MIN)
> 5454 return -EINVAL;
> 5455 ret = apply_swap_cgroup_priority(memcg, id,
> 5456 prio);
> 5457 }
> 5458 }
> 5459 } else if (num_parsed == 1) {
> 5460 if (strcmp(first_token, "none") == 0)
> 5461 ret = apply_swap_cgroup_priority(
> > 5462 memcg, id, SWAP_PRIORITY_GLOBAL);
> 5463 else if (strcmp(first_token, "disabled") == 0)
> 5464 ret = apply_swap_cgroup_priority(
> 5465 memcg, id, SWAP_PRIORITY_DISABLE);
> 5466 else
> 5467 ret = -EINVAL;
> 5468 } else {
> 5469 return -EINVAL;
> 5470 }
> 5471
> 5472 if (ret)
> 5473 return ret;
> 5474
> 5475 return nbytes;
> 5476 }
> 5477
This is an initialization bug where the "default" value may not be handled
correctly in certain cases, such as:
e.g. echo none > memory.swap.priority
I should have checked this more carefully. I will fix the issue and add
a test case in the next patch revision.
Best regards,
Youngjun Park
Powered by blists - more mailing lists