From: Jason Gunthorpe <jgg@ziepe.ca>
To: Saeed Mahameed <saeedm@mellanox.com>
Cc: "eric.dumazet@gmail.com" <eric.dumazet@gmail.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"arnd@arndb.de" <arnd@arndb.de>,
"leon@kernel.org" <leon@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Moshe Shemesh <moshe@mellanox.com>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
Boris Pismenny <borisp@mellanox.com>,
Tariq Toukan <tariqt@mellanox.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
Eran Ben Elisha <eranbe@mellanox.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Ilya Lesokhin <ilyal@mellanox.com>,
Kamal Heib <kamalh@mellanox.com>
Subject: Re: [PATCH] net/mlx5e: fix high stack usage
Date: Fri, 2 Nov 2018 16:15:52 -0600 [thread overview]
Message-ID: <20181102221552.GC17096@ziepe.ca> (raw)
In-Reply-To: <4ebfc3aeb5335a1f671602f9a906f948c39a30da.camel@mellanox.com>
On Fri, Nov 02, 2018 at 10:07:02PM +0000, Saeed Mahameed wrote:
> On Fri, 2018-11-02 at 14:39 -0700, Eric Dumazet wrote:
> >
> > On 11/02/2018 02:05 PM, Saeed Mahameed wrote:
> >
> > > temp will be mem copied to priv->stats.sw at the end,
> > > memcpy(&priv->stats.sw, &s, sizeof(s));
> > >
> > > one other way to solve this as suggested by Andrew, is to get rid
> > > of
> > > the temp var and make it point directly to priv->stats.sw
> > >
> >
> > What about concurrency ?
> >
> > This temp variable is there to make sure concurrent readers of stats
> > might
> > not see mangle data (because another 'reader' just did a memset() and
> > is doing the folding)
> >
> >
> > mlx5e_get_stats() can definitely be run at the same time by multiple
> > threads.
> >
>
> hmm, you are right, i was thinking that mlx5e_get_Stats will trigger a
> work to update stats and grab the state_lock, but for sw stats this is
> not the case it is done in place.
That was my guess when I saw this.. the confusing bit is why is there
s and temp, why not just s?
> BTW memcpy itself is not thread safe.
At least on 64 bit memcpy will do > 8 byte stores when copying so on
most architectures it will cause individual new or old u64 to be
returned and not a mess..
32 bit will always make a mess.
If the stats don't update that often then kmalloc'ing a new buffer and
RCU'ing it into view might be a reasonable alternative to this?
Jason
next prev parent reply other threads:[~2018-11-02 22:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-02 15:33 [PATCH] net/mlx5e: fix high stack usage Arnd Bergmann
2018-11-02 16:08 ` Jason Gunthorpe
2018-11-02 16:23 ` Arnd Bergmann
2018-11-02 17:00 ` Jason Gunthorpe
2018-11-02 21:05 ` Saeed Mahameed
2018-11-02 21:39 ` Eric Dumazet
2018-11-02 22:07 ` Saeed Mahameed
2018-11-02 22:15 ` Arnd Bergmann
2018-11-03 0:52 ` Saeed Mahameed
2018-11-02 22:15 ` Jason Gunthorpe [this message]
2018-11-03 0:37 ` Saeed Mahameed
2018-11-05 11:24 ` David Laight
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=20181102221552.GC17096@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=borisp@mellanox.com \
--cc=davem@davemloft.net \
--cc=eranbe@mellanox.com \
--cc=eric.dumazet@gmail.com \
--cc=ilyal@mellanox.com \
--cc=kamalh@mellanox.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=moshe@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=tariqt@mellanox.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 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).