Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Shay Agroskin <shayagr@amazon.com>
Cc: Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
"Jubran, Samih" <sameehj@amazon.com>,
Andrew Lunn <andrew@lunn.ch>,
"davem@davemloft.net" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"Woodhouse, David" <dwmw@amazon.co.uk>,
"Machulsky, Zorik" <zorik@amazon.com>,
"Matushevsky, Alexander" <matua@amazon.com>,
"Bshara, Saeed" <saeedb@amazon.com>,
"Wilson, Matt" <msw@amazon.com>,
"Liguori, Anthony" <aliguori@amazon.com>,
"Bshara, Nafea" <nafea@amazon.com>,
"Tzalik, Guy" <gtzalik@amazon.com>,
"Belgazal, Netanel" <netanel@amazon.com>,
"Saidi, Ali" <alisaidi@amazon.com>,
"Herrenschmidt, Benjamin" <benh@amazon.com>,
"Kiyanovski, Arthur" <akiyano@amazon.com>,
"Dagan, Noam" <ndagan@amazon.com>
Subject: Re: [PATCH V2 net-next 1/4] net: ena: ethtool: use unsigned long for pointer arithmetics
Date: Sun, 6 Sep 2020 09:45:16 -0700 [thread overview]
Message-ID: <20200906094516.2f8ea69c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <pj41zlv9grp4ge.fsf@u68c7b5b1d2d758.ant.amazon.com>
On Sun, 6 Sep 2020 13:47:13 +0300 Shay Agroskin wrote:
> Maciej Fijalkowski <maciej.fijalkowski@intel.com> writes:
> > I don't want to stir up the pot, but do you really need the
> > offsetof() of
> > each member in the stats struct? Couldn't you piggyback on
> > assumption that
> > these stats need to be u64 and just walk the struct with
> > pointer?
> >
> > struct ena_ring *ring;
> > int offset;
> > int i, j;
> > u8 *ptr;
> >
> > for (i = 0; i < adapter->num_io_queues; i++) {
> > /* Tx stats */
> > ring = &adapter->tx_ring[i];
> > ptr = (u8 *)&ring->tx_stats;
> >
> > for (j = 0; j < ENA_STATS_ARRAY_TX; j++) {
> > ena_safe_update_stat((u64 *)ptr,
> > (*data)++, &ring->syncp);
> > ptr += sizeof(u64);
> > }
> > }
> >
> > I find this as a simpler and lighter solution. There might be
> > issues with
> > code typed in email client, but you get the idea.
> >
> >>
> >> of course we need to convert the stat_offset field to be in 8
> >> bytes resolution instead.
> >>
> >> This approach has a potential bug hidden in it. If in the
> >> future
> >> someone decides to expand the "ena_stats_tx" struct and add a
> >> field preceding cnt,
> >> cnt will no longer be the beginning of the struct, which will
> >> cause a bug."
> >>
> >> Therefore, if you have another way to do this, please share
> >> it. Otherwise I'd
> >> rather leave this code as it is for the sake of robustness.
> >>
> >> >
> >> > Andrew
>
> Hi all,
>
> We tried to implement your suggestion, and found that removing the
> stat_offset
> field causes problems that are challenging to solve.
> Removing stat_offset introduces a requirement that the statistics
> in a stat
> strings array (check [1] for example) and stat variables struct
> (check [2] for
> example) must be in the same order.
> This requirement is prone to future bugs that might be challenging
> to locate.
> We also tried to unify the array and struct creation by
> using X macros. At the moment this change requires more time and
> effort by us
> and our customers need this code merged asap.
>
> [1] https://elixir.bootlin.com/linux/v5.9-
> rc3/source/drivers/net/ethernet/amazon/ena/ena_ethtool.c#L71
> [2] https://elixir.bootlin.com/linux/v5.9-
> rc3/source/drivers/net/ethernet/amazon/ena/ena_netdev.h#L232
>
> (This message was sent before but didn't seem to get into the
> mailing list. Apologies if you got it twice)
Divide the offset by 8, cast &ring->tx_stats to u64 * (without
referencing cnt). That should be fine.
next prev parent reply other threads:[~2020-09-06 16:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 13:43 [PATCH V2 net-next 0/4] Enhance current features in ena driver sameehj
2020-08-19 13:43 ` [PATCH V2 net-next 1/4] net: ena: ethtool: use unsigned long for pointer arithmetics sameehj
2020-08-19 14:17 ` Andrew Lunn
2020-08-20 12:13 ` Jubran, Samih
2020-08-26 15:36 ` Maciej Fijalkowski
2020-09-06 10:47 ` Shay Agroskin
2020-09-06 16:45 ` Jakub Kicinski [this message]
2020-08-26 10:48 ` Jubran, Samih
2020-08-19 13:43 ` [PATCH V2 net-next 2/4] net: ena: ethtool: Add new device statistics sameehj
2020-08-19 14:18 ` Andrew Lunn
2020-08-19 13:43 ` [PATCH V2 net-next 3/4] net: ena: ethtool: add stats printing to XDP queues sameehj
2020-08-19 13:43 ` [PATCH V2 net-next 4/4] net: ena: xdp: add queue counters for xdp actions sameehj
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=20200906094516.2f8ea69c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
--to=kuba@kernel.org \
--cc=akiyano@amazon.com \
--cc=aliguori@amazon.com \
--cc=alisaidi@amazon.com \
--cc=andrew@lunn.ch \
--cc=benh@amazon.com \
--cc=davem@davemloft.net \
--cc=dwmw@amazon.co.uk \
--cc=gtzalik@amazon.com \
--cc=maciej.fijalkowski@intel.com \
--cc=matua@amazon.com \
--cc=msw@amazon.com \
--cc=nafea@amazon.com \
--cc=ndagan@amazon.com \
--cc=netanel@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=saeedb@amazon.com \
--cc=sameehj@amazon.com \
--cc=shayagr@amazon.com \
--cc=zorik@amazon.com \
--subject='Re: [PATCH V2 net-next 1/4] net: ena: ethtool: use unsigned long for pointer arithmetics' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).