From: Stephen Hemminger <stephen@networkplumber.org>
To: Saeed Mahameed <saeedm@mellanox.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Gal Pressman <galp@mellanox.com>
Subject: Re: [net-next 04/13] net/mlx5e: Vxlan, replace spinlock with read-write lock
Date: Fri, 27 Jul 2018 14:48:00 -0700 [thread overview]
Message-ID: <20180727144800.1065a3fd@xeon-e3> (raw)
In-Reply-To: <20180727211518.1916-5-saeedm@mellanox.com>
On Fri, 27 Jul 2018 14:15:09 -0700
Saeed Mahameed <saeedm@mellanox.com> wrote:
> From: Gal Pressman <galp@mellanox.com>
>
> The VXLAN database is mainly used by readers in data path, and rarely
> used by control path writers.
> Multiple readers (threads) should not block each other and cause an
> unnecessary contention on the lock.
>
> Replacing the spinlock with rwlock optimizes the common use case where
> adding ports to the table (adding VXLAN interfaces) is quite rare, but
> the table is accessed for each VXLAN TX skb.
>
> Signed-off-by: Gal Pressman <galp@mellanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Did you know that for small sections a spinlock is significantly faster than
a reader-writer lock. It turns out that reader-writer locks the reader
creates a cache line bounce.
https://www.kernel.org/doc/Documentation/locking/spinlocks.txt
Lesson 2: reader-writer spinlocks.
If your data accesses have a very natural pattern where you usually tend
to mostly read from the shared variables, the reader-writer locks
(rw_lock) versions of the spinlocks are sometimes useful. They allow multiple
readers to be in the same critical region at once, but if somebody wants
to change the variables it has to get an exclusive write lock.
NOTE! reader-writer locks require more atomic memory operations than
simple spinlocks. Unless the reader critical section is long, you
are better off just using spinlocks.
next prev parent reply other threads:[~2018-07-27 23:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-27 21:15 [pull request][net-next 00/13] Mellanox, mlx5 updates 2018-07-27 (Vxlan updates) Saeed Mahameed
2018-07-27 21:15 ` [net-next 01/13] net/mlx5e: Vxlan, reflect 4789 UDP port default addition to software database Saeed Mahameed
2018-07-27 21:15 ` [net-next 02/13] net/mlx5e: Vxlan, check maximum number of UDP ports Saeed Mahameed
2018-07-27 21:15 ` [net-next 03/13] net/mlx5e: Vxlan, replace ports radix-tree with hash table Saeed Mahameed
2018-07-27 21:15 ` [net-next 04/13] net/mlx5e: Vxlan, replace spinlock with read-write lock Saeed Mahameed
2018-07-27 21:48 ` Stephen Hemminger [this message]
2018-07-27 22:29 ` Saeed Mahameed
2018-07-27 21:15 ` [net-next 05/13] net/mlx5e: Vxlan, cleanup an unused member in vxlan work Saeed Mahameed
2018-07-27 21:15 ` [net-next 06/13] net/mlx5e: Vxlan, add direct delete function Saeed Mahameed
2018-07-27 21:15 ` [net-next 07/13] net/mlx5e: Vxlan, move netdev only logic to en_main.c Saeed Mahameed
2018-07-27 21:15 ` [net-next 08/13] net/mlx5e: Vxlan, rename struct mlx5e_vxlan to mlx5_vxlan_port Saeed Mahameed
2018-07-27 21:15 ` [net-next 09/13] net/mlx5e: Vxlan, rename from mlx5e to mlx5 Saeed Mahameed
2018-07-27 21:15 ` [net-next 10/13] net/mlx5e: Vxlan, return values for add/del port Saeed Mahameed
2018-07-27 21:15 ` [net-next 11/13] net/mlx5e: Vxlan, add sync lock for add/del vxlan port Saeed Mahameed
2018-07-27 21:15 ` [net-next 12/13] net/mlx5e: Vxlan, move vxlan logic to core driver Saeed Mahameed
2018-07-27 21:15 ` [net-next 13/13] net/mlx5e: Issue direct lookup on vxlan ports by vport representors Saeed Mahameed
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=20180727144800.1065a3fd@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=davem@davemloft.net \
--cc=galp@mellanox.com \
--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