From: Eric Dumazet <eric.dumazet@gmail.com>
To: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC PATCH] net: add additional lock to qdisc to increase enqueue/dequeue fairness
Date: Wed, 24 Mar 2010 15:24:56 +0100 [thread overview]
Message-ID: <1269440696.3213.53.camel@edumazet-laptop> (raw)
In-Reply-To: <20100323202553.21598.10754.stgit@gitlad.jf.intel.com>
Le mardi 23 mars 2010 à 13:25 -0700, Alexander Duyck a écrit :
> The qdisc layer shows a significant issue when you start transmitting from
> multiple CPUs. The issue is that the transmit rate drops significantly, and I
> believe it is due to the fact that the spinlock is shared between the 1
> dequeue, and n-1 enqueue cpu threads. In order to improve this situation I am
> adding one additional lock which will need to be obtained during the enqueue
> portion of the path. This essentially allows sch_direct_xmit to jump to
> near the head of the line when attempting to obtain the lock after
> completing a transmit.
>
This two stages lock permits to dequeue cpu to have 50% of chance to get
q.lock, since all other cpus (but one) are competing in enqueue_lock.
> Running the script below I saw an increase from 200K packets per second to
> 1.07M packets per second as a result of this patch.
>
> for j in `seq 0 15`; do
> for i in `seq 0 7`; do
> netperf -H <ip> -t UDP_STREAM -l 600 -N -T $i -- -m 6 &
> done
> done
>
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> ---
>
> include/net/sch_generic.h | 3 ++-
> net/core/dev.c | 7 ++++++-
> net/sched/sch_generic.c | 1 +
> 3 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
> index 67dc08e..f5088a9 100644
> --- a/include/net/sch_generic.h
> +++ b/include/net/sch_generic.h
> @@ -51,7 +51,6 @@ struct Qdisc {
> struct list_head list;
> u32 handle;
> u32 parent;
> - atomic_t refcnt;
> struct gnet_stats_rate_est rate_est;
> int (*reshape_fail)(struct sk_buff *skb,
> struct Qdisc *q);
> @@ -65,6 +64,8 @@ struct Qdisc {
> struct netdev_queue *dev_queue;
> struct Qdisc *next_sched;
>
> + atomic_t refcnt;
> + spinlock_t enqueue_lock;
> struct sk_buff *gso_skb;
> /*
Could you at least try to not fill the hole, but place enqueue_lock
right after "struct sk_buff_head q;" ?
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 67dc08e..6079c70 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -71,6 +71,7 @@ struct Qdisc {
*/
unsigned long state;
struct sk_buff_head q;
+ spinlock_t enqueue_lock;
struct gnet_stats_basic_packed bstats;
struct gnet_stats_queue qstats;
};
So that on x86_64, all these fields use one cache line instead of two.
offsetof(struct Qdisc, state)=0x80
offsetof(struct Qdisc, q)=0x88
offsetof(struct Qdisc, enqueue_lock)=0xa0
It would be nice to have a benchmark for non pathological cases (one cpu
doing a flood xmit of small packets)
next prev parent reply other threads:[~2010-03-24 14:25 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-23 20:25 [RFC PATCH] net: add additional lock to qdisc to increase enqueue/dequeue fairness Alexander Duyck
2010-03-23 20:31 ` David Miller
2010-03-24 2:12 ` Andi Kleen
2010-03-23 20:40 ` Rick Jones
2010-03-23 20:54 ` Eric Dumazet
2010-03-23 21:18 ` Eric Dumazet
2010-03-23 21:45 ` David Miller
2010-03-23 22:08 ` Duyck, Alexander H
2010-03-24 2:58 ` David Miller
2010-03-24 5:42 ` Eric Dumazet
2010-03-24 6:10 ` David Miller
2010-03-23 22:13 ` Eric Dumazet
2010-05-21 15:43 ` Stephen Hemminger
2010-05-21 16:44 ` Eric Dumazet
2010-05-21 17:38 ` Stephen Hemminger
2010-05-21 17:40 ` Eric Dumazet
2010-06-02 9:48 ` Eric Dumazet
2010-06-02 9:49 ` [PATCH 1/2 net-next-2.6] net: Define accessors to manipulate QDISC_STATE_RUNNING Eric Dumazet
2010-06-02 10:24 ` David Miller
2010-06-02 9:50 ` [PATCH 2/2 net-next-2.6] net: QDISC_STATE_RUNNING dont need atomic bit ops Eric Dumazet
2010-06-02 10:25 ` David Miller
2010-03-24 14:24 ` Eric Dumazet [this message]
2010-05-21 15:08 ` [PATCH] net: add additional lock to qdisc to increase throughput Eric Dumazet
2010-05-21 20:04 ` Duyck, Alexander H
2010-06-02 12:10 ` David Miller
2010-06-02 14:52 ` 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=1269440696.3213.53.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=alexander.h.duyck@intel.com \
--cc=netdev@vger.kernel.org \
/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