* Re: switching network namespace midway
From: Eric W. Biederman @ 2012-11-02 20:45 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: rsa, netdev
In-Reply-To: <20121102140353.GE18091@kvack.org>
Benjamin LaHaise <bcrl@kvack.org> writes:
> On Thu, Nov 01, 2012 at 11:18:58PM -0700, Eric W. Biederman wrote:
>> You need a per network namespace exit function to delete the tunnel when
>> the xmit direction goes away. Otherwise we have a very nasty race if
>> the original network namespace exits.
>
> That already exists as ipgre_exit_net(). Since the ip_tunnel structure
> remains hashed in the network namespace that creation occurred in, this
> case should be covered.
*blink* I had looked for that, but I definitely missed that one.
The consequence of the design where we can run ioctls on network devices
we can't even see but whose ipaddrs are in our network namespace is
interesting. Correct but interesting.
>> NETNS_LOCAL may make sense on the reference device that is used to
>> support ioctls for creating devices.
>
> *nod* That makes sense.
After a second look. fb_tunnel_dev is very special in the code so
allowing fb_tunnel_dev to change network namespace is almost certain
to create problems, so it should get a NETNS_LOCAL.
>> ipgre_open ? It looks like it needs to be handled. Probably that
>> ip_route_output_gre needs to be moved.
>
> Good catch. Will respin with that changed.
I'm not seeing anything else but I will look again after you respin.
>> ipv6?
>
> That's next on the list. There are also issues with ipip, ipmr and
> ipvti, as well as their ipv6 versions.
I don't see sense in ip multicast routing tunnels (ipmr) changing
network namespaces as they are essentially aliases for other network
devices, and aren't really proper tunnels.
Eric
^ permalink raw reply
* Do You Want To Be Comfortable
From: nilton @ 2012-11-02 13:03 UTC (permalink / raw)
Hello, My name is Nilton secretary to Mr.Norman Chan, I got your email
contact from an online directory; Mr.Norman Chan would need your
assistance on a business proposal. Contact me him through mail;
normchan1@live.com for more detailed.
-------------------------------------------------------------------------
"O usuario e integralmente responsavel por todo conteudo enviado
de sua conta de e-mail. Sua senha e pessoal e intransferivel."
^ permalink raw reply
* Re: [PATCH v2 9/9] net: batman-adv: use per_cpu_add helper
From: Sven Eckelmann @ 2012-11-02 17:55 UTC (permalink / raw)
To: b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r
Cc: NetDev, Kernel-Maillist, siwu-MaAgPAbsBIVS8oHt8HbXEIQuADTiUCJX,
Shan Wei, Christoph Lameter, lindner_marek-LWAfsSFWpa4,
David Miller
In-Reply-To: <5093EE7E.6040400-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 499 bytes --]
On Saturday 03 November 2012 00:02:06 Shan Wei wrote:
> From: Shan Wei <davidshan-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
>
> As Christoph Lameter said:
> > In addition, following usage of per_cpu_ptr can be replaced by
> > this_cpu_read.
> >
> > cpu=get_cpu()
> > ....
> > *per_cpu_ptr(p,cpu)
> > ....
> > ....
> > put_cpu()
>
> Right.
>
> Signed-off-by: Shan Wei <davidshan-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
> ---
Is this really supposed to be the commit message?
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply
* Re: [PATCH 0/9 v2] use efficient this_cpu_* helper
From: Christoph Lameter @ 2012-11-02 17:49 UTC (permalink / raw)
To: Shan Wei; +Cc: David Miller, NetDev, Kernel-Maillist
In-Reply-To: <5093EEC2.7000109@gmail.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1046 bytes --]
On Sat, 3 Nov 2012, Shan Wei wrote:
> this_cpu_ptr is faster than per_cpu_ptr(p, smp_processor_id())
> and can reduce memory accesses.
> The latter helper needs to find the offset for current cpu,
> and needs more assembler instructions which objdump shows in following.
>
> per_cpu_ptr(p, smp_processor_id()):
> 1e: 65 8b 04 25 00 00 00 00 mov %gs:0x0,%eax
> 26: 48 98 cltq
> 28: 31 f6 xor %esi,%esi
> 2a: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
> 31: 48 8b 04 c5 00 00 00 00 mov 0x0(,%rax,8),%rax
> 39: c7 44 10 04 14 00 00 00 movl $0x14,0x4(%rax,%rdx,1)
>
> this_cpu_ptr(p)
> 1e: 65 48 03 14 25 00 00 00 00 add %gs:0x0,%rdx
> 27: 31 f6 xor %esi,%esi
> 29: c7 42 04 14 00 00 00 movl $0x14,0x4(%rdx)
> 30: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
this_cpu_read() etc even avoids the use of this_cpu_ptr()
reducing the 6 instructions earlier to 1.
^ permalink raw reply
* Re: [PATCH v2 9/9] net: batman-adv: use per_cpu_add helper
From: Christoph Lameter @ 2012-11-02 17:48 UTC (permalink / raw)
To: Shan Wei
Cc: lindner_marek, siwu, ordex, b.a.t.m.a.n, David Miller, NetDev,
Kernel-Maillist
In-Reply-To: <5093EE7E.6040400@gmail.com>
On Sat, 3 Nov 2012, Shan Wei wrote:
> diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
> index 897ba6a..3aef5b2 100644
> --- a/net/batman-adv/main.h
> +++ b/net/batman-adv/main.h
> @@ -263,9 +263,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
> static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
> size_t count)
> {
> - int cpu = get_cpu();
> - per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count;
> - put_cpu();
> + this_cpu_add(bat_priv->bat_counters[idx], count);
> }
Reviewed-by: Christoph Lameter <cl@linux.com>
^ permalink raw reply
* Re: [PATCH 4/9] net: openvswitch: use this_cpu_ptr per-cpu helper
From: Christoph Lameter @ 2012-11-02 17:46 UTC (permalink / raw)
To: Shan Wei
Cc: dev-yBygre7rU0TnMu66kgdUjQ, NetDev, Kernel-Maillist, David Miller
In-Reply-To: <5093EE59.8010609-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Sat, 3 Nov 2012, Shan Wei wrote:
> +++ b/net/openvswitch/datapath.c
> @@ -208,7 +208,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
> int error;
> int key_len;
>
> - stats = per_cpu_ptr(dp->stats_percpu, smp_processor_id());
> + stats = this_cpu_ptr(dp->stats_percpu);
>
> /* Extract flow from 'skb' into 'key'. */
> error = ovs_flow_extract(skb, p->port_no, &key, &key_len);
> @@ -282,7 +282,7 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
> return 0;
>
> err:
> - stats = per_cpu_ptr(dp->stats_percpu, smp_processor_id());
> + stats = this_cpu_ptr(dp->stats_percpu);
>
> u64_stats_update_begin(&stats->sync);
> stats->n_lost++;
> diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
> index 03779e8..70af0be 100644
> --- a/net/openvswitch/vport.c
> +++ b/net/openvswitch/vport.c
> @@ -333,8 +333,7 @@ void ovs_vport_receive(struct vport *vport, struct sk_buff *skb)
> {
> struct vport_percpu_stats *stats;
>
> - stats = per_cpu_ptr(vport->percpu_stats, smp_processor_id());
> -
> + stats = this_cpu_ptr(vport->percpu_stats);
> u64_stats_update_begin(&stats->sync);
> stats->rx_packets++;
> stats->rx_bytes += skb->len;
> @@ -359,7 +358,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
> if (likely(sent)) {
> struct vport_percpu_stats *stats;
>
> - stats = per_cpu_ptr(vport->percpu_stats, smp_processor_id());
> + stats = this_cpu_ptr(vport->percpu_stats);
>
> u64_stats_update_begin(&stats->sync);
> stats->tx_packets++;
Use this_cpu_inc(vport->percpu_stats->packets) here?
^ permalink raw reply
* Re: [PATCH v2 1/9] net: core: use this_cpu_ptr per-cpu helper
From: Christoph Lameter @ 2012-11-02 17:44 UTC (permalink / raw)
To: Shan Wei
Cc: David Miller, timo.teras, steffen.klassert, NetDev,
Kernel-Maillist
In-Reply-To: <5093EE47.20700@gmail.com>
On Sat, 3 Nov 2012, Shan Wei wrote:
> +++ b/net/core/flow.c
> @@ -327,11 +327,9 @@ static void flow_cache_flush_tasklet(unsigned long data)
> static void flow_cache_flush_per_cpu(void *data)
> {
> struct flow_flush_info *info = data;
> - int cpu;
> struct tasklet_struct *tasklet;
>
> - cpu = smp_processor_id();
> - tasklet = &per_cpu_ptr(info->cache->percpu, cpu)->flush_tasklet;
> + tasklet = &this_cpu_ptr(info->cache->percpu)->flush_tasklet
Another case for the use of this_cpu_read
^ permalink raw reply
* [RFC] net: netlink -- Allow netlink_dump to return error code if protocol handler is missed
From: Cyrill Gorcunov @ 2012-11-02 17:35 UTC (permalink / raw)
To: NETDEV; +Cc: David Miller, Eric Dumazet, Pavel Emelyanov
We've observed that in case if UDP diag module is not
supported in kernel the netlink returns NLMSG_DONE without
notifying a caller that handler is missed.
This patch makes netlink_dump to return error code instead.
So as example it become possible to detect such situation
and handle it gracefully on userspace level.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: David Miller <davem@davemloft.net>
CC: Eric Dumazet <eric.dumazet@gmail.com>
CC: Pavel Emelyanov <xemul@parallels.com>
---
net/ipv4/inet_diag.c | 5 ++++-
net/netlink/af_netlink.c | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
Index: linux-2.6.git/net/ipv4/inet_diag.c
===================================================================
--- linux-2.6.git.orig/net/ipv4/inet_diag.c
+++ linux-2.6.git/net/ipv4/inet_diag.c
@@ -895,13 +895,16 @@ static int __inet_diag_dump(struct sk_bu
struct inet_diag_req_v2 *r, struct nlattr *bc)
{
const struct inet_diag_handler *handler;
+ int err = 0;
handler = inet_diag_lock_handler(r->sdiag_protocol);
if (!IS_ERR(handler))
handler->dump(skb, cb, r, bc);
+ else
+ err = PTR_ERR(handler);
inet_diag_unlock_handler(handler);
- return skb->len;
+ return err ? : skb->len;
}
static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
Index: linux-2.6.git/net/netlink/af_netlink.c
===================================================================
--- linux-2.6.git.orig/net/netlink/af_netlink.c
+++ linux-2.6.git/net/netlink/af_netlink.c
@@ -1740,6 +1740,10 @@ static int netlink_dump(struct sock *sk)
else
__netlink_sendskb(sk, skb);
return 0;
+ } else if (len < 0) {
+ err = len;
+ nlk->cb = NULL;
+ goto errout_skb;
}
nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE, sizeof(len), NLM_F_MULTI);
^ permalink raw reply
* [PATCH net-next] macb: Keep driver's speed/duplex in sync with actual NCFGR
From: Vitalii Demianets @ 2012-11-02 17:09 UTC (permalink / raw)
To: netdev
Cc: Jean-Christophe PLAGNIOL-VILLARD, Nicolas Ferre, linux-arm-kernel,
Jamie Iles, Havard Skinnemoen
When underlying phy driver restores its state very fast after being brought
down and up so that macb driver function macb_handle_link_change() was never
called with link state "down", driver's internal representation of phy speed
and duplex (bp->speed and bp->duplex) didn't change. So, macb driver sees no
reason to perform actual write to the NCFGR register, although the speed and
duplex settings in that register were reset when interface was brought down
and up. In that case actual phy speed and duplex differ from NCFGR settings.
The patch fixes that by keeping internal driver representation of speed and
duplex in sync with actual content of NCFGR.
Signed-off-by: Vitalii Demianets <vitas@nppfactor.kiev.ua>
---
drivers/net/ethernet/cadence/macb.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c
b/drivers/net/ethernet/cadence/macb.c
index c374875..13c3c33 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -1031,6 +1031,8 @@ static void macb_init_hw(struct macb *bp)
config |= MACB_BIT(NBC); /* No BroadCast */
config |= macb_dbw(bp);
macb_writel(bp, NCFGR, config);
+ bp->speed = SPEED_10;
+ bp->duplex = DUPLEX_HALF;
macb_configure_dma(bp);
--
1.7.8.6
^ permalink raw reply related
* Re: [tcpdump-workers] vlan tagged packets and libpcap breakage
From: Bill Fenner @ 2012-11-02 16:13 UTC (permalink / raw)
To: Guy Harris
Cc: Ani Sinha, netdev, tcpdump-workers, Michael Richardson,
Francesco Ruggeri
In-Reply-To: <5422DBB2-EABF-4C9F-B0CD-8C77E91F9FF8@alum.mit.edu>
On Wed, Oct 31, 2012 at 6:20 PM, Guy Harris <guy@alum.mit.edu> wrote:
>
> On Oct 31, 2012, at 2:50 PM, Ani Sinha <ani@aristanetworks.com> wrote:
>
>> pcap files that already have the tags reinsrted should work with
>> current filter code. However for live traffic, one has to get the tags
>> from CMSG() and then reinsert it back to the packet for the current
>> filter to work.
>
> *Somebody* has to do that, at least to packets that pass the filter, before they're handed to a libpcap-based application, for programs that expect to see packets as they arrived from/were transmitted to the wire to work.
>
> I.e., the tags *should* be reinserted by libpcap, and, as I understand it, that's what the
>
> #if defined(HAVE_PACKET_AUXDATA) && defined(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI)
> ...
> #endif
>
> blocks of code in pcap-linux.c in libpcap are doing.
>
> Now, if filtering is being done in the *kernel*, and the tags aren't being reinserted by the kernel, then filter code stuffed into the kernel would need to differ from filter code run in userland. There's already precedent for that on Linux, with the "cooked mode" headers; those are synthesized by libpcap from the metadata returned for PF_PACKET sockets, and the code that attempts to hand the kernel a filter goes through the filter code, which was generated under the assumption that the packet begins with a "cooked mode" header, and modifies (a copy of) the code to, instead, use the special Linux-BPF-interpreter offsets to access the metadata.
>
> The right thing to do here would be to, if possible, do the same, so that the kernel doesn't have to reinsert VLAN tags for packets that aren't going to be handed to userland.
In this case, it would be incredibly complicated to do this just
postprocessing a set of bpf instructions. The problem is that when
running the filter in the kernel, the IP header, etc. are not offset,
so "off_macpl" and "off_linktype" would be zero, not 4, while
generating the rest of the expression. We would also have to insert
code when comparing the ethertype to 0x8100 to instead load the
vlan-tagged metadata, so all jumps crossing that point would have to
be adjusted, and if the "if-false" instruction was also testing the
ethertype, then the ethertype would have to be reloaded (again
inserting another instruction).
Basically, take a look at the output of "tcpdump -d tcp port 22 or
(vlan and tcp port 22)". Are the IPv4 tcp ports at x+14/x+16, or at
x+18/x+20? If we're filtering in the kernel, they're at x+14/x+16
whether the packet is vlan tagged or not. If we're filtering on the
actual packet contents (from a savefile, for example), they're at
x+18/x+20 if the packet is vlan tagged.
Also, an expression such as 'tcp port 22' would have to have some
instructions added at the beginning, for "vlan-tagged == false", or it
would match both tagged and untagged packets.
This would be much more straightforward to deal with in the code
generation phase, except until now the code generation phase hasn't
known whether the filter is headed for the kernel or not.
Bill
^ permalink raw reply
* [PATCH 0/9 v2] use efficient this_cpu_* helper
From: Shan Wei @ 2012-11-02 16:03 UTC (permalink / raw)
To: cl, David Miller, NetDev, Kernel-Maillist, Shan Wei
this_cpu_ptr is faster than per_cpu_ptr(p, smp_processor_id())
and can reduce memory accesses.
The latter helper needs to find the offset for current cpu,
and needs more assembler instructions which objdump shows in following.
per_cpu_ptr(p, smp_processor_id()):
1e: 65 8b 04 25 00 00 00 00 mov %gs:0x0,%eax
26: 48 98 cltq
28: 31 f6 xor %esi,%esi
2a: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
31: 48 8b 04 c5 00 00 00 00 mov 0x0(,%rax,8),%rax
39: c7 44 10 04 14 00 00 00 movl $0x14,0x4(%rax,%rdx,1)
this_cpu_ptr(p)
1e: 65 48 03 14 25 00 00 00 00 add %gs:0x0,%rdx
27: 31 f6 xor %esi,%esi
29: c7 42 04 14 00 00 00 movl $0x14,0x4(%rdx)
30: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
Changelog V2:
1. Use this_cpu_read directly instead of ref to field of per-cpu variable.
2. Patch5 about ftrace is dropped from this series.
3. Add new patch9 to replace get_cpu;per_cpu_ptr;put_cpu with this_cpu_add opt.
4. For preemption disable case, use __this_cpu_read instead.
$ git diff --stat b77bc2069d1e437d5a1a71bb5cfcf4556ee40015
drivers/clocksource/arm_generic.c | 2 +-
kernel/padata.c | 5 ++---
kernel/rcutree.c | 2 +-
kernel/trace/blktrace.c | 2 +-
kernel/trace/trace.c | 4 +---
net/batman-adv/main.h | 4 +---
net/core/flow.c | 4 +---
net/openvswitch/datapath.c | 4 ++--
net/openvswitch/vport.c | 5 ++---
net/rds/ib_recv.c | 2 +-
net/xfrm/xfrm_ipcomp.c | 7 +++----
11 files changed, 16 insertions(+), 25 deletions(-)
^ permalink raw reply
* [PATCH v2 9/9] net: batman-adv: use per_cpu_add helper
From: Shan Wei @ 2012-11-02 16:02 UTC (permalink / raw)
To: lindner_marek, siwu, ordex, b.a.t.m.a.n, David Miller, NetDev,
Kernel-Maillist, Shan Wei, Christoph Lameter
From: Shan Wei <davidshan@tencent.com>
As Christoph Lameter said:
> In addition, following usage of per_cpu_ptr can be replaced by this_cpu_read.
>
> cpu=get_cpu()
> ....
> *per_cpu_ptr(p,cpu)
> ....
> ....
> put_cpu()
Right.
Signed-off-by: Shan Wei <davidshan@tencent.com>
---
net/batman-adv/main.h | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 897ba6a..3aef5b2 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -263,9 +263,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp,
static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx,
size_t count)
{
- int cpu = get_cpu();
- per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count;
- put_cpu();
+ this_cpu_add(bat_priv->bat_counters[idx], count);
}
#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)
--
1.7.1
^ permalink raw reply related
* [PATCH 4/9] net: openvswitch: use this_cpu_ptr per-cpu helper
From: Shan Wei @ 2012-11-02 16:01 UTC (permalink / raw)
To: jesse-l0M0P4e3n4LQT0dZR+AlfA, dev-yBygre7rU0TnMu66kgdUjQ, NetDev,
Kernel-Maillist, David Miller,
cl-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b, Shan Wei
From: Shan Wei <davidshan-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
no change vs v1.
Lots of drivers use this kind to read/write per-cpu variable.
stats = this_cpu_ptr(dp->stats_percpu);
u64_stats_update_begin(&stats->sync);
stats->tx_packets++;
u64_stats_update_begin(&stats->sync);
Signed-off-by: Shan Wei <davidshan-1Nz4purKYjRBDgjK7y7TUQ@public.gmane.org>
---
net/openvswitch/datapath.c | 4 ++--
net/openvswitch/vport.c | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 4c4b62c..77d16a5 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -208,7 +208,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb)
int error;
int key_len;
- stats = per_cpu_ptr(dp->stats_percpu, smp_processor_id());
+ stats = this_cpu_ptr(dp->stats_percpu);
/* Extract flow from 'skb' into 'key'. */
error = ovs_flow_extract(skb, p->port_no, &key, &key_len);
@@ -282,7 +282,7 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
return 0;
err:
- stats = per_cpu_ptr(dp->stats_percpu, smp_processor_id());
+ stats = this_cpu_ptr(dp->stats_percpu);
u64_stats_update_begin(&stats->sync);
stats->n_lost++;
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 03779e8..70af0be 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -333,8 +333,7 @@ void ovs_vport_receive(struct vport *vport, struct sk_buff *skb)
{
struct vport_percpu_stats *stats;
- stats = per_cpu_ptr(vport->percpu_stats, smp_processor_id());
-
+ stats = this_cpu_ptr(vport->percpu_stats);
u64_stats_update_begin(&stats->sync);
stats->rx_packets++;
stats->rx_bytes += skb->len;
@@ -359,7 +358,7 @@ int ovs_vport_send(struct vport *vport, struct sk_buff *skb)
if (likely(sent)) {
struct vport_percpu_stats *stats;
- stats = per_cpu_ptr(vport->percpu_stats, smp_processor_id());
+ stats = this_cpu_ptr(vport->percpu_stats);
u64_stats_update_begin(&stats->sync);
stats->tx_packets++;
--
1.7.1
^ permalink raw reply related
* [PATCH v2 3/9] net: xfrm: use __this_cpu_read per-cpu helper
From: Shan Wei @ 2012-11-02 16:01 UTC (permalink / raw)
To: steffen.klassert, David Miller, NetDev, Herbert Xu,
Kernel-Maillist, cl
From: Shan Wei <davidshan@tencent.com>
Signed-off-by: Shan Wei <davidshan@tencent.com>
---
net/xfrm/xfrm_ipcomp.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index e5246fb..394d672 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -276,14 +276,13 @@ static struct crypto_comp * __percpu *ipcomp_alloc_tfms(const char *alg_name)
struct crypto_comp * __percpu *tfms;
int cpu;
- /* This can be any valid CPU ID so we don't need locking. */
- cpu = raw_smp_processor_id();
-
list_for_each_entry(pos, &ipcomp_tfms_list, list) {
struct crypto_comp *tfm;
tfms = pos->tfms;
- tfm = *per_cpu_ptr(tfms, cpu);
+
+ /* This can be any valid CPU ID so we don't need locking. */
+ tfm = __this_cpu_read(tfms);
if (!strcmp(crypto_comp_name(tfm), alg_name)) {
pos->users++;
--
1.7.1
^ permalink raw reply related
* [PATCH v2 2/9] net: rds: use this_cpu_ptr per-cpu helper
From: Shan Wei @ 2012-11-02 16:01 UTC (permalink / raw)
To: venkat.x.venkatsubra, David Miller, rds-devel, NetDev,
Kernel-Maillist, cl, Shan Wei
From: Shan Wei <davidshan@tencent.com>
Signed-off-by: Shan Wei <davidshan@tencent.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
---
net/rds/ib_recv.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
index 8d19491..a4a5064 100644
--- a/net/rds/ib_recv.c
+++ b/net/rds/ib_recv.c
@@ -423,7 +423,7 @@ static void rds_ib_recv_cache_put(struct list_head *new_item,
local_irq_save(flags);
- chp = per_cpu_ptr(cache->percpu, smp_processor_id());
+ chp = this_cpu_ptr(cache->percpu);
if (!chp->first)
INIT_LIST_HEAD(new_item);
else /* put on front */
--
1.7.1
^ permalink raw reply related
* [PATCH v2 1/9] net: core: use this_cpu_ptr per-cpu helper
From: Shan Wei @ 2012-11-02 16:01 UTC (permalink / raw)
To: David Miller, timo.teras, steffen.klassert, NetDev,
Kernel-Maillist, cl, Shan Wei
From: Shan Wei <davidshan@tencent.com>
Signed-off-by: Shan Wei <davidshan@tencent.com>
Reviewed-by: Christoph Lameter <cl@linux.com>
---
net/core/flow.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/net/core/flow.c b/net/core/flow.c
index e318c7e..3bad824 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -327,11 +327,9 @@ static void flow_cache_flush_tasklet(unsigned long data)
static void flow_cache_flush_per_cpu(void *data)
{
struct flow_flush_info *info = data;
- int cpu;
struct tasklet_struct *tasklet;
- cpu = smp_processor_id();
- tasklet = &per_cpu_ptr(info->cache->percpu, cpu)->flush_tasklet;
+ tasklet = &this_cpu_ptr(info->cache->percpu)->flush_tasklet;
tasklet->data = (unsigned long)info;
tasklet_schedule(tasklet);
}
--
1.7.1
^ permalink raw reply related
* [PATCH 0/9 v2] use efficient this_cpu_* helper
From: Shan Wei @ 2012-11-02 16:01 UTC (permalink / raw)
To: cl, David Miller, NetDev, Kernel-Maillist, Shan Wei
this_cpu_ptr is faster than per_cpu_ptr(p, smp_processor_id())
and can reduce memory accesses.
The latter helper needs to find the offset for current cpu,
and needs more assembler instructions which objdump shows in following.
per_cpu_ptr(p, smp_processor_id()):
1e: 65 8b 04 25 00 00 00 00 mov %gs:0x0,%eax
26: 48 98 cltq
28: 31 f6 xor %esi,%esi
2a: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
31: 48 8b 04 c5 00 00 00 00 mov 0x0(,%rax,8),%rax
39: c7 44 10 04 14 00 00 00 movl $0x14,0x4(%rax,%rdx,1)
this_cpu_ptr(p)
1e: 65 48 03 14 25 00 00 00 00 add %gs:0x0,%rdx
27: 31 f6 xor %esi,%esi
29: c7 42 04 14 00 00 00 movl $0x14,0x4(%rdx)
30: 48 c7 c7 00 00 00 00 mov $0x0,%rdi
Changelog V2:
1. Use this_cpu_read directly instead of ref to field of per-cpu variable.
2. Patch5 about ftrace is dropped from this series.
3. Add new patch9 to replace get_cpu;per_cpu_ptr;put_cpu with this_cpu_add opt.
4. For preemption disable case, use __this_cpu_read instead.
$ git diff --stat b77bc2069d1e437d5a1a71bb5cfcf4556ee40015
drivers/clocksource/arm_generic.c | 2 +-
kernel/padata.c | 5 ++---
kernel/rcutree.c | 2 +-
kernel/trace/blktrace.c | 2 +-
kernel/trace/trace.c | 4 +---
net/batman-adv/main.h | 4 +---
net/core/flow.c | 4 +---
net/openvswitch/datapath.c | 4 ++--
net/openvswitch/vport.c | 5 ++---
net/rds/ib_recv.c | 2 +-
net/xfrm/xfrm_ipcomp.c | 7 +++----
11 files changed, 16 insertions(+), 25 deletions(-)
^ permalink raw reply
* Re: [PATCH] net: ipv6: change %8s to %s for rt->dst.dev->name in seq_printf of rt6_info_route
From: Shan Wei @ 2012-11-02 15:40 UTC (permalink / raw)
To: Chen Gang; +Cc: davem, kuznet, jmorris, yoshfuji, kaber, netdev
In-Reply-To: <5093BA27.3090109@asianux.com>
Chen Gang said, at 2012/11/2 20:18:
>
> the length of rt->dst.dev->name is 16 (IFNAMSIZ)
> in seq_printf, it is not suitable to use %8s for rt->dst.dev->name.
> so change it to %s, since each line has not been solid any more.
>
> additional information:
>
> %8s limit the width, not for the original string output length
> if name length is more than 8, it still can be fully displayed.
> if name length is less than 8, the ' ' will be filled before name.
>
> %.8s truly limit the original string output length (precision)
>
>
> Signed-off-by: Chen Gang <gang.chen@asianux.com>
1. not to send same patch triple times.
2. config your email client,because tab is changed to space.
you can read Documentation/email-clients.txt.
^ permalink raw reply
* Re: [PATCH 4/4] arm/dts: am33xx: Add CPSW and MDIO module nodes for AM33XX
From: Richard Cochran @ 2012-11-02 15:19 UTC (permalink / raw)
To: N, Mugunthan V
Cc: Cousson, Benoit, Hiremath, Vaibhav, netdev@vger.kernel.org,
paul@pwsan.com, linux-arm-kernel@lists.infradead.org,
linux-omap@vger.kernel.org
In-Reply-To: <EB1619762EAF8B4E97A227FB77B7E0293EA09122@DBDE01.ent.ti.com>
On Fri, Nov 02, 2012 at 10:42:04AM +0000, N, Mugunthan V wrote:
>
> I saw those posts. The CPSW ip version changes tracks the internal IP
> changes and there is no possible way to track the offset changes. For
> example CPTS sub module offsets in DM814x and AM335x are different
> though the CPTS version is same in both IP versions. So keeping these
> offset in DT will make the same driver works directly with DT changes
> for future SoC.
But the CPSW versions are different, and the offsets could be
determined that way, couldn't they?
The TRM for the DM814x does not even make the distinction among
CPSW_SS, CPSW_PORT, CPSW_CPDMA, and so on. Instead, it places all of
the registers into one space called CPSW_3G.
So I agree with Benoit. Placing all of the offsets into DT seems like
over-engineering to me, unless you know of TI's plans to release a new
SoC with the same CPSW version but different register offsets.
Thanks,
Richard
^ permalink raw reply
* Re: [PATCH net-next] sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name
From: Brian Haley @ 2012-11-02 15:02 UTC (permalink / raw)
To: Pavel Emelyanov; +Cc: David Miller, Eric Dumazet, netdev@vger.kernel.org
In-Reply-To: <5093940B.6020207@parallels.com>
On 11/02/2012 05:36 AM, Pavel Emelyanov wrote:
>> +static int sock_getbindtodevice(struct sock *sk, char __user *optval,
>> + int __user *optlen, int len)
>> +{
>> + int ret = -ENOPROTOOPT;
>> +#ifdef CONFIG_NETDEVICES
>> + struct net *net = sock_net(sk);
>> + struct net_device *dev;
>> + char devname[IFNAMSIZ];
>> +
>> + if (sk->sk_bound_dev_if == 0) {
>> + len = 0;
>> + goto zero;
>> + }
>> +
>> + ret = -EINVAL;
>> + if (len < IFNAMSIZ)
>> + goto out;
>> +
>> + rcu_read_lock();
>> + dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if);
>> + if (dev)
>> + strcpy(devname, dev->name);
>
> This still races with the device name change, potentially providing
> a name which never existed in the system, doesn't it?
My only argument here is that SIOCGIFNAME has had this same code forever, and
noone has ever complained about that returning a garbled name. Even
dev_get_by_name() only holds an rcu lock when doing a strncmp().
We'd need to audit the whole kernel to catch all the places where we potentially
look at dev->name while it could change. Is it really worth it?
-Brian
^ permalink raw reply
* [PATCH 3/3] net: neterion: Do not break word unregister.
From: YOSHIFUJI Hideaki @ 2001-09-16 15:00 UTC (permalink / raw)
To: davem, netdev; +Cc: yoshfuji
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
drivers/net/ethernet/neterion/s2io.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
index de50547..c98decb 100644
--- a/drivers/net/ethernet/neterion/s2io.c
+++ b/drivers/net/ethernet/neterion/s2io.c
@@ -8239,7 +8239,8 @@ static int __init s2io_starter(void)
/**
* s2io_closer - Cleanup routine for the driver
- * Description: This function is the cleanup routine for the driver. It unregist * ers the driver.
+ * Description: This function is the cleanup routine for the driver. It
+ * unregisters the driver.
*/
static __exit void s2io_closer(void)
--
1.7.9.5
^ permalink raw reply related
* [PATCH 2/3] net: sh_eth: Fix a typo - replace regist with register.
From: YOSHIFUJI Hideaki @ 2001-09-16 15:00 UTC (permalink / raw)
To: davem, netdev; +Cc: yoshfuji
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
drivers/net/ethernet/renesas/sh_eth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index c8bfea0..3d70586 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -2286,7 +2286,7 @@ static int sh_mdio_init(struct net_device *ndev, int id,
for (i = 0; i < PHY_MAX_ADDR; i++)
mdp->mii_bus->irq[i] = PHY_POLL;
- /* regist mdio bus */
+ /* register mdio bus */
ret = mdiobus_register(mdp->mii_bus);
if (ret)
goto out_free_irq;
--
1.7.9.5
^ permalink raw reply related
* [PATCH RESEND] net: neterion: Do not break word unregister.
From: YOSHIFUJI Hideaki @ 2012-11-02 14:45 UTC (permalink / raw)
To: davem, netdev; +Cc: yoshfuji
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
drivers/net/ethernet/neterion/s2io.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
index de50547..c98decb 100644
--- a/drivers/net/ethernet/neterion/s2io.c
+++ b/drivers/net/ethernet/neterion/s2io.c
@@ -8239,7 +8239,8 @@ static int __init s2io_starter(void)
/**
* s2io_closer - Cleanup routine for the driver
- * Description: This function is the cleanup routine for the driver. It unregist * ers the driver.
+ * Description: This function is the cleanup routine for the driver. It
+ * unregisters the driver.
*/
static __exit void s2io_closer(void)
--
1.7.9.5
^ permalink raw reply related
* [PATCH RESEND] net: sh_eth: Fix a typo - replace regist with register.
From: YOSHIFUJI Hideaki @ 2012-11-02 14:45 UTC (permalink / raw)
To: davem, netdev; +Cc: yoshfuji
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
---
drivers/net/ethernet/renesas/sh_eth.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index c8bfea0..3d70586 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -2286,7 +2286,7 @@ static int sh_mdio_init(struct net_device *ndev, int id,
for (i = 0; i < PHY_MAX_ADDR; i++)
mdp->mii_bus->irq[i] = PHY_POLL;
- /* regist mdio bus */
+ /* register mdio bus */
ret = mdiobus_register(mdp->mii_bus);
if (ret)
goto out_free_irq;
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH 3/3] net: neterion: Do not break word unregister.
From: YOSHIFUJI Hideaki @ 2012-11-02 14:43 UTC (permalink / raw)
To: davem; +Cc: YOSHIFUJI Hideaki, netdev
In-Reply-To: <201211021439.qA2EdkbO004741@94.43.138.210.xn.2iij.net>
Sorry, subject and date are strange. I'm resending...
--yoshfuji
YOSHIFUJI Hideaki wrote:
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> ---
> drivers/net/ethernet/neterion/s2io.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
> index de50547..c98decb 100644
> --- a/drivers/net/ethernet/neterion/s2io.c
> +++ b/drivers/net/ethernet/neterion/s2io.c
> @@ -8239,7 +8239,8 @@ static int __init s2io_starter(void)
>
> /**
> * s2io_closer - Cleanup routine for the driver
> - * Description: This function is the cleanup routine for the driver. It unregist * ers the driver.
> + * Description: This function is the cleanup routine for the driver. It
> + * unregisters the driver.
> */
>
> static __exit void s2io_closer(void)
>
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox