All of lore.kernel.org
 help / color / mirror / Atom feed
* [sj:damon/next 8/115] mm/damon/core.c:2897:6: warning: variable 'sz' is used uninitialized whenever 'if' condition is false
@ 2026-11-28 12:18 kernel test robot
  2026-11-28 17:27 ` SJ Park
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2026-11-28 12:18 UTC (permalink / raw)
  To: SJ Park; +Cc: oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/sj/linux.git damon/next
head:   48de80bb219cbce999fe877fcf3256d863908567
commit: 6c2c2ebe06271b1f829f6eac8b56baab5ca71b11 [8/115] mm/damon/core: do not update stat for core filter rejecting region
config: powerpc-randconfig-2200-20261128 (https://download.01.org/0day-ci/archive/20261128/20261128131145.Nl6CvXC3-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 578b1f2d6a9776b63cbb6b86f4cca6208d429f48)
smatch: v0.5.0-9187-g5189e3fb
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261128/20261128131145.Nl6CvXC3-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/20261128131145.Nl6CvXC3-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> mm/damon/core.c:2897:6: warning: variable 'sz' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    2897 |         if (c->ops.apply_scheme) {
         |             ^~~~~~~~~~~~~~~~~~~
   mm/damon/core.c:2930:23: note: uninitialized use occurs here
    2930 |         damos_update_stat(s, sz, sz_applied, sz_ops_filter_passed);
         |                              ^~
   mm/damon/core.c:2897:2: note: remove the 'if' if its condition is always true
    2897 |         if (c->ops.apply_scheme) {
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
   mm/damon/core.c:2864:18: note: initialize the variable 'sz' to silence this warning
    2864 |         unsigned long sz;
         |                         ^
         |                          = 0
   1 warning generated.


vim +2897 mm/damon/core.c

c7ec7d5f6b3d1f SJ Park      2026-04-27  2859  
e63a30c51f8400 SJ Park      2022-10-26  2860  static void damos_apply_scheme(struct damon_ctx *c, struct damon_target *t,
e63a30c51f8400 SJ Park      2022-10-26  2861  		struct damon_region *r, struct damos *s)
2ea3498980f5e6 SJ Park      2022-10-26  2862  {
2ea3498980f5e6 SJ Park      2022-10-26  2863  	struct damos_quota *quota = &s->quota;
6c2c2ebe06271b SJ Park      2026-11-22  2864  	unsigned long sz;
2ea3498980f5e6 SJ Park      2022-10-26  2865  	struct timespec64 begin, end;
2ea3498980f5e6 SJ Park      2022-10-26  2866  	unsigned long sz_applied = 0;
b5bbe9c08fd151 SJ Park      2025-01-06  2867  	unsigned long sz_ops_filter_passed = 0;
c603c630b509d6 SJ Park      2023-09-13  2868  	/*
c603c630b509d6 SJ Park      2023-09-13  2869  	 * We plan to support multiple context per kdamond, as DAMON sysfs
c603c630b509d6 SJ Park      2023-09-13  2870  	 * implies with 'nr_contexts' file.  Nevertheless, only single context
c603c630b509d6 SJ Park      2023-09-13  2871  	 * per kdamond is supported for now.  So, we can simply use '0' context
c603c630b509d6 SJ Park      2023-09-13  2872  	 * index here.
c603c630b509d6 SJ Park      2023-09-13  2873  	 */
c603c630b509d6 SJ Park      2023-09-13  2874  	unsigned int cidx = 0;
c603c630b509d6 SJ Park      2023-09-13  2875  	struct damos *siter;		/* schemes iterator */
c603c630b509d6 SJ Park      2023-09-13  2876  	unsigned int sidx = 0;
c603c630b509d6 SJ Park      2023-09-13  2877  	struct damon_target *titer;	/* targets iterator */
bcea0202d4656f SJ Park      2026-06-29  2878  	unsigned int tidx = 0, nr_accesses = 0;
c603c630b509d6 SJ Park      2023-09-13  2879  	bool do_trace = false;
c603c630b509d6 SJ Park      2023-09-13  2880  
c603c630b509d6 SJ Park      2023-09-13  2881  	/* get indices for trace_damos_before_apply() */
c603c630b509d6 SJ Park      2023-09-13  2882  	if (trace_damos_before_apply_enabled()) {
c603c630b509d6 SJ Park      2023-09-13  2883  		damon_for_each_scheme(siter, c) {
c603c630b509d6 SJ Park      2023-09-13  2884  			if (siter == s)
c603c630b509d6 SJ Park      2023-09-13  2885  				break;
c603c630b509d6 SJ Park      2023-09-13  2886  			sidx++;
c603c630b509d6 SJ Park      2023-09-13  2887  		}
c603c630b509d6 SJ Park      2023-09-13  2888  		damon_for_each_target(titer, c) {
c603c630b509d6 SJ Park      2023-09-13  2889  			if (titer == t)
c603c630b509d6 SJ Park      2023-09-13  2890  				break;
c603c630b509d6 SJ Park      2023-09-13  2891  			tidx++;
c603c630b509d6 SJ Park      2023-09-13  2892  		}
bcea0202d4656f SJ Park      2026-06-29  2893  		nr_accesses = damon_nr_accesses_mvsum(r, c);
c603c630b509d6 SJ Park      2023-09-13  2894  		do_trace = true;
c603c630b509d6 SJ Park      2023-09-13  2895  	}
2ea3498980f5e6 SJ Park      2022-10-26  2896  
f7d911c39cbbb8 SJ Park      2022-03-22 @2897  	if (c->ops.apply_scheme) {
6c2c2ebe06271b SJ Park      2026-11-22  2898  		if (damos_core_filter_out(c, t, r, s))
6c2c2ebe06271b SJ Park      2026-11-22  2899  			return;
6c2c2ebe06271b SJ Park      2026-11-22  2900  		sz = damon_sz_region(r);
54419bbd0ee3c7 SJ Park      2026-03-09  2901  		if (damos_quota_is_set(quota) &&
54419bbd0ee3c7 SJ Park      2026-03-09  2902  				quota->charged_sz + sz > quota->esz) {
1cd2430300594a SJ Park      2021-11-05  2903  			sz = ALIGN_DOWN(quota->esz - quota->charged_sz,
cc1db8dff8e751 SJ Park      2026-01-17  2904  					c->min_region_sz);
2b8a248d587334 SJ Park      2021-11-05  2905  			if (!sz)
2b8a248d587334 SJ Park      2021-11-05  2906  				goto update_stat;
64a9974ad5c61f SJ Park      2026-11-02  2907  			if (damon_split_region_at(c, t, r, sz))
90c2fa6adfed7a SJ Park      2026-09-01  2908  				goto update_stat;
2b8a248d587334 SJ Park      2021-11-05  2909  		}
4ff3b4a54a3214 Donggeun Yoo 2026-09-21  2910  		sz = damon_sz_region(r);
1cd2430300594a SJ Park      2021-11-05  2911  		ktime_get_coarse_ts64(&begin);
bcea0202d4656f SJ Park      2026-06-29  2912  		trace_damos_before_apply(cidx, sidx, tidx, r, nr_accesses,
c603c630b509d6 SJ Park      2023-09-13  2913  				damon_nr_regions(t), do_trace);
b5bbe9c08fd151 SJ Park      2025-01-06  2914  		sz_applied = c->ops.apply_scheme(c, t, r, s,
b5bbe9c08fd151 SJ Park      2025-01-06  2915  				&sz_ops_filter_passed);
cfc33a7d2daca4 SJ Park      2025-01-06  2916  		damos_walk_call_walk(c, t, r, s, sz_ops_filter_passed);
1cd2430300594a SJ Park      2021-11-05  2917  		ktime_get_coarse_ts64(&end);
1cd2430300594a SJ Park      2021-11-05  2918  		quota->total_charged_ns += timespec64_to_ns(&end) -
1cd2430300594a SJ Park      2021-11-05  2919  			timespec64_to_ns(&begin);
4ee4fb3214a8aa SJ Park      2026-04-27  2920  		damos_charge_quota(quota, sz, sz_applied);
c7ec7d5f6b3d1f SJ Park      2026-04-27  2921  		if (damos_quota_is_full(quota, c->min_region_sz)) {
50585192bc2ef9 SJ Park      2021-11-05  2922  			quota->charge_target_from = t;
5a2d162e22bf33 SJ Park      2026-04-27  2923  			quota->charge_addr_from = r->ar.end;
50585192bc2ef9 SJ Park      2021-11-05  2924  		}
2b8a248d587334 SJ Park      2021-11-05  2925  	}
2f0b548c9f03a7 SJ Park      2021-11-05  2926  	if (s->action != DAMOS_STAT)
1f366e421c8f69 SJ Park      2021-11-05  2927  		r->age = 0;
2b8a248d587334 SJ Park      2021-11-05  2928  
2b8a248d587334 SJ Park      2021-11-05  2929  update_stat:
60fa9355a6c620 SJ Park      2025-01-06  2930  	damos_update_stat(s, sz, sz_applied, sz_ops_filter_passed);
1f366e421c8f69 SJ Park      2021-11-05  2931  }
e63a30c51f8400 SJ Park      2022-10-26  2932  

:::::: The code at line 2897 was first introduced by commit
:::::: f7d911c39cbbb88d625216a0cfd0517a3047c46e mm/damon: rename damon_primitives to damon_operations

:::::: TO: SeongJae Park <sj@kernel.org>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [sj:damon/next 8/115] mm/damon/core.c:2897:6: warning: variable 'sz' is used uninitialized whenever 'if' condition is false
  2026-11-28 12:18 [sj:damon/next 8/115] mm/damon/core.c:2897:6: warning: variable 'sz' is used uninitialized whenever 'if' condition is false kernel test robot
@ 2026-11-28 17:27 ` SJ Park
  0 siblings, 0 replies; 2+ messages in thread
From: SJ Park @ 2026-11-28 17:27 UTC (permalink / raw)
  To: kernel test robot; +Cc: SJ Park, oe-kbuild-all

On Sat, 28 Nov 2026 13:18:16 +0100 kernel test robot <lkp@intel.com> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/sj/linux.git damon/next
> head:   48de80bb219cbce999fe877fcf3256d863908567
> commit: 6c2c2ebe06271b1f829f6eac8b56baab5ca71b11 [8/115] mm/damon/core: do not update stat for core filter rejecting region
> config: powerpc-randconfig-2200-20261128 (https://download.01.org/0day-ci/archive/20261128/20261128131145.Nl6CvXC3-lkp@intel.com/config)
> compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 578b1f2d6a9776b63cbb6b86f4cca6208d429f48)
> smatch: v0.5.0-9187-g5189e3fb
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261128/20261128131145.Nl6CvXC3-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/20261128131145.Nl6CvXC3-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
> >> mm/damon/core.c:2897:6: warning: variable 'sz' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>     2897 |         if (c->ops.apply_scheme) {
>          |             ^~~~~~~~~~~~~~~~~~~
>    mm/damon/core.c:2930:23: note: uninitialized use occurs here
>     2930 |         damos_update_stat(s, sz, sz_applied, sz_ops_filter_passed);
>          |                              ^~
>    mm/damon/core.c:2897:2: note: remove the 'if' if its condition is always true
>     2897 |         if (c->ops.apply_scheme) {
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~
>    mm/damon/core.c:2864:18: note: initialize the variable 'sz' to silence this warning
>     2864 |         unsigned long sz;
>          |                         ^
>          |                          = 0
>    1 warning generated.

Thank you for this report!  I added a fix to my tree.


Thanks,
SJ

[...]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-28 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 12:18 [sj:damon/next 8/115] mm/damon/core.c:2897:6: warning: variable 'sz' is used uninitialized whenever 'if' condition is false kernel test robot
2026-11-28 17:27 ` SJ Park

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.