From: Eric Dumazet <edumazet@google.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@plumgrid.com>,
Jamal Hadi Salim <jhs@mojatatu.com>,
John Fastabend <john.fastabend@gmail.com>,
Eric Dumazet <edumazet@google.com>,
Eric Dumazet <edumazet@gmail.com>
Subject: [PATCH v2 net-next 4/7] net_sched: act_gact: use a separate packet counters for gact_determ()
Date: Sun, 5 Jul 2015 23:41:30 -0700 [thread overview]
Message-ID: <1436164896-8243-6-git-send-email-edumazet@google.com> (raw)
In-Reply-To: <1436164896-8243-1-git-send-email-edumazet@google.com>
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 <edumazet@google.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
---
include/net/tc_act/tc_gact.h | 7 ++++---
net/sched/act_gact.c | 4 +++-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h
index 9fc9b578908a..592a6bc02b0b 100644
--- a/include/net/tc_act/tc_gact.h
+++ b/include/net/tc_act/tc_gact.h
@@ -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) \
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
index 22a3a61aa090..2f9bec584b3f 100644
--- a/net/sched/act_gact.c
+++ b/net/sched/act_gact.c
@@ -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;
}
--
2.4.3.573.g4eafbef
next prev parent reply other threads:[~2015-07-06 6:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-06 6:41 [PATCH v2 net-next 0/7] net_sched: act: lockless operation Eric Dumazet
2015-07-06 6:41 ` [PATCH v2 net-next 1/7] net: sched: extend percpu stats helpers Eric Dumazet
2015-07-06 6:41 ` [PATCH v2 net-next 2/7] net: sched: add percpu stats to actions Eric Dumazet
2015-07-06 6:41 ` [PATCH v2 net-next 3/7] net_sched: act_gact: make tcfg_pval non zero Eric Dumazet
2015-07-06 6:41 ` [PATCH v2 net-next 3/7] net_sched: act: " Eric Dumazet
2015-07-06 6:41 ` Eric Dumazet [this message]
2015-07-06 6:49 ` [PATCH v2 net-next 0/7] net_sched: act: lockless operation Eric Dumazet
2015-07-06 12:12 ` Jamal Hadi Salim
2015-07-06 12:17 ` 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=1436164896-8243-6-git-send-email-edumazet@google.com \
--to=edumazet@google.com \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=edumazet@gmail.com \
--cc=jhs@mojatatu.com \
--cc=john.fastabend@gmail.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;
as well as URLs for NNTP newsgroup(s).