[libvirt] [PATCH go v2] Add support for perf events

Nitesh Konkar posted 1 patch 7 years, 1 month ago
Failed in applying to current master (apply log)
There is a newer version of this series
connect.go      | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
domain.go       | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
domain_compat.h | 36 ++++++++++++++++++++++++++++++++++++
3 files changed, 144 insertions(+)
[libvirt] [PATCH go v2] Add support for perf events
Posted by Nitesh Konkar 7 years, 1 month ago
Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
---
 connect.go      | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 domain.go       | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 domain_compat.h | 36 ++++++++++++++++++++++++++++++++++++
 3 files changed, 144 insertions(+)

diff --git a/connect.go b/connect.go
index 3c53485..e24cf66 100644
--- a/connect.go
+++ b/connect.go
@@ -2264,6 +2264,24 @@ type DomainStatsPerf struct {
 	StalledCyclesBackend     uint64
 	RefCpuCyclesSet          bool
 	RefCpuCycles             uint64
+        CpuClockSet              bool
+        CpuClock                 uint64
+        TaskClockSet             bool
+        TaskClock                uint64
+        PageFaultsSet            bool
+        PageFaults               uint64
+        ContextSwitchesSet       bool
+        ContextSwitches          uint64
+        CpuMigrationsSet         bool
+        CpuMigrations            uint64
+        PageFaultsMinSet         bool
+        PageFaultsMin            uint64
+        PageFaultsMajSet         bool
+        PageFaultsMaj            uint64
+        AlignmentFaultsSet       bool
+        AlignmentFaults          uint64
+        EmulationFaultsSet       bool
+        EmulationFaults          uint64
 }
 
 func getDomainStatsPerfFieldInfo(params *DomainStatsPerf) map[string]typedParamsFieldInfo {
@@ -2320,6 +2338,42 @@ func getDomainStatsPerfFieldInfo(params *DomainStatsPerf) map[string]typedParams
 			set: &params.RefCpuCyclesSet,
 			ul:  &params.RefCpuCycles,
 		},
+                "perf.cpu_clock": typedParamsFieldInfo{
+                        set: &params.CpuClockSet,
+                        ul:  &params.CpuClock,
+                },
+                "perf.task_clock": typedParamsFieldInfo{
+                        set: &params.TaskClockSet,
+                        ul:  &params.TaskClock,
+                },
+                "perf.page_faults": typedParamsFieldInfo{
+                        set: &params.PageFaultsSet,
+                        ul:  &params.PageFaults,
+                },
+                "perf.context_switches": typedParamsFieldInfo{
+                        set: &params.ContextSwitchesSet,
+                        ul:  &params.ContextSwitches,
+                },
+                "perf.cpu_migrations": typedParamsFieldInfo{
+                        set: &params.CpuMigrationsSet,
+                        ul:  &params.CpuMigrations,
+                },
+                "perf.page_faults_min": typedParamsFieldInfo{
+                        set: &params.PageFaultsMinSet,
+                        ul:  &params.PageFaultsMin,
+                },
+                "perf.page_faults_maj": typedParamsFieldInfo{
+                        set: &params.PageFaultsMajSet,
+                        ul:  &params.PageFaultsMaj,
+                },
+                "perf.alignment_faults": typedParamsFieldInfo{
+                        set: &params.AlignmentFaultsSet,
+                        ul:  &params.AlignmentFaults,
+                },
+                "perf.emulation_faults": typedParamsFieldInfo{
+                        set: &params.EmulationFaultsSet,
+                        ul:  &params.EmulationFaults,
+                },
 	}
 }
 
diff --git a/domain.go b/domain.go
index 2bd9852..1cb0b95 100644
--- a/domain.go
+++ b/domain.go
@@ -3195,6 +3195,24 @@ type DomainPerfEvents struct {
 	StalledCyclesBackend     bool
 	RefCpuCyclesSet          bool
 	RefCpuCycles             bool
+        CpuClockSet              bool
+        CpuClock                 bool
+        TaskClockSet             bool
+        TaskClock                bool
+        PageFaultsSet            bool
+        PageFaults               bool
+        ContextSwitchesSet       bool
+        ContextSwitches          bool
+        CpuMigrationsSet         bool
+        CpuMigrations            bool
+        PageFaultsMinSet         bool
+        PageFaultsMin            bool
+        PageFaultsMajSet         bool
+        PageFaultsMaj            bool
+        AlignmentFaultsSet       bool
+        AlignmentFaults          bool
+        EmulationFaultsSet       bool
+        EmulationFaults          bool
 }
 
 /* Remember to also update DomainStatsPerf in connect.go when adding to the stuct above */
@@ -3253,6 +3271,42 @@ func getDomainPerfEventsFieldInfo(params *DomainPerfEvents) map[string]typedPara
 			set: &params.RefCpuCyclesSet,
 			b:   &params.RefCpuCycles,
 		},
+                C.VIR_PERF_PARAM_CPU_CLOCK: typedParamsFieldInfo{
+                        set: &params.CpuClockSet,
+                        b:   &params.CpuClock,
+                },
+                C.VIR_PERF_PARAM_TASK_CLOCK: typedParamsFieldInfo{
+                        set: &params.TaskClockSet,
+                        b:   &params.TaskClock,
+                },
+                C.VIR_PERF_PARAM_PAGE_FAULTS: typedParamsFieldInfo{
+                        set: &params.PageFaultsSet,
+                        b:   &params.PageFaults,
+                },
+                C.VIR_PERF_PARAM_CONTEXT_SWITCHES: typedParamsFieldInfo{
+                        set: &params.ContextSwitchesSet,
+                        b:   &params.ContextSwitches,
+                },
+                C.VIR_PERF_PARAM_CPU_MIGRATIONS: typedParamsFieldInfo{
+                        set: &params.CpuMigrationsSet,
+                        b:   &params.CpuMigrations,
+                },
+                C.VIR_PERF_PARAM_PAGE_FAULTS_MIN: typedParamsFieldInfo{
+                        set: &params.PageFaultsMinSet,
+                        b:   &params.PageFaultsMin,
+                },
+                C.VIR_PERF_PARAM_PAGE_FAULTS_MAJ: typedParamsFieldInfo{
+                        set: &params.PageFaultsMajSet,
+                        b:   &params.PageFaultsMaj,
+                },
+                C.VIR_PERF_PARAM_ALIGNMENT_FAULTS: typedParamsFieldInfo{
+                        set: &params.AlignmentFaultsSet,
+                        b:   &params.AlignmentFaults,
+                },
+                C.VIR_PERF_PARAM_REF_EMULATION_FAULTS: typedParamsFieldInfo{
+                        set: &params.EmulationFaultsSet,
+                        b:   &params.EmulationFaults,
+                },
 	}
 }
 
diff --git a/domain_compat.h b/domain_compat.h
index 9540435..a114173 100644
--- a/domain_compat.h
+++ b/domain_compat.h
@@ -45,6 +45,42 @@
 #define VIR_PERF_PARAM_REF_CPU_CYCLES "ref_cpu_cycles"
 #endif
 
+#ifndef VIR_PERF_PARAM_CPU_CLOCK
+#define VIR_PERF_PARAM_CPU_CLOCK "cpu_clock"
+#endif
+
+#ifndef VIR_PERF_PARAM_TASK_CLOCK
+#define VIR_PERF_PARAM_TASK_CLOCK "task_clock"
+#endif
+
+#ifndef VIR_PERF_PARAM_PAGE_FAULTS
+#define VIR_PERF_PARAM_PAGE_FAULTS "page_faults"
+#endif
+
+#ifndef VIR_PERF_PARAM_CONTEXT_SWITCHES
+#define VIR_PERF_PARAM_CONTEXT_SWITCHES "context_switches"
+#endif
+
+#ifndef VIR_PERF_PARAM_CPU_MIGRATIONS
+#define VIR_PERF_PARAM_CPU_MIGRATIONS "cpu_migrations"
+#endif
+
+#ifndef VIR_PERF_PARAM_PAGE_FAULTS_MIN
+#define VIR_PERF_PARAM_PAGE_FAULTS_MIN "page_faults_min"
+#endif
+
+#ifndef VIR_PERF_PARAM_PAGE_FAULTS_MAJ
+#define VIR_PERF_PARAM_PAGE_FAULTS_MAJ "page_faults_maj"
+#endif
+
+#ifndef VIR_PERF_PARAM_ALIGNMENT_FAULTS
+#define VIR_PERF_PARAM__ALIGNMENT_FAULTS "alignment_faults"
+#endif
+
+#ifndef VIR_PERF_PARAM_EMULATION_FAULTS
+#define VIR_PERF_PARAM_EMULATION_FAULTS "emulation_faults"
+#endif
+
 #ifndef VIR_DOMAIN_EVENT_ID_METADATA_CHANGE
 #define VIR_DOMAIN_EVENT_ID_METADATA_CHANGE 23
 #endif
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH go v2] Add support for perf events
Posted by Peter Krempa 7 years, 1 month ago
On Fri, Feb 24, 2017 at 15:22:51 +0530, Nitesh Konkar wrote:
> Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> ---
>  connect.go      | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  domain.go       | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  domain_compat.h | 36 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 144 insertions(+)

The files are improperly indented. The go files use tabs for indentation
while your code uses spaces. I've already pointed this out in v1.

> 
> diff --git a/connect.go b/connect.go
> index 3c53485..e24cf66 100644
> --- a/connect.go
> +++ b/connect.go
> @@ -2264,6 +2264,24 @@ type DomainStatsPerf struct {
>  	StalledCyclesBackend     uint64
>  	RefCpuCyclesSet          bool
>  	RefCpuCycles             uint64
> +        CpuClockSet              bool
> +        CpuClock                 uint64
> +        TaskClockSet             bool
> +        TaskClock                uint64
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH go v2] Add support for perf events
Posted by Daniel P. Berrange 7 years, 1 month ago
On Fri, Feb 24, 2017 at 11:02:33AM +0100, Peter Krempa wrote:
> On Fri, Feb 24, 2017 at 15:22:51 +0530, Nitesh Konkar wrote:
> > Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> > ---
> >  connect.go      | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  domain.go       | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  domain_compat.h | 36 ++++++++++++++++++++++++++++++++++++
> >  3 files changed, 144 insertions(+)
> 
> The files are improperly indented. The go files use tabs for indentation
> while your code uses spaces. I've already pointed this out in v1.

More specifically the go files use 'gofmt' for formatting. The best way
to achieve this is to setup your editor to automatically run gofmt when
saving files. If you are using emacs this is achieved by installing and
using this lisp file

  https://github.com/dominikh/go-mode.el

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH go v2] Add support for perf events
Posted by Nitesh Konkar 7 years, 1 month ago
On Fri, Feb 24, 2017 at 4:06 PM, Daniel P. Berrange <berrange@redhat.com>
wrote:

> On Fri, Feb 24, 2017 at 11:02:33AM +0100, Peter Krempa wrote:
> > On Fri, Feb 24, 2017 at 15:22:51 +0530, Nitesh Konkar wrote:
> > > Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> > > ---
> > >  connect.go      | 54 ++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++
> > >  domain.go       | 54 ++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++
> > >  domain_compat.h | 36 ++++++++++++++++++++++++++++++++++++
> > >  3 files changed, 144 insertions(+)
> >
> > The files are improperly indented. The go files use tabs for indentation
> > while your code uses spaces. I've already pointed this out in v1.
>
> More specifically the go files use 'gofmt' for formatting. The best way
> to achieve this is to setup your editor to automatically run gofmt when
> saving files. If you are using emacs this is achieved by installing and
> using this lisp file
>
Thanks Daniel. However I am using vim and I think
gofmt -w domain.go and gofmt -w connect.go would help me
achieve the same.

  https://github.com/dominikh/go-mode.el
>
> Regards,
> Daniel
> --
> |: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/
> :|
> |: http://libvirt.org              -o-             http://virt-manager.org
> :|
> |: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/
> :|
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH go v2] Add support for perf events
Posted by Daniel P. Berrange 7 years, 1 month ago
On Fri, Feb 24, 2017 at 04:39:01PM +0530, Nitesh Konkar wrote:
> On Fri, Feb 24, 2017 at 4:06 PM, Daniel P. Berrange <berrange@redhat.com>
> wrote:
> 
> > On Fri, Feb 24, 2017 at 11:02:33AM +0100, Peter Krempa wrote:
> > > On Fri, Feb 24, 2017 at 15:22:51 +0530, Nitesh Konkar wrote:
> > > > Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> > > > ---
> > > >  connect.go      | 54 ++++++++++++++++++++++++++++++
> > ++++++++++++++++++++++++
> > > >  domain.go       | 54 ++++++++++++++++++++++++++++++
> > ++++++++++++++++++++++++
> > > >  domain_compat.h | 36 ++++++++++++++++++++++++++++++++++++
> > > >  3 files changed, 144 insertions(+)
> > >
> > > The files are improperly indented. The go files use tabs for indentation
> > > while your code uses spaces. I've already pointed this out in v1.
> >
> > More specifically the go files use 'gofmt' for formatting. The best way
> > to achieve this is to setup your editor to automatically run gofmt when
> > saving files. If you are using emacs this is achieved by installing and
> > using this lisp file
> >
> Thanks Daniel. However I am using vim and I think
> gofmt -w domain.go and gofmt -w connect.go would help me
> achieve the same.

FYI there is a vim mode too

  https://github.com/fatih/vim-go


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH go v2] Add support for perf events
Posted by Nitesh Konkar 7 years, 1 month ago
On Fri, Feb 24, 2017 at 3:32 PM, Peter Krempa <pkrempa@redhat.com> wrote:

> On Fri, Feb 24, 2017 at 15:22:51 +0530, Nitesh Konkar wrote:
> > Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
> > ---
> >  connect.go      | 54 ++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++
> >  domain.go       | 54 ++++++++++++++++++++++++++++++
> ++++++++++++++++++++++++
> >  domain_compat.h | 36 ++++++++++++++++++++++++++++++++++++
> >  3 files changed, 144 insertions(+)
>
> The files are improperly indented. The go files use tabs for indentation
> while your code uses spaces. I've already pointed this out in v1.
>
I had read the review on v1 but could not understand exactly whats wrong
with the indentation as everything looked aligned on applying the patch.
 Now its clear, shall send v3.  Thanks.

>
> >
> > diff --git a/connect.go b/connect.go
> > index 3c53485..e24cf66 100644
> > --- a/connect.go
> > +++ b/connect.go
> > @@ -2264,6 +2264,24 @@ type DomainStatsPerf struct {
> >       StalledCyclesBackend     uint64
> >       RefCpuCyclesSet          bool
> >       RefCpuCycles             uint64
> > +        CpuClockSet              bool
> > +        CpuClock                 uint64
> > +        TaskClockSet             bool
> > +        TaskClock                uint64
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list