Skip to content

Commit

Permalink
net_sched: act_gact: use a separate packet counters for gact_determ()
Browse files Browse the repository at this point in the history
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: Eric Dumazet <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Acked-by: Jamal Hadi Salim <[email protected]>
Acked-by: John Fastabend <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed Jul 8, 2015
1 parent cef5ecf commit cc6510a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions include/net/tc_act/tc_gact.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
struct tcf_gact {
struct tcf_common common;
#ifdef CONFIG_GACT_PROB
u16 tcfg_ptype;
u16 tcfg_pval;
int tcfg_paction;
u16 tcfg_ptype;
u16 tcfg_pval;
int tcfg_paction;
atomic_t packets;
#endif
};
#define to_gact(a) \
Expand Down
4 changes: 3 additions & 1 deletion net/sched/act_gact.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ static int gact_net_rand(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() */
if (gact->tcf_bstats.packets % gact->tcfg_pval)
if (pack % gact->tcfg_pval)
return gact->tcf_action;
return gact->tcfg_paction;
}
Expand Down

0 comments on commit cc6510a

Please sign in to comment.