projects
/
cascardo
/
ovs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ovsdb-server: Fix a reference count leak bug
[cascardo/ovs.git]
/
lib
/
perf-counter.c
diff --git
a/lib/perf-counter.c
b/lib/perf-counter.c
index
e72ff29
..
62e2d76
100644
(file)
--- a/
lib/perf-counter.c
+++ b/
lib/perf-counter.c
@@
-15,7
+15,9
@@
*/
/* This implementation only applies to the Linux platform. */
*/
/* This implementation only applies to the Linux platform. */
-#ifdef __linux__
+
+#include <config.h>
+#if defined(__linux__) && defined(HAVE_LINUX_PERF_EVENT_H)
#include <stddef.h>
#include <sys/types.h>
#include <stddef.h>
#include <sys/types.h>
@@
-24,24
+26,20
@@
#include <sys/ioctl.h>
#include <linux/perf_event.h>
#include <asm/unistd.h>
#include <sys/ioctl.h>
#include <linux/perf_event.h>
#include <asm/unistd.h>
-#include <config.h>
#include "dynamic-string.h"
#include "dynamic-string.h"
-#include "openvswitch/vlog.h"
#include "perf-counter.h"
#include "shash.h"
#include "util.h"
#include "perf-counter.h"
#include "shash.h"
#include "util.h"
-VLOG_DEFINE_THIS_MODULE(perf_counter);
-
-static struct shash perf_counters;
+static struct shash perf_counters = SHASH_INITIALIZER(&perf_counters);
static int fd__ = 0;
uint64_t
perf_counter_read(uint64_t *counter)
{
static int fd__ = 0;
uint64_t
perf_counter_read(uint64_t *counter)
{
- i
f (fd__ > 0) {
- read(fd__, counter, sizeof(*counter));
-
} else
{
+ i
nt size = sizeof *counter;
+
+
if (fd__ <= 0 || read(fd__, counter, size) < size)
{
*counter = 0;
}
*counter = 0;
}
@@
-75,9
+73,7
@@
perf_event_setup(void)
pe.exclude_hv = 1;
fd__ = perf_event_open(&pe, 0, -1, -1, 0);
pe.exclude_hv = 1;
fd__ = perf_event_open(&pe, 0, -1, -1, 0);
- if (fd__ == -1) {
- VLOG_INFO("Peformance counter is not available on this platform.");
- } else {
+ if (fd__ > 0) {
ioctl(fd__, PERF_EVENT_IOC_RESET, 0);
ioctl(fd__, PERF_EVENT_IOC_ENABLE, 0);
}
ioctl(fd__, PERF_EVENT_IOC_RESET, 0);
ioctl(fd__, PERF_EVENT_IOC_ENABLE, 0);
}
@@
-115,8
+111,8
@@
perf_counter_to_ds(struct ds *ds, struct perf_counter *pfc)
ratio = 0.0;
}
ratio = 0.0;
}
- ds_put_format(ds, "%-40s%12
lu%12lu%12.1f\n", pfc->name, pfc->n_events
,
- pfc->total_count, ratio);
+ ds_put_format(ds, "%-40s%12
"PRIu64"%12"PRIu64"%12.1f\n"
,
+ pfc->
name, pfc->n_events, pfc->
total_count, ratio);
}
static void
}
static void