-----Original Message-----
From: Daniel P. Berrange [mailto:berrange@redhat.com]
Sent: Tuesday, December 8, 2015 6:54 PM
To: Ren, Qiaowei
Cc: libvir-list(a)redhat.com; Jiri Denemark
Subject: Re: [PATCH v2 3/8] perf: implement a set of util functions for perf event
On Mon, Dec 07, 2015 at 03:53:54PM +0800, Qiaowei Ren wrote:
> This patch implement a set of interfaces for perf event. Based on
> these interfaces, we can implement internal driver API for perf, and
> get the results of perf conuter you care about.
>
> Signed-off-by: Qiaowei Ren <qiaowei.ren(a)intel.com>
> ---
> include/libvirt/virterror.h | 1 +
> src/Makefile.am | 1 +
> src/libvirt_private.syms | 12 ++
> src/util/virerror.c | 1 +
> src/util/virperf.c | 298
++++++++++++++++++++++++++++++++++++++++++++
> src/util/virperf.h | 61 +++++++++
> 6 files changed, 374 insertions(+)
> create mode 100644 src/util/virperf.c create mode 100644
> src/util/virperf.h
>
> +int
> +virPerfEventDisable(virPerfPtr perf,
> + virPerfEventType type) {
> + virPerfEventPtr event = virPerfGetEvent(perf, type);
> + if (event == NULL)
> + return -1;
> +
> + if (ioctl(event->fd, PERF_EVENT_IOC_DISABLE) < 0) {
> + virReportSystemError(errno,
> + _("Unable to disable perf event type=%d"),
> + event->type);
> + return -1;
> + }
Since we're closing the file handle next, is there any benefit in doing this ioctl()
?
I guess that VIR_FORCE_CLOSE() will just close the file handle, but the perf event have to
be disabled before this. In fact it is from the example in man page of perf_event_open().
Thanks,
Qiaowei