All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jisheng Zhang <jszhang@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lucas Stach" <l.stach@pengutronix.de>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Eric Dumazet" <edumazet@google.com>,
	"Samuel Holland" <samuel@sholland.org>,
	netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	linux-kernel@vger.kernel.org, "Chen-Yu Tsai" <wens@csie.org>,
	"Jose Abreu" <joabreu@synopsys.com>,
	kernel@pengutronix.de,
	"Giuseppe Cavallaro" <peppe.cavallaro@st.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	linux-sunxi@lists.linux.dev,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [REGRESSION] [PATCH net-next v5 2/2] net: stmmac: use per-queue 64 bit statistics where necessary
Date: Wed, 13 Sep 2023 22:34:42 +0800	[thread overview]
Message-ID: <ZQHIgmcnCNoZwtwu@xhacker> (raw)
In-Reply-To: <2fcc9fb0e40ceff8ea4ae55cca3ce0aff75a20ca.camel@sipsolutions.net>

On Tue, Sep 12, 2023 at 11:30:14AM +0200, Johannes Berg wrote:
> On Tue, 2023-09-12 at 11:24 +0200, Uwe Kleine-König wrote:
> > > 
> > > The newly added "struct u64_stats_sync syncp" uses a seqlock
> > > internally, which is broken into multiple words on 32bit machines, and
> > > needs to be initialized properly. You need to call u64_stats_init on
> > > syncp before first usage.
> > 
> > This is done. The problematic thing is that in stmmac_open() ->
> > __stmmac_open() the syncp initialized before is overwritten by
> > 
> > 	memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf));

Thank Johannes and Uwe for pointing out the issue.

> > 
> > Do I need to point out that this is ugly?
> 
> I think it also leaks the (lockdep) state since it reinits the syncp
> (and a lot of other state) doing this. This is also called when the MTU
> changes.
> 
> Also, I couldn't convince myself that it's even race-free? Even if it
> is, it's not really obvious, IMHO.
> 
> So it seems to me that really this needs to be split into data that
> actually should be reinitialized, and data that shouldn't, or just not
> use memcpy() here but copy only the relevant state?

Since we are in rc1, I need to fix the bug with as small changes as
possible. so another solution could be: replace rx/tx stats structure
with pointers, then setup pointers in the new allocated dma_conf with
the old one as current code did for dma_tx_size/dma_rx_size in
stmmac_setup_dma_desc():

dma_conf->dma_tx_size = priv->dma_conf.dma_tx_size

Is it acceptable?

Thanks

> 
> But anyway, I have no skin in this game - just reviewing this because I
> was trying to help out Uwe.
> 
> johannes

WARNING: multiple messages have this Message-ID (diff)
From: Jisheng Zhang <jszhang@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lucas Stach" <l.stach@pengutronix.de>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Eric Dumazet" <edumazet@google.com>,
	"Samuel Holland" <samuel@sholland.org>,
	netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	linux-kernel@vger.kernel.org, "Chen-Yu Tsai" <wens@csie.org>,
	"Jose Abreu" <joabreu@synopsys.com>,
	kernel@pengutronix.de,
	"Giuseppe Cavallaro" <peppe.cavallaro@st.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	linux-sunxi@lists.linux.dev,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [REGRESSION] [PATCH net-next v5 2/2] net: stmmac: use per-queue 64 bit statistics where necessary
Date: Wed, 13 Sep 2023 22:34:42 +0800	[thread overview]
Message-ID: <ZQHIgmcnCNoZwtwu@xhacker> (raw)
In-Reply-To: <2fcc9fb0e40ceff8ea4ae55cca3ce0aff75a20ca.camel@sipsolutions.net>

On Tue, Sep 12, 2023 at 11:30:14AM +0200, Johannes Berg wrote:
> On Tue, 2023-09-12 at 11:24 +0200, Uwe Kleine-König wrote:
> > > 
> > > The newly added "struct u64_stats_sync syncp" uses a seqlock
> > > internally, which is broken into multiple words on 32bit machines, and
> > > needs to be initialized properly. You need to call u64_stats_init on
> > > syncp before first usage.
> > 
> > This is done. The problematic thing is that in stmmac_open() ->
> > __stmmac_open() the syncp initialized before is overwritten by
> > 
> > 	memcpy(&priv->dma_conf, dma_conf, sizeof(*dma_conf));

Thank Johannes and Uwe for pointing out the issue.

> > 
> > Do I need to point out that this is ugly?
> 
> I think it also leaks the (lockdep) state since it reinits the syncp
> (and a lot of other state) doing this. This is also called when the MTU
> changes.
> 
> Also, I couldn't convince myself that it's even race-free? Even if it
> is, it's not really obvious, IMHO.
> 
> So it seems to me that really this needs to be split into data that
> actually should be reinitialized, and data that shouldn't, or just not
> use memcpy() here but copy only the relevant state?

Since we are in rc1, I need to fix the bug with as small changes as
possible. so another solution could be: replace rx/tx stats structure
with pointers, then setup pointers in the new allocated dma_conf with
the old one as current code did for dma_tx_size/dma_rx_size in
stmmac_setup_dma_desc():

dma_conf->dma_tx_size = priv->dma_conf.dma_tx_size

Is it acceptable?

Thanks

> 
> But anyway, I have no skin in this game - just reviewing this because I
> was trying to help out Uwe.
> 
> johannes

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-09-13 14:46 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 16:06 [PATCH net-next v5 0/2] net: stmmac: improve driver statistics Jisheng Zhang
2023-07-17 16:06 ` Jisheng Zhang
2023-07-17 16:06 ` [PATCH net-next v5 1/2] net: stmmac: don't clear network statistics in .ndo_open() Jisheng Zhang
2023-07-17 16:06   ` Jisheng Zhang
2023-07-17 16:06 ` [PATCH net-next v5 2/2] net: stmmac: use per-queue 64 bit statistics where necessary Jisheng Zhang
2023-07-17 16:06   ` Jisheng Zhang
2023-09-11 17:11   ` [REGRESSION] " Uwe Kleine-König
2023-09-11 17:11     ` Uwe Kleine-König
2023-09-12  8:01     ` Jisheng Zhang
2023-09-12  8:01       ` Jisheng Zhang
2023-09-12  9:04       ` Lucas Stach
2023-09-12  9:04         ` Lucas Stach
2023-09-12  9:24         ` Uwe Kleine-König
2023-09-12  9:24           ` Uwe Kleine-König
2023-09-12  9:30           ` Johannes Berg
2023-09-12  9:30             ` Johannes Berg
2023-09-13 14:34             ` Jisheng Zhang [this message]
2023-09-13 14:34               ` Jisheng Zhang
2023-09-13 14:49               ` Johannes Berg
2023-09-13 14:49                 ` Johannes Berg
2023-09-13 20:12               ` Uwe Kleine-König
2023-09-13 20:12                 ` Uwe Kleine-König
2023-09-12  8:23     ` Jisheng Zhang
2023-09-12  8:23       ` Jisheng Zhang
2023-09-12  9:26       ` Uwe Kleine-König
2023-09-12  9:26         ` Uwe Kleine-König
2023-09-21 18:34   ` Guenter Roeck
2023-09-21 18:34     ` Guenter Roeck
2023-09-21 19:56     ` Uwe Kleine-König
2023-09-21 19:56       ` Uwe Kleine-König
2023-09-21 20:14       ` Guenter Roeck
2023-09-21 20:14         ` Guenter Roeck
2023-07-19  1:01 ` [PATCH net-next v5 0/2] net: stmmac: improve driver statistics Jakub Kicinski
2023-07-19  1:01   ` Jakub Kicinski
2023-07-20  4:00 ` patchwork-bot+netdevbpf
2023-07-20  4:00   ` patchwork-bot+netdevbpf

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=ZQHIgmcnCNoZwtwu@xhacker \
    --to=jszhang@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=joabreu@synopsys.com \
    --cc=johannes@sipsolutions.net \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=l.stach@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peppe.cavallaro@st.com \
    --cc=samuel@sholland.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=wens@csie.org \
    /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.