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

ofproto-dpif-upcall: Add memory usage stats.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Ethan Jackson
2013-11-20 17:41:02 -08:00
parent a6b7506dab
commit 1c030aa570
7 changed files with 60 additions and 0 deletions

View File

@@ -265,6 +265,23 @@ udpif_revalidate(struct udpif *udpif)
udpif_drop_key_clear(udpif);
}
void
udpif_get_memory_usage(struct udpif *udpif, struct simap *usage)
{
size_t i;
simap_increase(usage, "dispatchers", 1);
simap_increase(usage, "flow_dumpers", 1);
simap_increase(usage, "handlers", udpif->n_handlers);
for (i = 0; i < udpif->n_handlers; i++) {
struct handler *handler = &udpif->handlers[i];
ovs_mutex_lock(&handler->mutex);
simap_increase(usage, "handler upcalls", handler->n_upcalls);
ovs_mutex_unlock(&handler->mutex);
}
}
/* Destroys and deallocates 'upcall'. */
static void
upcall_destroy(struct upcall *upcall)

View File

@@ -39,6 +39,8 @@ void udpif_destroy(struct udpif *);
void udpif_wait(struct udpif *);
void udpif_revalidate(struct udpif *);
void udpif_get_memory_usage(struct udpif *, struct simap *usage);
/* udpif figures out how to forward packets, and does forward them, but it
* can't set up datapath flows on its own. This interface passes packet

View File

@@ -1545,6 +1545,17 @@ get_memory_usage(const struct ofproto *ofproto_, struct simap *usage)
simap_increase(usage, "subfacets", n_subfacets);
}
static void
type_get_memory_usage(const char *type, struct simap *usage)
{
struct dpif_backer *backer;
backer = shash_find_data(&all_dpif_backers, type);
if (backer) {
udpif_get_memory_usage(backer->udpif, usage);
}
}
static void
flush(struct ofproto *ofproto_)
{
@@ -6146,6 +6157,7 @@ const struct ofproto_class ofproto_dpif_class = {
run,
wait,
get_memory_usage,
type_get_memory_usage,
flush,
get_features,
get_tables,

View File

@@ -783,6 +783,12 @@ struct ofproto_class {
void (*get_memory_usage)(const struct ofproto *ofproto,
struct simap *usage);
/* Adds some memory usage statistics for the implementation of 'type'
* into 'usage', for use with memory_report().
*
* This function is optional. */
void (*type_get_memory_usage)(const char *type, struct simap *usage);
/* Every "struct rule" in 'ofproto' is about to be deleted, one by one.
* This function may prepare for that, for example by clearing state in
* advance. It should *not* actually delete any "struct rule"s from

View File

@@ -1619,6 +1619,19 @@ ofproto_get_memory_usage(const struct ofproto *ofproto, struct simap *usage)
connmgr_get_memory_usage(ofproto->connmgr, usage);
}
void
ofproto_type_get_memory_usage(const char *datapath_type, struct simap *usage)
{
const struct ofproto_class *class;
datapath_type = ofproto_normalize_type(datapath_type);
class = ofproto_class_find__(datapath_type);
if (class && class->type_get_memory_usage) {
class->type_get_memory_usage(datapath_type, usage);
}
}
void
ofproto_get_ofproto_controller_info(const struct ofproto *ofproto,
struct shash *info)

View File

@@ -177,6 +177,7 @@ void ofproto_wait(struct ofproto *);
bool ofproto_is_alive(const struct ofproto *);
void ofproto_get_memory_usage(const struct ofproto *, struct simap *);
void ofproto_type_get_memory_usage(const char *datapath_type, struct simap *);
/* A port within an OpenFlow switch.
*

View File

@@ -2453,6 +2453,15 @@ void
bridge_get_memory_usage(struct simap *usage)
{
struct bridge *br;
struct sset types;
const char *type;
sset_init(&types);
ofproto_enumerate_types(&types);
SSET_FOR_EACH (type, &types) {
ofproto_type_get_memory_usage(type, usage);
}
sset_destroy(&types);
HMAP_FOR_EACH (br, node, &all_bridges) {
ofproto_get_memory_usage(br->ofproto, usage);