Skip to content

Commit

Permalink
net: replace percpu_xxx funcs with this_cpu_xxx or __this_cpu_xxx
Browse files Browse the repository at this point in the history
percpu_xxx funcs are duplicated with this_cpu_xxx funcs, so replace
them for further code clean up.

And in preempt safe scenario, __this_cpu_xxx funcs may has a bit
better performance since __this_cpu_xxx has no redundant
preempt_enable/preempt_disable on some architectures.

Signed-off-by: Alex Shi <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Acked-by: David S. Miller <[email protected]>
Cc: Patrick McHardy <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Tejun Heo <[email protected]>
  • Loading branch information
Alex Shi authored and htejun committed May 14, 2012
1 parent 9ff00d5 commit 19e8d69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions net/netfilter/xt_TEE.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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 (percpu_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
Expand Down Expand Up @@ -124,9 +124,9 @@ tee_tg4(struct sk_buff *skb, const struct xt_action_param *par)
ip_send_check(iph);

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

if (percpu_read(tee_active))
if (__this_cpu_read(tee_active))
return XT_CONTINUE;
skb = pskb_copy(skb, GFP_ATOMIC);
if (skb == NULL)
Expand All @@ -186,9 +186,9 @@ tee_tg6(struct sk_buff *skb, const struct xt_action_param *par)
--iph->hop_limit;
}
if (tee_tg_route6(skb, info)) {
percpu_write(tee_active, true);
__this_cpu_write(tee_active, true);
ip6_local_out(skb);
percpu_write(tee_active, false);
__this_cpu_write(tee_active, false);
} else {
kfree_skb(skb);
}
Expand Down
4 changes: 2 additions & 2 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ static struct socket *sock_alloc(void)
inode->i_uid = current_fsuid();
inode->i_gid = current_fsgid();

percpu_add(sockets_in_use, 1);
this_cpu_add(sockets_in_use, 1);
return sock;
}

Expand Down Expand Up @@ -522,7 +522,7 @@ void sock_release(struct socket *sock)
if (rcu_dereference_protected(sock->wq, 1)->fasync_list)
printk(KERN_ERR "sock_release: fasync list not empty!\n");

percpu_sub(sockets_in_use, 1);
this_cpu_sub(sockets_in_use, 1);
if (!sock->file) {
iput(SOCK_INODE(sock));
return;
Expand Down

0 comments on commit 19e8d69

Please sign in to comment.