From: Cong Wang <xiyou.wangcong@gmail.com>
To: Saeed Mahameed <saeedm@mellanox.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Tariq Toukan <tariqt@mellanox.com>
Subject: Re: [Patch net-next] mlx5: use RCU lock in mlx5_eq_cq_get()
Date: Wed, 6 Feb 2019 09:15:32 -0800 [thread overview]
Message-ID: <CAM_iQpW5GQD8PS1d34tNF5Dfd63pTJDfz_5kJWyqJOOrAMdU7g@mail.gmail.com> (raw)
In-Reply-To: <e88ac12b80b510648f7ab1d4cee50c43908ba49d.camel@mellanox.com>
On Wed, Feb 6, 2019 at 8:55 AM Saeed Mahameed <saeedm@mellanox.com> wrote:
> Hi Cong,
>
> The patch is ok to me, but i really doubt that you can hit a contention
> on latest upstream driver, since we already have spinlock per EQ, which
> means spinlock per core, each EQ (core) msix handler can only access
> one spinlock (its own), so I am surprised how you got the contention,
> Maybe you are not running on latest upstream driver ?
We are running 4.14 stable release. Which commit changes the game
here? We can consider to backport it unless it is complicated.
Also, if you don't like this patch, we are happy to carry it for our own,
sometimes it isn't worth the time to push into upstream.
>
> what is the workload ?
>
It's a memcached RPC performance test, that is all I can tell.
(Apparently I have almost zero knowledge about memcached.)
> > > In fact, radix_tree_lookup() is perfectly fine with RCU read lock,
> > > we don't have to take a spinlock on this hot path. It is pretty
> > > much
> > > similar to commit 291c566a2891
> > > ("net/mlx4_core: Fix racy CQ (Completion Queue) free"). Slow paths
> > > are still serialized with the spinlock, and with synchronize_irq()
> > > it should be safe to just move the fast path to RCU read lock.
> > >
> > > This patch itself reduces the latency by about 50% with our
> > > workload.
> > >
> > > Cc: Saeed Mahameed <saeedm@mellanox.com>
> > > Cc: Tariq Toukan <tariqt@mellanox.com>
> > > Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> > > ---
> > > drivers/net/ethernet/mellanox/mlx5/core/eq.c | 12 ++++++------
> > > 1 file changed, 6 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> > > b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> > > index ee04aab65a9f..7092457705a2 100644
> > > --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> > > +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
> > > @@ -114,11 +114,11 @@ static struct mlx5_core_cq
> > > *mlx5_eq_cq_get(struct mlx5_eq *eq, u32 cqn)
> > > struct mlx5_cq_table *table = &eq->cq_table;
> > > struct mlx5_core_cq *cq = NULL;
> > >
> > > - spin_lock(&table->lock);
> > > + rcu_read_lock();
> > > cq = radix_tree_lookup(&table->tree, cqn);
> > > if (likely(cq))
> > > mlx5_cq_hold(cq);
> > > - spin_unlock(&table->lock);
> > > + rcu_read_unlock();
> >
> > Thanks for you patch.
> >
> > I think we can improve it further, by taking the if statement out of
> > the
> > critical section.
> >
>
> No, mlx5_cq_hold must stay under RCU read, otherwise cq might get freed
> before the irq gets a change to increment ref count on it.
>
Agreed.
Thanks.
next prev parent reply other threads:[~2019-02-06 17:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-06 0:35 [Patch net-next] mlx5: use RCU lock in mlx5_eq_cq_get() Cong Wang
2019-02-06 12:02 ` Tariq Toukan
2019-02-06 16:55 ` Saeed Mahameed
2019-02-06 17:15 ` Cong Wang [this message]
2019-02-06 17:35 ` Saeed Mahameed
2019-02-06 17:43 ` Cong Wang
2019-02-06 17:17 ` Eric Dumazet
2019-02-06 17:37 ` Saeed Mahameed
2019-02-06 17:35 ` Saeed Mahameed
2019-02-06 17:40 ` Saeed Mahameed
2019-02-06 22:51 ` Cong Wang
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=CAM_iQpW5GQD8PS1d34tNF5Dfd63pTJDfz_5kJWyqJOOrAMdU7g@mail.gmail.com \
--to=xiyou.wangcong@gmail.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).