Patchwork [06/10] s390: use RCU to walk list of network devices

login
register
mail settings
Submitter stephen hemminger
Date Nov. 10, 2009, 5:54 p.m.
Message ID <20091110175647.547660685@vyatta.com>
Download mbox | patch
Permalink /patch/38078/
State Accepted
Delegated to: David Miller
Headers show

Comments

stephen hemminger - Nov. 10, 2009, 5:54 p.m.
This is similar to other cases where for_each_netdev_rcu
can be used when gathering information.

By inspection, don't have platform or cross-build environment
to validate.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Eric Dumazet - Nov. 10, 2009, 6:27 p.m.
Stephen Hemminger a écrit :
> This is similar to other cases where for_each_netdev_rcu
> can be used when gathering information.
> 
> By inspection, don't have platform or cross-build environment
> to validate.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> 
> --- a/arch/s390/appldata/appldata_net_sum.c	2009-11-09 22:19:05.593480476 -0800
> +++ b/arch/s390/appldata/appldata_net_sum.c	2009-11-10 09:28:38.335438652 -0800
> @@ -83,8 +83,9 @@ static void appldata_get_net_sum_data(vo
>  	rx_dropped = 0;
>  	tx_dropped = 0;
>  	collisions = 0;
> -	read_lock(&dev_base_lock);
> -	for_each_netdev(&init_net, dev) {
> +
> +	rcu_read_lock();
> +	for_each_netdev_rcu(&init_net, dev) {
>  		const struct net_device_stats *stats = dev_get_stats(dev);
>  
>  		rx_packets += stats->rx_packets;
> @@ -98,7 +99,8 @@ static void appldata_get_net_sum_data(vo
>  		collisions += stats->collisions;
>  		i++;
>  	}
> -	read_unlock(&dev_base_lock);
> +	rcu_read_unlock();
> +
>  	net_data->nr_interfaces = i;
>  	net_data->rx_packets = rx_packets;
>  	net_data->tx_packets = tx_packets;
> 

Not sure if dev_get_stats(dev) could sleep on some devices...

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
stephen hemminger - Nov. 10, 2009, 6:29 p.m.
On Tue, 10 Nov 2009 19:27:11 +0100
Eric Dumazet <eric.dumazet@gmail.com> wrote:

> Stephen Hemminger a écrit :
> > This is similar to other cases where for_each_netdev_rcu
> > can be used when gathering information.
> > 
> > By inspection, don't have platform or cross-build environment
> > to validate.
> > 
> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> > 
> > 
> > --- a/arch/s390/appldata/appldata_net_sum.c	2009-11-09 22:19:05.593480476 -0800
> > +++ b/arch/s390/appldata/appldata_net_sum.c	2009-11-10 09:28:38.335438652 -0800
> > @@ -83,8 +83,9 @@ static void appldata_get_net_sum_data(vo
> >  	rx_dropped = 0;
> >  	tx_dropped = 0;
> >  	collisions = 0;
> > -	read_lock(&dev_base_lock);
> > -	for_each_netdev(&init_net, dev) {
> > +
> > +	rcu_read_lock();
> > +	for_each_netdev_rcu(&init_net, dev) {
> >  		const struct net_device_stats *stats = dev_get_stats(dev);
> >  
> >  		rx_packets += stats->rx_packets;
> > @@ -98,7 +99,8 @@ static void appldata_get_net_sum_data(vo
> >  		collisions += stats->collisions;
> >  		i++;
> >  	}
> > -	read_unlock(&dev_base_lock);
> > +	rcu_read_unlock();
> > +
> >  	net_data->nr_interfaces = i;
> >  	net_data->rx_packets = rx_packets;
> >  	net_data->tx_packets = tx_packets;
> > 
> 
> Not sure if dev_get_stats(dev) could sleep on some devices...
> 

It would have already been broken since dev_get_stats is previously
called with read_lock(), and sleeping with any lock held causes warning.
Eric Dumazet - Nov. 10, 2009, 6:40 p.m.
Stephen Hemminger a écrit :
> This is similar to other cases where for_each_netdev_rcu
> can be used when gathering information.
> 
> By inspection, don't have platform or cross-build environment
> to validate.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> 

Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Nov. 11, 2009, 6:49 a.m.
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 10 Nov 2009 19:40:42 +0100

> Stephen Hemminger a écrit :
>> This is similar to other cases where for_each_netdev_rcu
>> can be used when gathering information.
>> 
>> By inspection, don't have platform or cross-build environment
>> to validate.
>> 
>> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>> 
>> 
> 
> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/arch/s390/appldata/appldata_net_sum.c	2009-11-09 22:19:05.593480476 -0800
+++ b/arch/s390/appldata/appldata_net_sum.c	2009-11-10 09:28:38.335438652 -0800
@@ -83,8 +83,9 @@  static void appldata_get_net_sum_data(vo
 	rx_dropped = 0;
 	tx_dropped = 0;
 	collisions = 0;
-	read_lock(&dev_base_lock);
-	for_each_netdev(&init_net, dev) {
+
+	rcu_read_lock();
+	for_each_netdev_rcu(&init_net, dev) {
 		const struct net_device_stats *stats = dev_get_stats(dev);
 
 		rx_packets += stats->rx_packets;
@@ -98,7 +99,8 @@  static void appldata_get_net_sum_data(vo
 		collisions += stats->collisions;
 		i++;
 	}
-	read_unlock(&dev_base_lock);
+	rcu_read_unlock();
+
 	net_data->nr_interfaces = i;
 	net_data->rx_packets = rx_packets;
 	net_data->tx_packets = tx_packets;