[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3aa80a19-d2cd-47a2-aaf9-4bc438b7656b@huawei.com>
Date: Wed, 6 Aug 2025 12:00:40 +0800
From: Jijie Shao <shaojijie@...wei.com>
To: Jakub Kicinski <kuba@...nel.org>
CC: <shaojijie@...wei.com>, <davem@...emloft.net>, <edumazet@...gle.com>,
<pabeni@...hat.com>, <andrew+netdev@...n.ch>, <horms@...nel.org>,
<shenjian15@...wei.com>, <liuyonglong@...wei.com>, <chenhao418@...wei.com>,
<jonathan.cameron@...wei.com>, <shameerali.kolothum.thodi@...wei.com>,
<salil.mehta@...wei.com>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH V2 net 2/3] net: hibmcge: fix the division by zero issue
on 2025/8/6 9:14, Jakub Kicinski wrote:
> On Sat, 2 Aug 2025 20:32:25 +0800 Jijie Shao wrote:
>> static inline u32 hbg_get_queue_used_num(struct hbg_ring *ring)
>> {
>> + if (!ring->len)
>> + return 0;
>> +
>> return (ring->ntu + ring->len - ring->ntc) % ring->len;
> This should probably be a READ_ONCE() to a temporary variable.
> There is no locking in debugfs, AFAICT, the value may change
> between the test and the division / modulo.
Yes, there is indeed a very short time window.
I will add READ_ONCE() to ring->len and read it only once.
Thanks
Jijie Shao
Powered by blists - more mailing lists