2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev: Globally track port status changes

Previously, we tracked status changes for ofports on a per-device basis.
Each time in the main thread's loop, we would inspect every ofport
to determine whether the status had changed for corresponding devices.

This patch replaces the per-netdev change_seq with a global 'struct seq'
which tracks status change for all ports. In the average case where
ports are not constantly going up or down, this allows us to check the
sequence once per main loop and not poll any ports. In the worst case,
execution is expected to be similar to how it is currently.

In a test environment of 5000 internal ports and 50 tunnel ports with
bfd, this reduces average CPU usage of the main thread from about 40% to
about 35%.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
This commit is contained in:
Joe Stringer
2013-12-13 03:33:46 +00:00
committed by Ethan Jackson
parent 2ffe6042ad
commit da4a619179
14 changed files with 140 additions and 171 deletions

View File

@@ -48,6 +48,7 @@
#include <string.h>
#include <unistd.h>
#include "connectivity.h"
#include "coverage.h"
#include "dpif-linux.h"
#include "dynamic-string.h"
@@ -65,6 +66,7 @@
#include "packets.h"
#include "poll-loop.h"
#include "rtnetlink-link.h"
#include "seq.h"
#include "shash.h"
#include "socket-util.h"
#include "sset.h"
@@ -357,7 +359,6 @@ struct netdev_linux {
struct ovs_mutex mutex;
unsigned int cache_valid;
unsigned int change_seq;
bool miimon; /* Link status of last poll. */
long long int miimon_interval; /* Miimon Poll rate. Disabled if <= 0. */
@@ -585,10 +586,7 @@ netdev_linux_changed(struct netdev_linux *dev,
unsigned int ifi_flags, unsigned int mask)
OVS_REQUIRES(dev->mutex)
{
dev->change_seq++;
if (!dev->change_seq) {
dev->change_seq++;
}
seq_change(connectivity_seq_get());
if ((dev->ifi_flags ^ ifi_flags) & IFF_RUNNING) {
dev->carrier_resets++;
@@ -640,7 +638,6 @@ static void
netdev_linux_common_construct(struct netdev_linux *netdev)
{
ovs_mutex_init(&netdev->mutex);
netdev->change_seq = 1;
}
/* Creates system and internal devices. */
@@ -2597,19 +2594,6 @@ netdev_linux_update_flags(struct netdev *netdev_, enum netdev_flags off,
return error;
}
static unsigned int
netdev_linux_change_seq(const struct netdev *netdev_)
{
struct netdev_linux *netdev = netdev_linux_cast(netdev_);
unsigned int change_seq;
ovs_mutex_lock(&netdev->mutex);
change_seq = netdev->change_seq;
ovs_mutex_unlock(&netdev->mutex);
return change_seq;
}
#define NETDEV_LINUX_CLASS(NAME, CONSTRUCT, GET_STATS, SET_STATS, \
GET_FEATURES, GET_STATUS) \
{ \
@@ -2668,8 +2652,6 @@ netdev_linux_change_seq(const struct netdev *netdev_)
\
netdev_linux_update_flags, \
\
netdev_linux_change_seq, \
\
netdev_linux_rx_alloc, \
netdev_linux_rx_construct, \
netdev_linux_rx_destruct, \