lkml.org 
[lkml]   [2022]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next 07/12] net: dsa: rzn1-a5psw: add statistics support
> > > +static void a5psw_get_ethtool_stats(struct dsa_switch *ds, int port,
> > > + uint64_t *data)
> > > +{
> > > + struct a5psw *a5psw = ds->priv;
> > > + u32 reg_lo, reg_hi;
> > > + unsigned int u;
> > > +
> > > + for (u = 0; u < ARRAY_SIZE(a5psw_stats); u++) {
> > > + /* A5PSW_STATS_HIWORD is global and thus, access must be
> > > + * exclusive
> > > + */
> >
> > Could you explain that a bit more. The RTNL lock will prevent two
> > parallel calls to this function.
>
> Ok, I wasn't sure of the locking applicable here.

In general, RTNL protects you for any user space management like
operation on the driver. In this case, if you look in net/ethtool, you
will find the IOCTL handler code takes RTNL before calling into the
main IOCTL dispatcher. If you want to be paranoid/document the
assumption, you can add an ASSERT_RTNL().

The semantics for some of the other statistics Vladimir requested can
be slightly different. One of them is in atomic context, because a
spinlock is held. But i don't remember if RTNL is also held. This is
less of an issue for your switch, since it uses MMIO, however many
switches need to perform blocking IO over MDIO, SPI, IC2 etc to get
stats, which you cannot do in atomic context. So they end up returning
cached values.

Look in the mailing list for past discussion for details.

Andrew

\
 
 \ /
  Last update: 2022-04-15 15:38    [W:0.102 / U:1.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site