All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@plumgrid.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Eric Dumazet <edumazet@gmail.com>
Subject: Re: [PATCH net-next 6/6] net_sched: act: remove spinlock in fast path
Date: Thu, 02 Jul 2015 09:35:25 -0700	[thread overview]
Message-ID: <5595684D.90500@gmail.com> (raw)
In-Reply-To: <1435842455-30501-7-git-send-email-edumazet@google.com>

On 15-07-02 06:07 AM, Eric Dumazet wrote:
> Final step for gact RCU operation :
> 
> 1) Use percpu stats
> 2) update lastuse only every clock tick
> 3) Remove spinlock acquisition, as it is no longer needed.
> 
> Since this is the last contended lock in packet RX when tc gact is used,
> this gives impressive gain.
> 
> My host with 8 RX queues was handling 5 Mpps before the patch,
> and more than 10 Mpps after patch.
> 
> Tested:
> 
> On receiver :
> IP=ip
> TC=tc
> dev=eth0
> 
> $TC qdisc del dev $dev ingress 2>/dev/null
> $TC qdisc add dev $dev ingress
> $TC filter del dev $dev root pref 10 2>/dev/null
> $TC filter del dev $dev pref 10 2>/dev/null
> tc filter add dev $dev est 1sec 4sec parent ffff: protocol ip prio 1 \
> 	u32 match ip src 7.0.0.0/8 flowid 1:15 action drop
> 
> Sender sends packets flood from 7/8 network
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Alexei Starovoitov <ast@plumgrid.com>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: John Fastabend <john.fastabend@gmail.com>
> ---
>  net/sched/act_gact.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)

[...]

> @@ -121,9 +121,8 @@ static int tcf_gact(struct sk_buff *skb, const struct tc_action *a,
>  		    struct tcf_result *res)
>  {
>  	struct tcf_gact *gact = a->priv;
> -	int action = gact->tcf_action;
> +	int action = READ_ONCE(gact->tcf_action);
>  
> -	spin_lock(&gact->tcf_lock);
>  #ifdef CONFIG_GACT_PROB
>  	{
>  	u32 ptype = READ_ONCE(gact->tcfg_ptype);
> @@ -132,12 +131,11 @@ static int tcf_gact(struct sk_buff *skb, const struct tc_action *a,
>  		action = gact_rand[ptype](gact);
>  	}
>  #endif
> -	gact->tcf_bstats.bytes += qdisc_pkt_len(skb);
> -	gact->tcf_bstats.packets++;
> +	bstats_cpu_update(this_cpu_ptr(gact->common.cpu_bstats), skb);
>  	if (action == TC_ACT_SHOT)
> -		gact->tcf_qstats.drops++;
> -	gact->tcf_tm.lastuse = jiffies;
> -	spin_unlock(&gact->tcf_lock);
> +		qstats_drop_inc(this_cpu_ptr(gact->common.cpu_qstats));
> +	if (gact->tcf_tm.lastuse != jiffies)
> +		gact->tcf_tm.lastuse = jiffies;

I'm missing the point of the if block. Is that really good enough
for the 32bit system case? I would have expected some wrapper to
handle it here something like u64_stats_() maybe _u64_jiffies(). Maybe
after a coffee I'll make sense of it.

>  
>  	return action;
>  }
> 

  reply	other threads:[~2015-07-02 16:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02 13:07 [PATCH net-next 0/6] net_sched: act: lockless operation Eric Dumazet
2015-07-02 13:07 ` [PATCH net-next 1/6] net: sched: extend percpu stats helpers Eric Dumazet
2015-07-02 15:19   ` John Fastabend
2015-07-03 10:44   ` Jamal Hadi Salim
2015-07-02 13:07 ` [PATCH net-next 2/6] net: sched: add percpu stats to actions Eric Dumazet
2015-07-02 15:31   ` John Fastabend
2015-07-03 10:48   ` Jamal Hadi Salim
2015-07-02 13:07 ` [PATCH net-next 3/6] net_sched: act: make tcfg_pval non zero Eric Dumazet
2015-07-02 15:33   ` John Fastabend
2015-07-02 16:58   ` Alexei Starovoitov
2015-07-03 10:49   ` Jamal Hadi Salim
2015-07-04  7:18     ` Eric Dumazet
2015-07-02 13:07 ` [PATCH net-next 4/6] net_sched: act: use a separate packet counters for gact_determ() Eric Dumazet
2015-07-02 15:44   ` John Fastabend
2015-07-03 10:50   ` Jamal Hadi Salim
2015-07-02 13:07 ` [PATCH net-next 5/6] net_sched: act: read tcfg_ptype once Eric Dumazet
2015-07-02 15:47   ` John Fastabend
2015-07-03 10:57   ` Jamal Hadi Salim
2015-07-02 13:07 ` [PATCH net-next 6/6] net_sched: act: remove spinlock in fast path Eric Dumazet
2015-07-02 16:35   ` John Fastabend [this message]
2015-07-02 20:59     ` Eric Dumazet
2015-07-03 11:25       ` Jamal Hadi Salim
2015-07-03 12:08         ` Eric Dumazet
2015-07-03 17:21           ` John Fastabend
2015-07-02 17:13   ` Alexei Starovoitov
2015-07-03 11:07   ` Jamal Hadi Salim
2015-07-04  5:45     ` 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=5595684D.90500@gmail.com \
    --to=john.fastabend@gmail.com \
    --cc=ast@plumgrid.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@gmail.com \
    --cc=edumazet@google.com \
    --cc=jhs@mojatatu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.