[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAjsZQwymBUvn67+jWJ1WRG2iJHyQFLwWEh8+3O_ryfX31mesw@mail.gmail.com>
Date: Sat, 3 May 2025 08:50:49 +0900
From: Moon Yeounsu <yyyynoom@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2] net: dlink: add synchronization for stats update
Thank you for reviewing my patch!
On Wed, Apr 30, 2025 at 6:35 AM Jakub Kicinski <kuba@...nel.org> wrote:
> I could be wrong but since this code runs in IRQ context I believe
> you need to use spin_lock_irqsave() here. Or just spin_lock() but
> not sure, and spin_lock_irqsave() always works..
If my understanding is correct, then it seems I was mistaken and you were right.
I misunderstood that the same form of locking function should always
be used for a given lock. However, as you pointed out,
`spin_[un]lock()` seems to be the correct choice in this case.
This is because the `tx_error()` function is only called from
`rio_interrupt()`, which runs in IRQ context. (There are no other call
paths.) In this context, there's no need to enable or disable IRQs at
all.
Also, I believe that `spin_lock_irq()` in `get_stats()` should be
changed to `spin_lock_irqsave()` since `get_stats()` can be called
from IRQ context (via `rio_interrupt()` -> `rio_error()` ->
`get_stats()`). In my view, calling `spin_unlock_irq()` in this
context could be risky, as it would re-enable local IRQs via
local_irq_enable().
There are two ways to lock the `get_stats()` function: either add a
new parameter to check whether it's in IRQ context, or simply use
`spin_lock_irqsave()`. I found that `rio_free_tx()` behaves like the
first case. I'd appreciate your opinion on which approach would be
preferable here.
Thanks again for your feedback.
Best regards,
Moon Yeounsu
Powered by blists - more mailing lists