[ovs-dev] [PATCH v3 05/13] connmgr: Make connmgr_wants_packet_in_on_miss() lock-free.

Ben Pfaff blp at ovn.org
Tue Sep 13 19:38:15 UTC 2016


On Mon, Sep 12, 2016 at 01:52:35PM -0700, Jarno Rajahalme wrote:
> Make connmgr_wants_packet_in_on_miss() use an atomic int instead of a
> list traversal taking the 'ofproto_mutex'.  This allows
> connmgr_wants_packet_in_on_miss() to be called also when
> 'ofproto_mutex' is already held, and makes it faster, too.
> 
> Remove unused ofproto_dpif_wants_packet_in_on_miss().
> 
> Signed-off-by: Jarno Rajahalme <jarno at ovn.org>
> ---
> v3: Fix the totally broken behavior with a help of a per-ofconn boolean.

I think that update_want_packet_in_on_miss() can be a little more
straightforward.  How about this?  I have not tested it.

static void
update_want_packet_in_on_miss(struct ofconn *ofconn)
{
    /* We want a packet-in on miss when controller_id is zero and OpenFlow is
     * lower than version 1.3. */
    enum ofputil_protocol p = ofconn->protocol;
    int new_want = (ofconn->controller_id == 0 &&
                    (p == OFPUTIL_P_NONE ||
                     ofputil_protocol_to_ofp_version(p) < OFP13_VERSION));

    /* Update the setting and the count if ncessary. */
    int old_want = ofconn->want_packet_in_on_miss;
    if (old_want != new_want) {
        atomic_int *dst = &ofconn->connmgr->want_packet_in_on_miss;
        int count;
        atomic_read_relaxed(dst, &count);
        atomic_store_relaxed(dst, count - old_want + new_want);

        ofconn->want_packet_in_on_miss = new_want;
    }
}

Acked-by: Ben Pfaff <blp at ovn.org>



More information about the dev mailing list