[PATCH] sched: fix integer handling issue

Ferruh Yigit ferruh.yigit at intel.com
Wed Feb 23 11:03:04 CET 2022


On 2/23/2022 7:17 AM, Morten Brørup wrote:
>> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
>> Sent: Tuesday, 22 February 2022 17.03
>>
>> On Tue, 22 Feb 2022 15:13:53 +0100
>> Morten Brørup <mb at smartsharesystems.com> wrote:
>>
>>>> From: Megha Ajmera [mailto:megha.ajmera at intel.com]
>>>> Sent: Tuesday, 22 February 2022 14.19
>>>>
>>>> Masking of core mask was incorrect. Instead of using 1U for
>> shifting,
>>>> it
>>>> should be using 1LU as the result is assigned to uint64.
>>>>
>>>> CID 375859: Potentially overflowing expression "1U <<
>> app_main_core"
>>>> with
>>>> type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit
>>>> arithmetic,
>>>> and then used in a context that expects an expression of type
>>>> "uint64_t"
>>>> (64 bits, unsigned).
>>>>
>>>> Coverity issue: 375859
>>>>
>>>> Signed-off-by: Megha Ajmera <megha.ajmera at intel.com>
>>>> ---
>>>>   examples/qos_sched/args.c | 2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/examples/qos_sched/args.c b/examples/qos_sched/args.c
>>>> index 10ca7bea61..44f2f5640e 100644
>>>> --- a/examples/qos_sched/args.c
>>>> +++ b/examples/qos_sched/args.c
>>>> @@ -433,7 +433,7 @@ app_parse_args(int argc, char **argv)
>>>>   			return -1;
>>>>   		}
>>>>   	}
>>>> -	app_used_core_mask |= 1u << app_main_core;
>>>> +	app_used_core_mask |= 1lu << app_main_core;
>>>
>>> Still wrong on 32 bit platforms, where long unsigned int is still 32
>> bits.
>>>
>>> Use this instead:
>>> app_used_core_mask |= RTE_BIT64(app_main_core);
>>
>> DPDK now supports > 64 lcores. So all code using/assuming a 64 bit mask
>> is broken.
>>
> 
> Good point. Is there a TODO-list where such a general review request can be filed, or should we just file it as a system-wide bug in Bugzilla?
> 
> Nonetheless, I think this one-line fix should be accepted as a short term solution.
> 

Hi Morten,

I suspect there can be more places that testpmd assumes
max core number is 64, someone needs to spend time to
analyze and fix it.




More information about the dev mailing list