damon.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: SeongJae Park <sj@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: SeongJae Park <sj@kernel.org>,
	oe-kbuild@lists.linux.dev, lkp@intel.com,
	oe-kbuild-all@lists.linux.dev, damon@lists.linux.dev
Subject: Re: [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz'.
Date: Wed, 22 Nov 2023 18:50:49 +0000	[thread overview]
Message-ID: <20231122185049.102436-1-sj@kernel.org> (raw)
In-Reply-To: <aa9343f1-b0f9-4452-82e9-d63192ecbcd7@suswa.mountain>

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
> 

      reply	other threads:[~2023-11-22 18:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <473b4c2e-863d-42ec-860a-bf8ec4385240@suswa.mountain>
2023-11-21 17:36 ` [sj:damon/next 32/42] mm/damon/core.c:1150 damos_set_effective_quota() error: uninitialized symbol 'esz' SeongJae Park
2023-11-22  9:13   ` Dan Carpenter
2023-11-22 18:50     ` SeongJae Park [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231122185049.102436-1-sj@kernel.org \
    --to=sj@kernel.org \
    --cc=damon@lists.linux.dev \
    --cc=dan.carpenter@linaro.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).