[ovs-dev] [optimize 10/26] ofproto-dpif: Avoid computing flow hash multiple times.

Ben Pfaff blp at nicira.com
Wed Apr 18 16:21:59 UTC 2012


On Tue, Apr 17, 2012 at 05:08:52PM -0700, Ethan Jackson wrote:
> > +    facet = facet_lookup_valid(ofproto, flow, miss->hmap_node.hash);
> 
> Pulling the hash out of hmap_node directly makes me a bit nervous.
> Does it make sense to store the hash directly in struct flow_miss with
> a comment about how it's computed?  At minimum I think we should
> document that handle_flow_miss() expects 'miss' to be in a hash table
> which uses flow_hash() with a basis of zero as it's hash function.

OK, I added to handle_flow_miss():

    uint32_t hash;

    /* The caller must ensure that miss->hmap_node.hash contains
     * flow_hash(miss->flow, 0). */
    hash = miss->hmap_node.hash;

and used 'hash' in place of miss->hmap_node.hash.

Is that better?



More information about the dev mailing list