[ovs-dev] [PATCH V2 4/4] datapath: Compact mask list array.

Pravin Shelar pshelar at nicira.com
Tue Apr 29 18:09:18 UTC 2014


On Wed, Apr 23, 2014 at 3:38 PM, Thomas Graf <tgraf at redhat.com> wrote:
> On 04/23/2014 05:49 PM, Pravin B Shelar wrote:
>>
>> Along with flow-table rehashing OVS can compact masks array.  This
>> allows us to calculate highest index for mask array.
>>
>> Signed-off-by: Pravin B Shelar <pshelar at nicira.com>
>
>
> Looks great in general, see comment below.
>
>
>> ---
>>   datapath/flow_table.c |   24 ++++++++++++++++++++----
>>   datapath/flow_table.h |    2 +-
>>   2 files changed, 21 insertions(+), 5 deletions(-)
>>
>> diff --git a/datapath/flow_table.c b/datapath/flow_table.c
>> index c8bd9d1..ea4100f 100644
>> --- a/datapath/flow_table.c
>> +++ b/datapath/flow_table.c
>> @@ -230,6 +230,7 @@ static struct mask_array *tbl_mask_array_alloc(int
>> size)
>>
>>         new->count = 0;
>>         new->max = size;
>> +       new->hi_index = 0;
>>
>>         return new;
>>   }
>> @@ -252,6 +253,8 @@ static int tbl_mask_array_realloc(struct flow_table
>> *tbl, int size)
>>                                 new->masks[new->count++] = old->masks[i];
>>                 }
>>         }
>> +
>> +       new->hi_index = new->count;
>>         rcu_assign_pointer(tbl->mask_array, new);
>>
>>         if (old)
>> @@ -260,6 +263,17 @@ static int tbl_mask_array_realloc(struct flow_table
>> *tbl, int size)
>>         return 0;
>>   }
>>
>> +static void tbl_mask_array_compact(struct flow_table *tbl)
>> +{
>> +       struct mask_array *ma;
>> +       int size;
>> +
>> +       ma = ovsl_dereference(tbl->mask_array);
>> +
>> +       size = roundup(ma->count, MASK_ARRAY_SIZE_MIN);
>> +       tbl_mask_array_realloc(tbl, size);
>
>
> I think you have to clear the masked cache as well. There might still
> be cached masks pointing to the now out of bounds array if you compact
> after having removed flow masks, right?

right, I forgot to add check in the lookup. sending v3.



More information about the dev mailing list