[libvirt] [PATCH v2 3/8] perf: implement a set of util functions for perf event

Ren, Qiaowei qiaowei.ren at intel.com
Wed Dec 9 00:46:02 UTC 2015


> -----Original Message-----
> From: Daniel P. Berrange [mailto:berrange at redhat.com]
> Sent: Tuesday, December 8, 2015 6:54 PM
> To: Ren, Qiaowei
> Cc: libvir-list at 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 at 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




More information about the libvir-list mailing list