From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] xenpm: Add option to report average CPU frequency Date: Tue, 19 Jan 2016 11:16:09 +0000 Message-ID: <569E1AF9.5000805@citrix.com> References: <1453200631-11818-1-git-send-email-malcolm.crossley@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1453200631-11818-1-git-send-email-malcolm.crossley@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Malcolm Crossley , ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com, wei.liu2@citrix.com Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 19/01/16 10:50, Malcolm Crossley wrote: > @@ -343,10 +348,44 @@ void pxstat_func(int argc, char *argv[]) > show_pxstat_by_cpuid(xc_handle, cpuid); > } > > +static int show_cpufreq_by_cpuid(xc_interface *xc_handle, int cpuid) > +{ > + int ret = 0; > + > + ret = get_avgfreq_by_cpuid(xc_handle, cpuid, &avgfreq[cpuid]); > + if ( ret ) > + return ret; > + > + printf("cpu id : %d\n", cpuid); > + printf("average cpu frequency: %d\n", avgfreq[cpuid]); > + printf("\n"); > + return 0; > +} > + > +void cpufreq_func(int argc, char *argv[]) > +{ > + int cpuid = -1; > + > + if ( argc > 0 ) > + parse_cpuid(argv[0], &cpuid); > + > + avgfreq = calloc(max_cpu_nr, sizeof(*avgfreq)); You need a NULL check here. ~Andrew