netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: saeedm@mellanox.com
Cc: netdev@vger.kernel.org
Subject: Re: [RFC net-next 1/2] net: net-porcfs: Reduce rcu lock critical section
Date: Tue, 10 Apr 2018 13:16:49 -0400 (EDT)	[thread overview]
Message-ID: <20180410.131649.583776764903333305.davem@davemloft.net> (raw)
In-Reply-To: <20180410170812.18905-1-saeedm@mellanox.com>

From: Saeed Mahameed <saeedm@mellanox.com>
Date: Tue, 10 Apr 2018 10:08:11 -0700

> The current net proc fs sequence file implementation to show current
> namespace netdevs list statistics and mc lists holds the rcu lock
> throughout the whole process, from dev seq start up to dev seq stop.
> 
> This is really greedy and demanding from device drivers since
> ndo_get_stats64 called from dev_seq_show while the rcu lock is held.
> 
> The rcu lock is needed to guarantee that device chain is not modified
> while the dev sequence file is walking through it and handling the
> netdev in the same time.
> 
> To minimize this critical section and drastically reduce the time rcu lock
> is being held, all we need is to grab the rcu lock only for the brief
> moment where we are looking for the next netdev to handle, if found,
> dev_hold it to guarantee it kept alive while accessed later in seq show
> callback and release the rcu lock immediately.
> 
> The current netdev being handled will be released "dev_put" when the seq next
> callback is called or dev seq stop is called.
> 
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

The tradeoff here is that now you are doing two unnecessary atomic
operations per stats dump.

That is what the RCU lock allows us to avoid.

  parent reply	other threads:[~2018-04-10 17:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 17:08 [RFC net-next 1/2] net: net-porcfs: Reduce rcu lock critical section Saeed Mahameed
2018-04-10 17:08 ` [RFC net-next 2/2] net: net-sysfs: Reduce netstat_show read_lock " Saeed Mahameed
2018-04-10 17:17   ` David Miller
2018-04-10 17:16 ` David Miller [this message]
2018-04-10 20:35   ` [RFC net-next 1/2] net: net-porcfs: Reduce rcu lock " Eric Dumazet
2018-04-11 18:59     ` Saeed Mahameed
2018-04-11 22:30       ` Eric Dumazet
2018-04-11 23:47         ` Saeed Mahameed
2018-04-12  2:59           ` Eric Dumazet
2018-04-12 19:12             ` Saeed Mahameed
2018-04-16 20:50               ` Saeed Mahameed
2018-04-16 21:07                 ` Eric Dumazet

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=20180410.131649.583776764903333305.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@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).