public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Arnd Bergmann <arnd@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	linux-kernel@vger.kernel.org,
	Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH] sched/fair: avoid integer overflow warning for fair_server_period_max;
Date: Wed, 7 Aug 2024 12:39:02 +0200	[thread overview]
Message-ID: <20240807103902.GU39708@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAKfTPtDs-Y5_puGU2QYd_NatB7RQzgGQPuwfaCWXrq_8Vqw2dw@mail.gmail.com>

On Wed, Aug 07, 2024 at 12:00:35PM +0200, Vincent Guittot wrote:
> Hi Arnd
> 
> On Wed, 7 Aug 2024 at 10:00, Arnd Bergmann <arnd@kernel.org> wrote:
> >
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > The clalculation of fair_server_period_max includes an integer overflow:
> >
> > In file included from kernel/sched/build_utility.c:72:
> > kernel/sched/debug.c:341:57: error: integer overflow in expression of type 'long int' results in '-100663296' [-Werror=overflow]
> >   341 | static unsigned long fair_server_period_max = (1 << 22) * NSEC_PER_USEC; /* ~4 seconds */
> >
> > Avoids this by using an unsigned constant to start with.
> 
> Dan sent something similar
> https://lore.kernel.org/lkml/a936b991-e464-4bdf-94ab-08e25d364986@stanley.mountain/

Right, tglx also pointed me at a report for this. Let me go queue Dan's
patch.

> >
> > Fixes: d741f297bcea ("sched/fair: Fair server interface")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  kernel/sched/debug.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
> > index 0148bc65d39c..242e7f264a0b 100644
> > --- a/kernel/sched/debug.c
> > +++ b/kernel/sched/debug.c
> > @@ -338,7 +338,7 @@ enum dl_param {
> >         DL_PERIOD,
> >  };
> >
> > -static unsigned long fair_server_period_max = (1 << 22) * NSEC_PER_USEC; /* ~4 seconds */
> > +static unsigned long fair_server_period_max = (1u << 22) * NSEC_PER_USEC; /* ~4 seconds */
> >  static unsigned long fair_server_period_min = (100) * NSEC_PER_USEC;     /* 100 us */
> >
> >  static ssize_t sched_fair_server_write(struct file *filp, const char __user *ubuf,
> > --
> > 2.39.2
> >

      reply	other threads:[~2024-08-07 10:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  8:00 [PATCH] sched/fair: avoid integer overflow warning for fair_server_period_max; Arnd Bergmann
2024-08-07 10:00 ` Vincent Guittot
2024-08-07 10:39   ` Peter Zijlstra [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=20240807103902.GU39708@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=bsegall@google.com \
    --cc=dan.carpenter@linaro.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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