Commit cc6510a9 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net_sched: act_gact: use a separate packet counters for gact_determ()

Second step for gact RCU operation :

We want to get rid of the spinlock protecting gact operations.
Stats (packets/bytes) will soon be per cpu.

gact_determ() would not work without a central packet counter,
so lets add it for this mode.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cef5ecf9
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
struct tcf_gact { struct tcf_gact {
struct tcf_common common; struct tcf_common common;
#ifdef CONFIG_GACT_PROB #ifdef CONFIG_GACT_PROB
u16 tcfg_ptype; u16 tcfg_ptype;
u16 tcfg_pval; u16 tcfg_pval;
int tcfg_paction; int tcfg_paction;
atomic_t packets;
#endif #endif
}; };
#define to_gact(a) \ #define to_gact(a) \
......
...@@ -36,8 +36,10 @@ static int gact_net_rand(struct tcf_gact *gact) ...@@ -36,8 +36,10 @@ static int gact_net_rand(struct tcf_gact *gact)
static int gact_determ(struct tcf_gact *gact) static int gact_determ(struct tcf_gact *gact)
{ {
u32 pack = atomic_inc_return(&gact->packets);
smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */ smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */
if (gact->tcf_bstats.packets % gact->tcfg_pval) if (pack % gact->tcfg_pval)
return gact->tcf_action; return gact->tcf_action;
return gact->tcfg_paction; return gact->tcfg_paction;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment