From: ebiederm@xmission.com (Eric W. Biederman)
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, containers@lists.osdl.org
Subject: Re: [PATCH 1/4] net: Dynamically allocate the per cpu counters for the loopback device.
Date: Thu, 27 Sep 2007 14:44:37 -0600 [thread overview]
Message-ID: <m1ps03hm8a.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20070927.115200.56183114.davem@davemloft.net> (David Miller's message of "Thu, 27 Sep 2007 11:52:00 -0700 (PDT)")
David Miller <davem@davemloft.net> writes:
> From: ebiederm@xmission.com (Eric W. Biederman)
> Date: Thu, 27 Sep 2007 01:48:00 -0600
>
>> I'm not doing get_cpu/put_cpu so does the comment make sense
>> in relationship to per_cpu_ptr?
>
> It is possible. But someone would need to go check for
> sure.
Verified.
hard_start_xmit is called inside of a
rcu_read_lock_bh(),rcu_read_unlock_bh() pair. Which means
the code will only run on one cpu.
Therefore we do not need get_cpu/put_cpu.
In addition per_cpu_ptr is valid. As it is just a lookup
into a NR_CPUS sized array by smp_processor_id() to return
the address of the specific cpu.
The only difference between per_cpu_ptr and __get_cpu_var()
are the implementation details between statically allocated
and dynamically allocated per cpu state.
So the comment is still valid, and still interesting it just
should say per_cpu_ptr instead of __get_cpu_var.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 0f9d8c6..756e267 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -154,7 +154,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
#endif
dev->last_rx = jiffies;
- /* it's OK to use __get_cpu_var() because BHs are off */
+ /* it's OK to use per_cpu_ptr() because BHs are off */
pcpu_lstats = netdev_priv(dev);
lb_stats = per_cpu_ptr(pcpu_lstats, smp_processor_id());
lb_stats->bytes += skb->len;
next prev parent reply other threads:[~2007-09-27 20:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-26 23:53 [PATCH 1/4] net: Dynamically allocate the per cpu counters for the loopback device Eric W. Biederman
2007-09-26 23:55 ` [PATCH 2/4] net ipv4: Remove unnecessary test for the loopback device from inetdev_destroy Eric W. Biederman
2007-09-26 23:58 ` [PATCH 3/4] net ipv4: When possible test for IFF_LOOPBACK and not dev == loopback_dev Eric W. Biederman
2007-09-27 0:00 ` [PATCH 4/4] net: Make the loopback device per network namespace Eric W. Biederman
2007-09-27 5:11 ` David Miller
2007-09-27 12:14 ` [Devel] " Denis V. Lunev
2007-09-27 16:48 ` Eric W. Biederman
2007-09-27 5:10 ` [PATCH 3/4] net ipv4: When possible test for IFF_LOOPBACK and not dev == loopback_dev David Miller
2007-09-27 10:34 ` Daniel Lezcano
2007-09-27 16:10 ` Eric W. Biederman
2007-09-27 5:09 ` [PATCH 2/4] net ipv4: Remove unnecessary test for the loopback device from inetdev_destroy David Miller
2007-09-27 5:09 ` [PATCH 1/4] net: Dynamically allocate the per cpu counters for the loopback device David Miller
2007-09-27 7:48 ` Eric W. Biederman
2007-09-27 18:52 ` David Miller
2007-09-27 20:44 ` Eric W. Biederman [this message]
2007-09-27 20:56 ` David Miller
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=m1ps03hm8a.fsf@ebiederm.dsl.xmission.com \
--to=ebiederm@xmission.com \
--cc=containers@lists.osdl.org \
--cc=davem@davemloft.net \
--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).