datapath: keep mask array compact when deleting mask
authorAndy Zhou <azhou@nicira.com>
Mon, 16 Jun 2014 19:45:04 +0000 (12:45 -0700)
committerPravin B Shelar <pshelar@nicira.com>
Tue, 1 Jul 2014 19:57:27 +0000 (12:57 -0700)
commit20941fe5ef0e3e044f963443abfab2ef987f312e
tree06412823883eea689739da21b6d3f0c103dcd39a
parent468647cce0d1a8be688c7b5557a06a1b697946b9
datapath: keep mask array compact when deleting mask

When deleting a mask from the mask array, we always move the last entry
into its current location. Another approach can be NULL in its
current place, and periodically compact it.

The approach taken by this patch is more efficient during run
time.  During look up, fast path packet don't have to skip over NULL
pointers.

A more important advantage of this approach is that it tries to
keep the mask array index stable by avoiding periodic index
reshuffle.

This patch implements an optimization to further promote index
stability.  By leaving the last entry value intact when moving it
to a new location, the old cache index can 'fix' themselves, by noticing
the index in the cache is outside the valid mask array region. The
new index can be found by scanning the mask pointer within the valid
rtegion.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
datapath/flow_table.c