Subject: Re: [PATCH v3 net-next 02/27] net: add RCU variant to search for netdev_adjacent link

From: Veaceslav Falico <[email-masked]>
Date: Tue, 17 Sep 2013 09:34:08 +0200

On Tue, Sep 17, 2013 at 02:23:18AM +0100, Ben Hutchings wrote:
>On Tue, 2013-09-17 at 02:46 +0200, Veaceslav Falico wrote:
>> Currently we have only the RTNL flavour, however we can traverse it while
>> holding only RCU, so add the RCU search. Add only one function that will be
>> used further, other functions can be added easily afterwards, if anyone
>> would need them.
>[...]
>> +static struct netdev_adjacent *__netdev_find_adj_rcu(struct net_device *dev,
>> +						     struct net_device *adj_dev,
>> +						     bool upper, bool neighbour)
>> +{
>> +	struct netdev_adjacent *adj;
>> +	struct list_head *adj_list;
>> +
>> +	if (neighbour)
>> +		adj_list = upper ? &dev->adj_list.upper :
>> +				   &dev->adj_list.lower;
>> +	else
>> +		adj_list = upper ? &dev->all_adj_list.upper :
>> +				   &dev->all_adj_list.lower;
>
>I think it would be clearer to make adj_list a parameter, rather than
>taking the dev and a pair of booleans.

Hm, true, indeed, will try to change in the next version.

Thank you!

>
>Ben.
>
>> +	list_for_each_entry_rcu(adj, adj_list, list) {
>> +		if (adj->dev == adj_dev)
>> +			return adj;
>> +	}
>> +	return NULL;
>> +}
>> +
>> +static struct netdev_adjacent *__netdev_lower_find_rcu(struct net_device *dev,
>> +							struct net_device *ldev)
>> +{
>> +	return __netdev_find_adj_rcu(dev, ldev, false, true);
>> +}
>> +
>>  static struct netdev_adjacent *__netdev_find_adj(struct net_device *dev,
>>  						 struct net_device *adj_dev,
>>  						 bool upper, bool neighbour)
>
>-- 
>Ben Hutchings, Staff Engineer, Solarflare
>Not speaking for my employer; that's the marketing department's job.
>They asked us to note that Solarflare product names are trademarked.
>