ofproto: Use netdev's 'change_seq' to reduce port modification check.
authorAlex Wang <alexw@nicira.com>
Thu, 3 Apr 2014 17:07:20 +0000 (10:07 -0700)
committerAlex Wang <alexw@nicira.com>
Thu, 10 Apr 2014 19:55:28 +0000 (12:55 -0700)
This commit uses the 'change_seq' in 'struct netdev' to determine
whether to update the 'ofport'.  This helps eliminate unnecessary
update.

In the experiment of configuring 5K internal port, there is neither
observable configuration overhead nor additional cpu consumption
after configuration finishes.  When one internal port state is
flapped every 0.3 second, this commit reduces the cpu utilization
of ovs-vswitchd thread from 40 to 12.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-provider.h
ofproto/ofproto.c

index bfa0235..0e22b7c 100644 (file)
@@ -174,6 +174,7 @@ struct ofport {
     struct netdev *netdev;
     struct ofputil_phy_port pp;
     ofp_port_t ofp_port;        /* OpenFlow port number. */
+    uint64_t change_seq;
     long long int created;      /* Time created, in msec. */
     int mtu;
 };
index a517264..436a745 100644 (file)
@@ -1514,7 +1514,13 @@ ofproto_run(struct ofproto *p)
          * need this two-phase approach. */
         sset_init(&devnames);
         HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
-            sset_add(&devnames, netdev_get_name(ofport->netdev));
+            uint64_t port_change_seq;
+
+            port_change_seq = netdev_get_change_seq(ofport->netdev);
+            if (ofport->change_seq != port_change_seq) {
+                ofport->change_seq = port_change_seq;
+                sset_add(&devnames, netdev_get_name(ofport->netdev));
+            }
         }
         SSET_FOR_EACH (devname, &devnames) {
             update_port(p, devname);
@@ -2210,6 +2216,7 @@ ofport_install(struct ofproto *p,
     }
     ofport->ofproto = p;
     ofport->netdev = netdev;
+    ofport->change_seq = netdev_get_change_seq(netdev);
     ofport->pp = *pp;
     ofport->ofp_port = pp->port_no;
     ofport->created = time_msec();
@@ -2446,6 +2453,7 @@ update_port(struct ofproto *ofproto, const char *name)
              * Don't close the old netdev yet in case port_modified has to
              * remove a retained reference to it.*/
             port->netdev = netdev;
+            port->change_seq = netdev_get_change_seq(netdev);
 
             if (port->ofproto->ofproto_class->port_modified) {
                 port->ofproto->ofproto_class->port_modified(port);