From: Jakub Kicinski <kuba@kernel.org>
To: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>, <davem@davemloft.net>,
<pabeni@redhat.com>, <edumazet@google.com>,
<netdev@vger.kernel.org>, <przemyslaw.kitszel@intel.com>,
<joshua.a.hay@intel.com>, <michal.kubiak@intel.com>,
<nex.sw.ncis.osdt.itp.upstreaming@intel.com>
Subject: Re: [PATCH net-next v2 2/9] libeth: add common queue stats
Date: Thu, 22 Aug 2024 16:17:18 -0700 [thread overview]
Message-ID: <20240822161718.22a1840e@kernel.org> (raw)
In-Reply-To: <613fb55f-b754-433a-9f27-7c66391116d9@intel.com>
On Thu, 22 Aug 2024 17:13:57 +0200 Alexander Lobakin wrote:
> > BTW for Intel? Or you want this to be part of the core?
> > I thought Intel, but you should tell us if you have broader plans.
>
> For now it's done as a lib inside Intel folder, BUT if any other vendor
> would like to use this, that would be great and then we could move it
> level up or some of these APIs can go into the core.
> IOW depends on users.
>
> libie in contrary contains HW-specific code and will always be
> Intel-specific.
Seems like an odd middle ground. If you believe it's generic finding
another driver shouldn't be hard.
> >> + const struct libeth_netdev_priv *priv = netdev_priv(dev); \
> >> + \
> >> + memset(stats, 0, sizeof(*stats)); \
> >> + u64_stats_init(&stats->syncp); \
> >> + \
> >> + mutex_init(&priv->base_##pfx##s[qid].lock); \
> >
> > the mutex is only for writes or for reads of base too?
> > mutex is a bad idea for rtnl stats
>
> Base stats are written only on ifdown, read anytime, mutex is used
> everywhere.
> Hmm maybe a bad idea, what would be better, spinlock or just use
> u64_sync as well?
Depends quite a bit on whether driver uses per queues stats to get
rtnl stats. And whether reading of the stats needs to sleep.
> >> +#define LIBETH_STATS_DEFINE_EXPORT(pfx, gpfx) \
> >> +static void \
> >> +libeth_get_queue_stats_##gpfx(struct net_device *dev, int idx, \
> >> + struct netdev_queue_stats_##gpfx *stats) \
> >> +{ \
> >> + const struct libeth_netdev_priv *priv = netdev_priv(dev); \
> >> + const struct libeth_##pfx##_stats *qs; \
> >> + u64 *raw = (u64 *)stats; \
> >> + u32 start; \
> >> + \
> >> + qs = READ_ONCE(priv->live_##pfx##s[idx]); \
> >> + if (!qs) \
> >> + return; \
> >> + \
> >> + do { \
> >> + start = u64_stats_fetch_begin(&qs->syncp); \
> >> + \
> >> + libeth_stats_foreach_export(pfx, exp) \
> >> + raw[exp->gi] = u64_stats_read(&qs->raw[exp->li]); \
> >> + } while (u64_stats_fetch_retry(&qs->syncp, start)); \
> >> +} \
> >
> > ugh. Please no
>
> So you mean just open-code reads/writes per each field than to compress
> it that way?
Yes. <rant> I don't understand why people try to be clever and
complicate stats reading for minor LoC saving (almost everyone,
including those working on fbnic). Just type the code in -- it
makes maintaining it, grepping and adding a new stat without
remembering all the details soo much easier. </rant>
> Sure, that would be no problem. Object code doesn't even
> change (my first approach was per-field).
>
> >> + \
> >> +static void \
> >> +libeth_get_##pfx##_base_stats(const struct net_device *dev, \
> >> + struct netdev_queue_stats_##gpfx *stats) \
> >> +{ \
> >> + const struct libeth_netdev_priv *priv = netdev_priv(dev); \
> >> + u64 *raw = (u64 *)stats; \
> >> + \
> >> + memset(stats, 0, sizeof(*(stats))); \
> >
> > Have you read the docs for any of the recent stats APIs?
>
> You mean to leave 0xffs for unsupported fields?
Kinda of. But also I do mean to call out that you haven't read the doc
for the interface over which you're building an abstraction 😵💫️
> > Nack. Just implement the APIs in the driver, this does not seem like
> > a sane starting point _at all_. You're going to waste more time coming
> > up with such abstraction than you'd save implementing it for 10 drivers.
>
> I believe this nack is for generic Netlink stats, not the whole, right?
> In general, I wasn't sure about whether it would be better to leave
> Netlink stats per driver or write it in libeth, so I wanted to see
> opinions of others. I'm fine with either way.
We (I?) keep pushing more and more stats into the generic definitions,
mostly as I find clear need for them in Meta's monitoring system.
My main concern is that if you hide the stats collecting in a library
it will make ensuring the consistency of the definition much harder,
and it will propagate the use of old APIs (dreaded ethtool -S) into new
drivers.
If you have useful helpers that can be broadly applicable that's great.
This library as it stands will need a lot of work and a lot of
convincing to go in.
next prev parent reply other threads:[~2024-08-22 23:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 22:34 [PATCH net-next v2 0/9][pull request] idpf: XDP chapter II: convert Tx completion to libeth Tony Nguyen
2024-08-19 22:34 ` [PATCH net-next v2 1/9] unroll: add generic loop unroll helpers Tony Nguyen
2024-08-21 0:55 ` Jakub Kicinski
2024-08-22 15:15 ` Alexander Lobakin
2024-08-22 22:59 ` Jakub Kicinski
2024-08-22 23:35 ` Tony Nguyen
2024-08-23 12:37 ` Alexander Lobakin
2024-08-19 22:34 ` [PATCH net-next v2 2/9] libeth: add common queue stats Tony Nguyen
2024-08-21 1:17 ` Jakub Kicinski
2024-08-22 15:13 ` Alexander Lobakin
2024-08-22 23:17 ` Jakub Kicinski [this message]
2024-08-23 12:59 ` Alexander Lobakin
2024-08-27 1:09 ` Jakub Kicinski
2024-08-27 15:31 ` Alexander Lobakin
2024-08-27 18:29 ` Jakub Kicinski
2024-08-28 15:06 ` Alexander Lobakin
2024-08-28 20:22 ` Jakub Kicinski
2024-08-29 12:01 ` Alexander Lobakin
2024-08-29 14:39 ` Jakub Kicinski
2024-08-19 22:34 ` [PATCH net-next v2 3/9] libie: add Tx buffer completion helpers Tony Nguyen
2024-08-19 22:34 ` [PATCH net-next v2 4/9] idpf: convert to libie Tx buffer completion Tony Nguyen
2024-08-19 22:34 ` [PATCH net-next v2 5/9] netdevice: add netdev_tx_reset_subqueue() shorthand Tony Nguyen
2024-08-19 22:34 ` [PATCH net-next v2 6/9] idpf: refactor Tx completion routines Tony Nguyen
2024-08-19 22:34 ` [PATCH net-next v2 7/9] idpf: fix netdev Tx queue stop/wake Tony Nguyen
2024-08-19 22:34 ` [PATCH net-next v2 8/9] idpf: enable WB_ON_ITR Tony Nguyen
2024-08-19 22:34 ` [PATCH net-next v2 9/9] idpf: switch to libeth generic statistics Tony Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240822161718.22a1840e@kernel.org \
--to=kuba@kernel.org \
--cc=aleksander.lobakin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joshua.a.hay@intel.com \
--cc=michal.kubiak@intel.com \
--cc=netdev@vger.kernel.org \
--cc=nex.sw.ncis.osdt.itp.upstreaming@intel.com \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.