From: Gautham R Shenoy <ego@linux.vnet.ibm.com>
To: Balbir Singh <bsingharora@gmail.com>
Cc: Stewart Smith <stewart@linux.vnet.ibm.com>,
"Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
Michael Neuling <mikey@neuling.org>,
linux-pm@vger.kernel.org,
Daniel Lezcano <daniel.lezcano@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Nicholas Piggin <npiggin@gmail.com>,
Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>,
"open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)"
<linuxppc-dev@lists.ozlabs.org>,
Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
Subject: Re: [PATCH] cpuidle:powernv: Make the snooze timeout dynamic.
Date: Fri, 1 Jun 2018 10:24:33 +0530 [thread overview]
Message-ID: <20180601045433.GA17425@in.ibm.com> (raw)
In-Reply-To: <CAKTCnz=WhC_vamKPZruEqc04WKpD5ZqZm0zTcCtagRHib6OZPw@mail.gmail.com>
Hi Balbir,
Thanks for reviewing the patch!
On Fri, Jun 01, 2018 at 12:51:05AM +1000, Balbir Singh wrote:
> On Thu, May 31, 2018 at 10:15 PM, Gautham R. Shenoy
[..snip..]
> >
> > +static u64 get_snooze_timeout(struct cpuidle_device *dev,
> > + struct cpuidle_driver *drv,
> > + int index)
> > +{
> > + int i;
> > +
> > + if (unlikely(!snooze_timeout_en))
> > + return default_snooze_timeout;
> > +
> > + for (i = index + 1; i < drv->state_count; i++) {
> > + struct cpuidle_state *s = &drv->states[i];
> > + struct cpuidle_state_usage *su = &dev->states_usage[i];
> > +
> > + if (s->disabled || su->disable)
> > + continue;
> > +
> > + return s->target_residency * tb_ticks_per_usec;
>
> Can we ensure this is not prone to overflow?
s->target_residency is an "unsigned int" so can take a maximum value
of UINT_MAX. tb_ticks_per_usec is an "unsigned long" with a value in
the range of 100-1000. The return value is a u64. The product of
s->target_residency and tb_ticks_per_usec should be contained in u64.
Is there a potential case of overflow that I am missing ?
>
> Otherwise looks good
>
> Reviewed-by: Balbir Singh <bsingharora@gmail.com>
--
Thanks and Regards
gautham.
WARNING: multiple messages have this Message-ID (diff)
From: Gautham R Shenoy <ego@linux.vnet.ibm.com>
To: Balbir Singh <bsingharora@gmail.com>
Cc: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Stewart Smith <stewart@linux.vnet.ibm.com>,
Michael Neuling <mikey@neuling.org>,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>,
Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>,
Nicholas Piggin <npiggin@gmail.com>,
"open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)"
<linuxppc-dev@lists.ozlabs.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-pm@vger.kernel.org
Subject: Re: [PATCH] cpuidle:powernv: Make the snooze timeout dynamic.
Date: Fri, 1 Jun 2018 10:24:33 +0530 [thread overview]
Message-ID: <20180601045433.GA17425@in.ibm.com> (raw)
In-Reply-To: <CAKTCnz=WhC_vamKPZruEqc04WKpD5ZqZm0zTcCtagRHib6OZPw@mail.gmail.com>
Hi Balbir,
Thanks for reviewing the patch!
On Fri, Jun 01, 2018 at 12:51:05AM +1000, Balbir Singh wrote:
> On Thu, May 31, 2018 at 10:15 PM, Gautham R. Shenoy
[..snip..]
> >
> > +static u64 get_snooze_timeout(struct cpuidle_device *dev,
> > + struct cpuidle_driver *drv,
> > + int index)
> > +{
> > + int i;
> > +
> > + if (unlikely(!snooze_timeout_en))
> > + return default_snooze_timeout;
> > +
> > + for (i = index + 1; i < drv->state_count; i++) {
> > + struct cpuidle_state *s = &drv->states[i];
> > + struct cpuidle_state_usage *su = &dev->states_usage[i];
> > +
> > + if (s->disabled || su->disable)
> > + continue;
> > +
> > + return s->target_residency * tb_ticks_per_usec;
>
> Can we ensure this is not prone to overflow?
s->target_residency is an "unsigned int" so can take a maximum value
of UINT_MAX. tb_ticks_per_usec is an "unsigned long" with a value in
the range of 100-1000. The return value is a u64. The product of
s->target_residency and tb_ticks_per_usec should be contained in u64.
Is there a potential case of overflow that I am missing ?
>
> Otherwise looks good
>
> Reviewed-by: Balbir Singh <bsingharora@gmail.com>
--
Thanks and Regards
gautham.
next prev parent reply other threads:[~2018-06-01 4:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-31 12:15 [PATCH] cpuidle:powernv: Make the snooze timeout dynamic Gautham R. Shenoy
2018-05-31 14:51 ` Balbir Singh
2018-06-01 4:54 ` Gautham R Shenoy [this message]
2018-06-01 4:54 ` Gautham R Shenoy
2018-06-02 0:16 ` Balbir Singh
2018-06-04 11:27 ` Michael Ellerman
2018-06-04 11:27 ` Michael Ellerman
2018-06-05 3:47 ` Stewart Smith
2018-06-05 3:47 ` Stewart Smith
2018-06-05 8:45 ` Gautham R Shenoy
2018-06-05 12:18 ` Michael Ellerman
2018-06-05 12:18 ` Michael Ellerman
2018-06-05 15:19 ` Michael Ellerman
2018-06-05 15:19 ` Michael Ellerman
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=20180601045433.GA17425@in.ibm.com \
--to=ego@linux.vnet.ibm.com \
--cc=akshay.adiga@linux.vnet.ibm.com \
--cc=bsingharora@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.org \
--cc=npiggin@gmail.com \
--cc=rjw@rjwysocki.net \
--cc=shilpa.bhat@linux.vnet.ibm.com \
--cc=stewart@linux.vnet.ibm.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 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.