[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKbn97Rbjc+3uZMpUi0tqCuhj88UdFZhhnqpC6nJRLC=A@mail.gmail.com>
Date: Tue, 12 Sep 2023 20:05:42 +0200
From: Eric Dumazet <edumazet@...gle.com>
To: Alexander Lobakin <aleksander.lobakin@...el.com>
Cc: Yajun Deng <yajun.deng@...ux.dev>, davem@...emloft.net,
kuba@...nel.org, pabeni@...hat.com, horms@...nel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net/core: Export dev_core_stats_rx_dropped_inc sets
On Tue, Sep 12, 2023 at 8:03 PM Eric Dumazet <edumazet@...gle.com> wrote:
> Sure, this was what was suggested (perhaps not _very_ precisely, but
> the general idea was pretty clear).
> v2 seems ok, right ?
>
> It seems we are all on the same page.
>
> +static __cold struct net_device_core_stats __percpu
> *dev_core_stats(struct net_device *dev)
> +{
> + /* This READ_ONCE() pairs with the write in netdev_core_stats_alloc() */
> + struct net_device_core_stats __percpu *p = READ_ONCE(dev->core_stats);
> +
> + if (likely(p))
> + return p;
> +
> + return netdev_core_stats_alloc(dev);
> +}
> +
> +#define DEV_CORE_STATS_INC(FIELD) \
> +void dev_core_stats_##FIELD##_inc(struct net_device *dev) \
> +{ \
> + struct net_device_core_stats __percpu *p; \
> + \
> + p = dev_core_stats(dev); \
> + if (p) \
> + this_cpu_inc(p->FIELD); \
> +} \
> +EXPORT_SYMBOL(dev_core_stats_##FIELD##_inc)
Oh well, I just read the patch, and it seems wrong indeed.
netdev_core_stats_alloc() is the one that can be cold.
Powered by blists - more mailing lists