diff options
author | Jesper Dangaard Brouer <brouer@redhat.com> | 2014-06-26 07:16:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-01 18:50:23 -0400 |
commit | baac167b706600ebe7158acaeb7c489ae9d0bb8b (patch) | |
tree | e7fe4f63eb410252d15ef5536e97a4adc08fc881 /net/core | |
parent | 9ceb87fceacca86a37f189b84b79797c313b0c03 (diff) |
pktgen: avoid expensive set_current_state() call in loop
Avoid calling set_current_state() inside the busy-loop in
pktgen_thread_worker(). In case of pkt_dev->delay, then it is still
used/enabled in pktgen_xmit() via the spin() call.
The set_current_state(TASK_INTERRUPTIBLE) uses a xchg, which implicit
is LOCK prefixed. I've measured the asm LOCK operation to take approx
8ns on this E5-2630 CPU. Performance increase corrolate with this
measurement.
Performance data with CLONE_SKB==100000, rx-usecs=30:
(single CPU performance, ixgbe 10Gbit/s, E5-2630)
* Prev: 5454050 pps --> 183.35ns (1/5454050*10^9)
* Now: 5684009 pps --> 175.93ns (1/5684009*10^9)
* Diff: +229959 pps --> -7.42ns
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/pktgen.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index fc17a9d309ac..b61f553689b6 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -3407,10 +3407,10 @@ static int pktgen_thread_worker(void *arg) | |||
3407 | 3407 | ||
3408 | pr_debug("starting pktgen/%d: pid=%d\n", cpu, task_pid_nr(current)); | 3408 | pr_debug("starting pktgen/%d: pid=%d\n", cpu, task_pid_nr(current)); |
3409 | 3409 | ||
3410 | set_current_state(TASK_INTERRUPTIBLE); | ||
3411 | |||
3412 | set_freezable(); | 3410 | set_freezable(); |
3413 | 3411 | ||
3412 | __set_current_state(TASK_RUNNING); | ||
3413 | |||
3414 | while (!kthread_should_stop()) { | 3414 | while (!kthread_should_stop()) { |
3415 | pkt_dev = next_to_run(t); | 3415 | pkt_dev = next_to_run(t); |
3416 | 3416 | ||
@@ -3424,8 +3424,6 @@ static int pktgen_thread_worker(void *arg) | |||
3424 | continue; | 3424 | continue; |
3425 | } | 3425 | } |
3426 | 3426 | ||
3427 | __set_current_state(TASK_RUNNING); | ||
3428 | |||
3429 | if (likely(pkt_dev)) { | 3427 | if (likely(pkt_dev)) { |
3430 | pktgen_xmit(pkt_dev); | 3428 | pktgen_xmit(pkt_dev); |
3431 | 3429 | ||
@@ -3456,9 +3454,8 @@ static int pktgen_thread_worker(void *arg) | |||
3456 | } | 3454 | } |
3457 | 3455 | ||
3458 | try_to_freeze(); | 3456 | try_to_freeze(); |
3459 | |||
3460 | set_current_state(TASK_INTERRUPTIBLE); | ||
3461 | } | 3457 | } |
3458 | set_current_state(TASK_INTERRUPTIBLE); | ||
3462 | 3459 | ||
3463 | pr_debug("%s stopping all device\n", t->tsk->comm); | 3460 | pr_debug("%s stopping all device\n", t->tsk->comm); |
3464 | pktgen_stop(t); | 3461 | pktgen_stop(t); |