[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKkSZ5HR=dmn57Zr4Xs6nH7PNJr+wOBZaXLu+3Lum659w@mail.gmail.com>
Date: Mon, 25 Apr 2022 20:43:39 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: Jakub Kicinski <kuba@...nel.org>, netdev <netdev@...r.kernel.org>,
"David S. Miller" <davem@...emloft.net>,
Paolo Abeni <pabeni@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH v2 net] net: Use this_cpu_inc() to increment net->core_stats
On Mon, Apr 25, 2022 at 9:39 AM Sebastian Andrzej Siewior
<bigeasy@...utronix.de> wrote:
>
> The macro dev_core_stats_##FIELD##_inc() disables preemption and invokes
> netdev_core_stats_alloc() to return a per-CPU pointer.
> netdev_core_stats_alloc() will allocate memory on its first invocation
> which breaks on PREEMPT_RT because it requires non-atomic context for
> memory allocation.
>
> This can be avoided by enabling preemption in netdev_core_stats_alloc()
> assuming the caller always disables preemption.
>
> Use unsigned long as type for the counter. Use this_cpu_inc() to
> increment the counter. Use a plain read of the counter.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
> v1…v2:
> - Add missing __percpu annotation as noticed by Jakub + robot
> - Use READ_ONCE() in dev_get_stats() to avoid possible split
> reads, noticed by Eric.
>
SGTM, thanks.
Note this will cause a merge conflict in net-next
Reviewed-by: Eric Dumazet <edumazet@...gle.com>
Powered by blists - more mailing lists