From: Saeed Mahameed <saeedm@mellanox.com>
To: "willemdebruijn.kernel@gmail.com" <willemdebruijn.kernel@gmail.com>
Cc: Roi Dayan <roid@mellanox.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Vlad Buslov <vladbu@mellanox.com>,
Jianbo Liu <jianbol@mellanox.com>
Subject: Re: [net-next 08/13] net/mlx5e: Protect tc flows hashtable with rcu
Date: Tue, 30 Jul 2019 20:09:33 +0000 [thread overview]
Message-ID: <f0e4d9fbcdba0ed19fc3494a29cf70ae2702e727.camel@mellanox.com> (raw)
In-Reply-To: <CAF=yD-LgfHTJrfyaVfokKkZWwPpz4uxYDKA11+jgO5rAq1LamA@mail.gmail.com>
On Tue, 2019-07-30 at 12:37 -0400, Willem de Bruijn wrote:
> On Tue, Jul 30, 2019 at 12:16 PM Willem de Bruijn
> <willemdebruijn.kernel@gmail.com> wrote:
> > On Mon, Jul 29, 2019 at 7:50 PM Saeed Mahameed <saeedm@mellanox.com
> > > wrote:
> > > From: Vlad Buslov <vladbu@mellanox.com>
> > >
> > > In order to remove dependency on rtnl lock, access to tc flows
> > > hashtable
> > > must be explicitly protected from concurrent flows removal.
> > >
> > > Extend tc flow structure with rcu to allow concurrent parallel
> > > access. Use
> > > rcu read lock to safely lookup flow in tc flows hash table, and
> > > take
> > > reference to it. Use rcu free for flow deletion to accommodate
> > > concurrent
> > > stats requests.
> > >
> > > Add new DELETED flow flag. Imlement new flow_flag_test_and_set()
> > > helper
> > > that is used to set a flag and return its previous value. Use it
> > > to
> > > atomically set the flag in mlx5e_delete_flower() to guarantee
> > > that flow can
> > > only be deleted once, even when same flow is deleted concurrently
> > > by
> > > multiple tasks.
> > >
> > > Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
> > > Reviewed-by: Jianbo Liu <jianbol@mellanox.com>
> > > Reviewed-by: Roi Dayan <roid@mellanox.com>
> > > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> > > ---
> > > @@ -3492,16 +3507,32 @@ int mlx5e_delete_flower(struct net_device
> > > *dev, struct mlx5e_priv *priv,
> > > {
> > > struct rhashtable *tc_ht = get_tc_ht(priv, flags);
> > > struct mlx5e_tc_flow *flow;
> > > + int err;
> > >
> > > + rcu_read_lock();
> > > flow = rhashtable_lookup_fast(tc_ht, &f->cookie,
> > > tc_ht_params);
> > > - if (!flow || !same_flow_direction(flow, flags))
> > > - return -EINVAL;
> > > + if (!flow || !same_flow_direction(flow, flags)) {
> > > + err = -EINVAL;
> > > + goto errout;
> > > + }
> > >
> > > + /* Only delete the flow if it doesn't have
> > > MLX5E_TC_FLOW_DELETED flag
> > > + * set.
> > > + */
> > > + if (flow_flag_test_and_set(flow, DELETED)) {
> > > + err = -EINVAL;
> > > + goto errout;
> > > + }
> > > rhashtable_remove_fast(tc_ht, &flow->node, tc_ht_params);
> > > + rcu_read_unlock();
> > >
> > > mlx5e_flow_put(priv, flow);
> >
> > Dereferencing flow outside rcu readside critical section? Does a
> > build
> > with lockdep not complain?
>
> Eh no, it won't. The surprising part to me was to use a readside
> critical section when performing a write action on an RCU ptr. The
> DELETED flag ensures that multiple writers will not compete to call
> rhashtable_remove_fast. rcu_read_lock is a common pattern to do
> rhashtable lookup + delete.
>
correct.
next prev parent reply other threads:[~2019-07-30 20:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 23:50 [pull request][net-next 00/13] Mellanox, mlx5 tc flow handling for concurrent execution (Part 1) Saeed Mahameed
2019-07-29 23:50 ` [net-next 01/13] net/mlx5e: Print a warning when LRO feature is dropped or not allowed Saeed Mahameed
2019-07-30 15:52 ` Willem de Bruijn
2019-07-30 20:07 ` Saeed Mahameed
2019-07-30 21:34 ` Willem de Bruijn
2019-07-29 23:50 ` [net-next 02/13] net/mlx5e: Avoid warning print when not required Saeed Mahameed
2019-07-29 23:50 ` [net-next 03/13] net/mlx5e: Improve ethtool rxnfc callback structure Saeed Mahameed
2019-07-29 23:50 ` [net-next 04/13] net/mlx5e: Fix unnecessary flow_block_cb_is_busy call Saeed Mahameed
2019-07-29 23:50 ` [net-next 05/13] net/mlx5e: Simplify get_route_and_out_devs helper function Saeed Mahameed
2019-07-29 23:50 ` [net-next 06/13] net/mlx5e: Extend tc flow struct with reference counter Saeed Mahameed
2019-07-29 23:50 ` [net-next 07/13] net/mlx5e: Change flow flags type to unsigned long Saeed Mahameed
2019-07-29 23:50 ` [net-next 08/13] net/mlx5e: Protect tc flows hashtable with rcu Saeed Mahameed
2019-07-30 16:15 ` Willem de Bruijn
2019-07-30 16:37 ` Willem de Bruijn
2019-07-30 20:09 ` Saeed Mahameed [this message]
2019-07-29 23:50 ` [net-next 09/13] net/mlx5e: Protect unready flows with dedicated lock Saeed Mahameed
2019-07-29 23:50 ` [net-next 10/13] net/mlx5e: Eswitch, change offloads num_flows type to atomic64 Saeed Mahameed
2019-07-29 23:50 ` [net-next 11/13] net/mlx5e: Eswitch, use state_lock to synchronize vlan change Saeed Mahameed
2019-07-29 23:50 ` [net-next 12/13] net/mlx5e: Rely on rcu instead of rtnl lock when getting upper dev Saeed Mahameed
2019-07-29 23:50 ` [net-next 13/13] net/mlx5e: Protect tc flow table with mutex Saeed Mahameed
2019-07-31 22:48 ` [pull request][net-next 00/13] Mellanox, mlx5 tc flow handling for concurrent execution (Part 1) David Miller
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=f0e4d9fbcdba0ed19fc3494a29cf70ae2702e727.camel@mellanox.com \
--to=saeedm@mellanox.com \
--cc=davem@davemloft.net \
--cc=jianbol@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=roid@mellanox.com \
--cc=vladbu@mellanox.com \
--cc=willemdebruijn.kernel@gmail.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