* [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
@ 2023-11-20 20:01 kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2023-11-20 20:01 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: SeongJae Park <sj@kernel.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/sj/linux.git damon/next
head: 54ffd8ae08121d8cbce1874fe46970cce643a2c7
commit: 28cef0e565adbb4175f12ffffce9d0680979de60 [32/42] mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning
:::::: branch date: 24 hours ago
:::::: commit date: 25 hours ago
config: x86_64-randconfig-161-20231121 (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce: (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202311210420.URG3QSAS-lkp@intel.com/
smatch warnings:
mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
vim +/esz +1150 mm/damon/core.c
28cef0e565adbb SeongJae Park 2023-10-27 1125
28cef0e565adbb SeongJae Park 2023-10-27 1126 /* Shouldn't be called if quota->ms, quota->sz, and quota->get_score unset */
1cd2430300594a SeongJae Park 2021-11-05 1127 static void damos_set_effective_quota(struct damos_quota *quota)
1cd2430300594a SeongJae Park 2021-11-05 1128 {
1cd2430300594a SeongJae Park 2021-11-05 1129 unsigned long throughput;
1cd2430300594a SeongJae Park 2021-11-05 1130 unsigned long esz;
1cd2430300594a SeongJae Park 2021-11-05 1131
28cef0e565adbb SeongJae Park 2023-10-27 1132 if (!quota->ms && !quota->get_score) {
1cd2430300594a SeongJae Park 2021-11-05 1133 quota->esz = quota->sz;
1cd2430300594a SeongJae Park 2021-11-05 1134 return;
1cd2430300594a SeongJae Park 2021-11-05 1135 }
1cd2430300594a SeongJae Park 2021-11-05 1136
28cef0e565adbb SeongJae Park 2023-10-27 1137 if (quota->get_score) {
28cef0e565adbb SeongJae Park 2023-10-27 1138 quota->esz_bp = damon_feed_loop_next_input(
28cef0e565adbb SeongJae Park 2023-10-27 1139 max(quota->esz_bp, 10000UL),
28cef0e565adbb SeongJae Park 2023-10-27 1140 quota->get_score(quota->get_score_arg));
28cef0e565adbb SeongJae Park 2023-10-27 1141 esz = quota->esz_bp / 10000;
28cef0e565adbb SeongJae Park 2023-10-27 1142 }
28cef0e565adbb SeongJae Park 2023-10-27 1143
28cef0e565adbb SeongJae Park 2023-10-27 1144 if (quota->ms) {
1cd2430300594a SeongJae Park 2021-11-05 1145 if (quota->total_charged_ns)
1cd2430300594a SeongJae Park 2021-11-05 1146 throughput = quota->total_charged_sz * 1000000 /
1cd2430300594a SeongJae Park 2021-11-05 1147 quota->total_charged_ns;
1cd2430300594a SeongJae Park 2021-11-05 1148 else
1cd2430300594a SeongJae Park 2021-11-05 1149 throughput = PAGE_SIZE * 1024;
28cef0e565adbb SeongJae Park 2023-10-27 @1150 esz = min(throughput * quota->ms, esz);
28cef0e565adbb SeongJae Park 2023-10-27 1151 }
1cd2430300594a SeongJae Park 2021-11-05 1152
1cd2430300594a SeongJae Park 2021-11-05 1153 if (quota->sz && quota->sz < esz)
1cd2430300594a SeongJae Park 2021-11-05 1154 esz = quota->sz;
28cef0e565adbb SeongJae Park 2023-10-27 1155
1cd2430300594a SeongJae Park 2021-11-05 1156 quota->esz = esz;
1cd2430300594a SeongJae Park 2021-11-05 1157 }
1cd2430300594a SeongJae Park 2021-11-05 1158
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
@ 2023-11-21 7:37 Dan Carpenter
2023-11-21 17:36 ` SeongJae Park
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-11-21 7:37 UTC (permalink / raw)
To: oe-kbuild, SeongJae Park; +Cc: lkp, oe-kbuild-all
tree: https://git.kernel.org/pub/scm/linux/kernel/git/sj/linux.git damon/next
head: 54ffd8ae08121d8cbce1874fe46970cce643a2c7
commit: 28cef0e565adbb4175f12ffffce9d0680979de60 [32/42] mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning
config: x86_64-randconfig-161-20231121 (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce: (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202311210420.URG3QSAS-lkp@intel.com/
smatch warnings:
mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
vim +/esz +1150 mm/damon/core.c
1cd2430300594a SeongJae Park 2021-11-05 1127 static void damos_set_effective_quota(struct damos_quota *quota)
1cd2430300594a SeongJae Park 2021-11-05 1128 {
1cd2430300594a SeongJae Park 2021-11-05 1129 unsigned long throughput;
1cd2430300594a SeongJae Park 2021-11-05 1130 unsigned long esz;
1cd2430300594a SeongJae Park 2021-11-05 1131
28cef0e565adbb SeongJae Park 2023-10-27 1132 if (!quota->ms && !quota->get_score) {
1cd2430300594a SeongJae Park 2021-11-05 1133 quota->esz = quota->sz;
1cd2430300594a SeongJae Park 2021-11-05 1134 return;
1cd2430300594a SeongJae Park 2021-11-05 1135 }
1cd2430300594a SeongJae Park 2021-11-05 1136
28cef0e565adbb SeongJae Park 2023-10-27 1137 if (quota->get_score) {
28cef0e565adbb SeongJae Park 2023-10-27 1138 quota->esz_bp = damon_feed_loop_next_input(
28cef0e565adbb SeongJae Park 2023-10-27 1139 max(quota->esz_bp, 10000UL),
28cef0e565adbb SeongJae Park 2023-10-27 1140 quota->get_score(quota->get_score_arg));
28cef0e565adbb SeongJae Park 2023-10-27 1141 esz = quota->esz_bp / 10000;
28cef0e565adbb SeongJae Park 2023-10-27 1142 }
esz uninitialized on else path.
28cef0e565adbb SeongJae Park 2023-10-27 1143
28cef0e565adbb SeongJae Park 2023-10-27 1144 if (quota->ms) {
1cd2430300594a SeongJae Park 2021-11-05 1145 if (quota->total_charged_ns)
1cd2430300594a SeongJae Park 2021-11-05 1146 throughput = quota->total_charged_sz * 1000000 /
1cd2430300594a SeongJae Park 2021-11-05 1147 quota->total_charged_ns;
1cd2430300594a SeongJae Park 2021-11-05 1148 else
1cd2430300594a SeongJae Park 2021-11-05 1149 throughput = PAGE_SIZE * 1024;
28cef0e565adbb SeongJae Park 2023-10-27 @1150 esz = min(throughput * quota->ms, esz);
28cef0e565adbb SeongJae Park 2023-10-27 1151 }
1cd2430300594a SeongJae Park 2021-11-05 1152
1cd2430300594a SeongJae Park 2021-11-05 1153 if (quota->sz && quota->sz < esz)
1cd2430300594a SeongJae Park 2021-11-05 1154 esz = quota->sz;
28cef0e565adbb SeongJae Park 2023-10-27 1155
1cd2430300594a SeongJae Park 2021-11-05 1156 quota->esz = esz;
1cd2430300594a SeongJae Park 2021-11-05 1157 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
2023-11-21 7:37 [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz' Dan Carpenter
@ 2023-11-21 17:36 ` SeongJae Park
2023-11-22 9:13 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: SeongJae Park @ 2023-11-21 17:36 UTC (permalink / raw)
To: Dan Carpenter; +Cc: oe-kbuild, SeongJae Park, lkp, oe-kbuild-all, damon
Hi Dan,
On Tue, 21 Nov 2023 02:37:12 -0500 Dan Carpenter <dan.carpenter@linaro.org> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/sj/linux.git damon/next
> head: 54ffd8ae08121d8cbce1874fe46970cce643a2c7
> commit: 28cef0e565adbb4175f12ffffce9d0680979de60 [32/42] mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning
> config: x86_64-randconfig-161-20231121 (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-lkp@intel.com/config)
> compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
> reproduce: (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-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>
> | Reported-by: Dan Carpenter <error27@gmail.com>
> | Closes: https://lore.kernel.org/r/202311210420.URG3QSAS-lkp@intel.com/
>
> smatch warnings:
> mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
Thank you for this nice report!
However, damos_set_effective_quota() is called from damos_adjust_quota(), which
ensures at least one among quota->{ms,sz,get_score} is nonzero. And
damos_set_effective_quota() ensures quota->{ms,get_score} is non-zero at the
beginning of the function. Then the function sets esz anyway, for non-zero
quota->ms and quota->get_score. Hence the uninitialized variable usage cannot
happen, if I understand correctly. Please let me know if I'm missing
something.
Thanks,
SJ
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
2023-11-21 17:36 ` SeongJae Park
@ 2023-11-22 9:13 ` Dan Carpenter
2023-11-22 18:50 ` SeongJae Park
0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2023-11-22 9:13 UTC (permalink / raw)
To: SeongJae Park; +Cc: oe-kbuild, lkp, oe-kbuild-all, damon
On Tue, Nov 21, 2023 at 05:36:02PM +0000, SeongJae Park wrote:
> Hi Dan,
>
> On Tue, 21 Nov 2023 02:37:12 -0500 Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/sj/linux.git damon/next
> > head: 54ffd8ae08121d8cbce1874fe46970cce643a2c7
> > commit: 28cef0e565adbb4175f12ffffce9d0680979de60 [32/42] mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning
> > config: x86_64-randconfig-161-20231121 (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-lkp@intel.com/config)
> > compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
> > reproduce: (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-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>
> > | Reported-by: Dan Carpenter <error27@gmail.com>
> > | Closes: https://lore.kernel.org/r/202311210420.URG3QSAS-lkp@intel.com/
> >
> > smatch warnings:
> > mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
>
> Thank you for this nice report!
>
> However, damos_set_effective_quota() is called from damos_adjust_quota(), which
> ensures at least one among quota->{ms,sz,get_score} is nonzero. And
> damos_set_effective_quota() ensures quota->{ms,get_score} is non-zero at the
> beginning of the function. Then the function sets esz anyway, for non-zero
> quota->ms and quota->get_score.
The problem is in the "non-zero quota->ms" situation. It uses an
uninitialized value of esz to initialize esz.
28cef0e565adbb SeongJae Park 2023-10-27 @1150 esz = min(throughput * quota->ms, esz);
^^^ ^^^
This is the uninitialized variable.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
2023-11-22 9:13 ` Dan Carpenter
@ 2023-11-22 18:50 ` SeongJae Park
0 siblings, 0 replies; 5+ messages in thread
From: SeongJae Park @ 2023-11-22 18:50 UTC (permalink / raw)
To: Dan Carpenter; +Cc: SeongJae Park, oe-kbuild, lkp, oe-kbuild-all, damon
On Wed, 22 Nov 2023 04:13:36 -0500 Dan Carpenter <dan.carpenter@linaro.org> wrote:
> On Tue, Nov 21, 2023 at 05:36:02PM +0000, SeongJae Park wrote:
> > Hi Dan,
> >
> > On Tue, 21 Nov 2023 02:37:12 -0500 Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/sj/linux.git damon/next
> > > head: 54ffd8ae08121d8cbce1874fe46970cce643a2c7
> > > commit: 28cef0e565adbb4175f12ffffce9d0680979de60 [32/42] mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning
> > > config: x86_64-randconfig-161-20231121 (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-lkp@intel.com/config)
> > > compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
> > > reproduce: (https://download.01.org/0day-ci/archive/20231121/202311210420.URG3QSAS-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>
> > > | Reported-by: Dan Carpenter <error27@gmail.com>
> > > | Closes: https://lore.kernel.org/r/202311210420.URG3QSAS-lkp@intel.com/
> > >
> > > smatch warnings:
> > > mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
> >
> > Thank you for this nice report!
> >
> > However, damos_set_effective_quota() is called from damos_adjust_quota(), which
> > ensures at least one among quota->{ms,sz,get_score} is nonzero. And
> > damos_set_effective_quota() ensures quota->{ms,get_score} is non-zero at the
> > beginning of the function. Then the function sets esz anyway, for non-zero
> > quota->ms and quota->get_score.
>
> The problem is in the "non-zero quota->ms" situation. It uses an
> uninitialized value of esz to initialize esz.
>
> 28cef0e565adbb SeongJae Park 2023-10-27 @1150 esz = min(throughput * quota->ms, esz);
> ^^^ ^^^
> This is the uninitialized variable.
Ah, you're correct. I was out of mind. Thank you for this kind explanation.
I will squash below fix to the broken commit.
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -1147,7 +1147,10 @@ static void damos_set_effective_quota(struct damos_quota *quota)
quota->total_charged_ns;
else
throughput = PAGE_SIZE * 1024;
- esz = min(throughput * quota->ms, esz);
+ if (quota->get_score)
+ esz = min(throughput * quota->ms, esz);
+ else
+ esz = throughput * quota->ms;
}
if (quota->sz && quota->sz < esz)
Thanks,
SJ
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-22 18:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-21 7:37 [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz' Dan Carpenter
2023-11-21 17:36 ` SeongJae Park
2023-11-22 9:13 ` Dan Carpenter
2023-11-22 18:50 ` SeongJae Park
-- strict thread matches above, loose matches on Subject: below --
2023-11-20 20:01 kernel test robot
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.