[ovs-dev] [PATCH V4 2/3] ofproto-dpif: Use sequence number to wake up main thread for packet-in I/O.

Joe Stringer joe at wand.net.nz
Thu Apr 24 12:54:34 UTC 2014


Good to see this as a separate change.

Acked-by: Joe Stringer <joestringer at nicira.com>


On 18 April 2014 08:32, Alex Wang <alexw at nicira.com> wrote:

> This commit adds per 'struct ofproto_dpif' sequence number for
> packet-in I/O.  Whenever a packet-in is inserted into the 'pins'
> queue, the inserting thread will change the sequence number to
> wake up the main thread.
>
> Signed-off-by: Alex Wang <alexw at nicira.com>
>
> ---
> V4:
> - this is a functional change separated from the next patch.
> ---
>  ofproto/ofproto-dpif.c |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index 5b0f6bd..f15c399 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -317,6 +317,8 @@ struct ofproto_dpif {
>
>      /* Work queues. */
>      struct guarded_list pins;      /* Contains "struct
> ofputil_packet_in"s. */
> +    struct seq *pins_seq;          /* For notifying 'pins' reception. */
> +    uint64_t pins_seqno;
>  };
>
>  /* All existing ofproto_dpif instances, indexed by ->up.name. */
> @@ -375,6 +377,9 @@ ofproto_dpif_send_packet_in(struct ofproto_dpif
> *ofproto,
>          COVERAGE_INC(packet_in_overflow);
>          free(CONST_CAST(void *, pin->up.packet));
>          free(pin);
> +    } else {
> +        /* Wakes up main thread for packet-in I/O. */
> +        seq_change(ofproto->pins_seq);
>      }
>  }
>
> @@ -1148,6 +1153,9 @@ construct(struct ofproto *ofproto_)
>      sset_init(&ofproto->port_poll_set);
>      ofproto->port_poll_errno = 0;
>      ofproto->change_seq = 0;
> +    ofproto->pins_seq = seq_create();
> +    ofproto->pins_seqno = seq_read(ofproto->pins_seq);
> +
>
>      SHASH_FOR_EACH_SAFE (node, next, &init_ofp_ports) {
>          struct iface_hint *iface_hint = node->data;
> @@ -1321,6 +1329,8 @@ destruct(struct ofproto *ofproto_)
>      ovs_mutex_destroy(&ofproto->stats_mutex);
>      ovs_mutex_destroy(&ofproto->vsp_mutex);
>
> +    seq_destroy(ofproto->pins_seq);
> +
>      close_dpif_backer(ofproto->backer);
>  }
>
> @@ -1353,6 +1363,12 @@ run(struct ofproto *ofproto_)
>          }
>      }
>
> +    /* Always updates the ofproto->pins_seqno to avoid frequent wakeup
> during
> +     * flow restore.  Even though nothing is processed during flow
> restore,
> +     * all queued 'pins' will be handled immediately when flow restore
> +     * completes. */
> +    ofproto->pins_seqno = seq_read(ofproto->pins_seq);
> +
>      if (ofproto->netflow) {
>          netflow_run(ofproto->netflow);
>      }
> @@ -1462,6 +1478,7 @@ wait(struct ofproto *ofproto_)
>      }
>
>      seq_wait(udpif_dump_seq(ofproto->backer->udpif), ofproto->dump_seq);
> +    seq_wait(ofproto->pins_seq, ofproto->pins_seqno);
>  }
>
>  static void
> --
> 1.7.9.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20140425/10131828/attachment-0005.html>


More information about the dev mailing list