Re: [PATCH] Code clean up for percpu_xxx() functions

From: Alex,Shi
Date: Thu Oct 20 2011 - 02:01:30 EST



> Sorry this huge patch brings too many potential bugs.
>
> I ask you a separate patch for the networking part, because I dont want
> to Ack all the other parts.
>

Thanks a lot for review! I split the first patch into 2 according your
suggestion. The second one for network here:

>From d5d71127ad22890f6f13fa382736c0df7f5d0231 Mon Sep 17 00:00:00 2001
From: Alex Shi <alex.shi@xxxxxxxxx>
Date: Thu, 20 Oct 2011 13:44:37 +0800
Subject: [PATCH 2/2] change this_cpu_xxx funcs for preempt safe scenarios

If context is preempt safe, using __this_cpu_xxx to replace this_cpu_xxx
have performance benefit, since the later has a abundant preempt_disable
instruction.

Signed-off-by: Alex Shi <alex.shi@xxxxxxxxx>
---
net/netfilter/xt_TEE.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/netfilter/xt_TEE.c b/net/netfilter/xt_TEE.c
index e78103d..678084c 100644
--- a/net/netfilter/xt_TEE.c
+++ b/net/netfilter/xt_TEE.c
@@ -90,7 +90,7 @@ tee_tg4(struct sk_buff *skb, const struct xt_action_param *par)
const struct xt_tee_tginfo *info = par->targinfo;
struct iphdr *iph;

- if (this_cpu_read(tee_active))
+ if (__this_cpu_read(tee_active))
return XT_CONTINUE;
/*
* Copy the skb, and route the copy. Will later return %XT_CONTINUE for
@@ -127,9 +127,9 @@ tee_tg4(struct sk_buff *skb, const struct xt_action_param *par)
ip_send_check(iph);

if (tee_tg_route4(skb, info)) {
- this_cpu_write(tee_active, true);
+ __this_cpu_write(tee_active, true);
ip_local_out(skb);
- this_cpu_write(tee_active, false);
+ __this_cpu_write(tee_active, false);
} else {
kfree_skb(skb);
}
@@ -170,7 +170,7 @@ tee_tg6(struct sk_buff *skb, const struct xt_action_param *par)
{
const struct xt_tee_tginfo *info = par->targinfo;

- if (this_cpu_read(tee_active))
+ if (__this_cpu_read(tee_active))
return XT_CONTINUE;
skb = pskb_copy(skb, GFP_ATOMIC);
if (skb == NULL)
@@ -188,9 +188,9 @@ tee_tg6(struct sk_buff *skb, const struct xt_action_param *par)
--iph->hop_limit;
}
if (tee_tg_route6(skb, info)) {
- this_cpu_write(tee_active, true);
+ __this_cpu_write(tee_active, true);
ip6_local_out(skb);
- this_cpu_write(tee_active, false);
+ __this_cpu_write(tee_active, false);
} else {
kfree_skb(skb);
}
--
1.6.3.3



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/