From: "Hunt, David" <david.hunt@intel.com>
To: "Burakov, Anatoly" <anatoly.burakov@intel.com>, dev@dpdk.org
Cc: stable@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v1] examples/vm_power_manager: fix overflowed return value
Date: Fri, 26 Apr 2019 12:14:42 +0100 [thread overview]
Message-ID: <109520e2-b6fc-418c-81e9-03b7821ea2ed@intel.com> (raw)
Message-ID: <20190426111442.utrAcOQb1yOMHp9dpizlP-F34xfh_ePLcxS8IopStQU@z> (raw)
In-Reply-To: <ffd31c3e-9510-f3e9-0604-576b8a14d8d9@intel.com>
Hi Anatoly,
On 26/4/2019 11:29 AM, Burakov, Anatoly wrote:
> On 26-Apr-19 9:44 AM, David Hunt wrote:
>> Coverity complains about the return of a value that may
>> possibly overflow because of a multiply. Limit the value
>> so it cannot overflow.
>>
>> Coverity issue: 337677
>> Fixes: 4b1a631b8a ("examples/vm_power: add oob monitoring functions")
>> CC: stable@dpdk.org
>> Signed-off-by: David Hunt <david.hunt@intel.com>
>> ---
>> examples/vm_power_manager/oob_monitor_x86.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/examples/vm_power_manager/oob_monitor_x86.c
>> b/examples/vm_power_manager/oob_monitor_x86.c
>> index ebd96b205..2074eec1e 100644
>> --- a/examples/vm_power_manager/oob_monitor_x86.c
>> +++ b/examples/vm_power_manager/oob_monitor_x86.c
>> @@ -99,7 +99,10 @@ apply_policy(int core)
>> return -1.0;
>> }
>> - ratio = (float)miss_diff * (float)100 / (float)hits_diff;
>> + ratio = (float)miss_diff / (float)hits_diff;
>> + if (ratio > 1.0)
>> + ratio = 1.0;
>> + ratio *= 100.0f;
>
> It should probably be the other way around - multiply first, then
> clamp. Also, please use RTE_MIN.
>
I tried that, but coverity still sees an overflow condition. I need to
clamp first, then multiply. Then coverity is happy.
Also, do you really want me to change to use RTE_MIN? I honestly prefer
the code as it is.
>> if (ratio < ci->branch_ratio_threshold)
>> power_manager_scale_core_min(core);
>>
>
>
next prev parent reply other threads:[~2019-04-26 11:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 8:44 David Hunt
2019-04-26 8:44 ` David Hunt
2019-04-26 10:29 ` Burakov, Anatoly
2019-04-26 10:29 ` Burakov, Anatoly
2019-04-26 11:14 ` Hunt, David [this message]
2019-04-26 11:14 ` Hunt, David
2019-04-26 12:03 ` Burakov, Anatoly
2019-04-26 12:03 ` Burakov, Anatoly
2019-04-26 12:35 ` Burakov, Anatoly
2019-04-26 12:35 ` Burakov, Anatoly
2019-04-26 13:50 ` Hunt, David
2019-04-26 13:50 ` Hunt, David
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=109520e2-b6fc-418c-81e9-03b7821ea2ed@intel.com \
--to=david.hunt@intel.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
/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 NNTP newsgroup(s).