[ovs-dev] [mlhash2 2/2] mac-learning: Simplify memory management.

Ben Pfaff blp at nicira.com
Fri Jul 22 22:45:31 UTC 2011


On Fri, Jul 22, 2011 at 01:36:26PM -0700, Ethan Jackson wrote:
> The mac-learning implementation used a free list to keep track of
> statically allocated table entries.  This made the code slightly
> more difficult to understand than the more straightforward heap
> based strategy implemented by this patch.

This should also update the comment on the declaration of lru_node in
struct mac_entry (it's never a member of a free list anymore).

I'd add a call to hmap_shrink() into mac_learning_flush().

In mac_learning_insert(), instead of trying to avoid a free() and
malloc() if the table is full, I'd just do

        if (hmap_count(&ml->table) >= MAC_MAX) {
            get_lru(ml, &e);
            mac_learning_expire(ml, e);
        }

The comment on mac_learning_expire() still mentions a free list.



More information about the dev mailing list