Subject: Re: [PATCH 4/6] vlan: Optimize multiple unregistration

From: Eric Dumazet <[email-masked]>
Date: Thu, 29 Oct 2009 15:30:14 +0100

Patrick McHardy a écrit :
> Patrick McHardy wrote:
>> Eric Dumazet wrote:
>>> Patrick McHardy a écrit :
>>>>> +{
>>>>> +	LIST_HEAD(list);
>>>>> +	int i;
>>>>> +	struct net_device *vlandev;
>>>>> +	struct vlan_group save;
>>>>> +
>>>>> +	memcpy(&save, grp, sizeof(save));
>>>>> +	memset(&grp->vlan_devices_arrays, 0, sizeof(grp->vlan_devices_arrays));
>>>> This shouldn't be necessary since the lower device is already in the
>>>> process of being unregistered. If it was necessary, it could cause
>>>> crashes since the individual pointers are not set to zero atomically.
>>>> Or maybe I'm misunderstanding the purpose entirely :)
>>> Very good point indeed, even if in practice memset() use long word transferts
>>>
>>> I'll make a cleanup patch, or do you want to do it ?
>> I can take care of this, patch will follow shortly.
> 
> How about this? I moved the code back into vlan_device_event() since
> its now only a very minimal change to the original code.
> 
> vlan-orig.diff contains the diff between the original code and the
> code after this patch for reference.
> 
> 

I have no problem with this solution, but I wonder why you re-added the curious

			/* unregistration of last vlan destroys group, abort
			 * afterwards */
			if (grp->nr_vlans == 1)
				i = VLAN_GROUP_ARRAY_LEN;

			unregister_vlan_dev(vlandev, &list);

while doing

	unregister_vlan_dev(vlandev, &list);
	if (grp->nr_vlans == 0)
		break;

seems more natural :)