From patchwork Fri Feb 12 19:06:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 8296281 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C75C1C02AA for ; Fri, 12 Feb 2016 19:09:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8C32D20434 for ; Fri, 12 Feb 2016 19:09:41 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1139A20454 for ; Fri, 12 Feb 2016 19:09:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUJ3j-00070N-BT; Fri, 12 Feb 2016 19:07:15 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUJ3g-00070C-QN for xen-devel@lists.xen.org; Fri, 12 Feb 2016 19:07:13 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 4B/2F-12072-06D2EB65; Fri, 12 Feb 2016 19:07:12 +0000 X-Env-Sender: prvs=843bae1bd=Andrew.Cooper3@citrix.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1455304026!12446499!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36679 invoked from network); 12 Feb 2016 19:07:08 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-4.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 12 Feb 2016 19:07:08 -0000 X-IronPort-AV: E=Sophos;i="5.22,437,1449532800"; d="scan'208";a="337901208" From: Andrew Cooper To: Xen-devel Date: Fri, 12 Feb 2016 19:06:48 +0000 Message-ID: <1455304008-30048-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA1 Cc: George Dunlap , Andrew Cooper , Ian Jackson , Ian Campbell , Wei Liu Subject: [Xen-devel] [PATCH] tools/xenalyze: Fix build with clang X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 1) EXIT_REASON_EXCEPTION_NMI is 0, and Clang complains: xenalyze.c:513:33: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides] [EXIT_REASON_EXCEPTION_NMI]="EXCEPTION_NMI", ^~~~~~~~~~~~~~~ xenalyze.c:512:11: note: previous initialization is here [0] = "NONE", ^~~~~~ 2) cr3_time_compare(), eip_compare(), ipi_send() and cr3_compare_start() are declared as nested functions, which is a GCCism not supported by Clang. As they don't actually make use of the interesting feature offered by nested functions (i.e. dynamic scoping), move them to just being normal functions. 3) clear_interval_summary(), update_cpi() and clear_interval_cpi() are all unused. The former isn't reference anywhere, so is deleted, while the other two are called from currently #if 0'd code. Signed-off-by: Andrew Cooper Acked-by: George Dunlap --- CC: George Dunlap CC: Ian Campbell CC: Ian Jackson CC: Wei Liu --- tools/xentrace/xenalyze.c | 188 +++++++++++++++++++++++----------------------- 1 file changed, 92 insertions(+), 96 deletions(-) diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index 6520790..1651302 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -509,7 +509,6 @@ struct { #define HVM_VMX_EXIT_REASON_MAX (EXIT_REASON_XSETBV+1) char * hvm_vmx_exit_reason_name[HVM_VMX_EXIT_REASON_MAX] = { - [0] = "NONE", [EXIT_REASON_EXCEPTION_NMI]="EXCEPTION_NMI", [EXIT_REASON_EXTERNAL_INTERRUPT]="EXTERNAL_INTERRUPT", [EXIT_REASON_TRIPLE_FAULT]="TRIPLE_FAULT", @@ -2270,11 +2269,6 @@ static inline void update_summary(struct event_cycle_summary *s, long long c) { s->count++; } -static inline void clear_interval_summary(struct event_cycle_summary *s) { - s->interval.count = 0; - s->interval.cycles = 0; -} - static inline void update_cycles(struct cycle_summary *s, long long c) { /* We don't know ahead of time how many samples there are, and working * with dynamic stuff is a pain, and unnecessary. This algorithm will @@ -2322,6 +2316,7 @@ static inline void clear_interval_cycles(struct interval_element *e) { e->instructions = 0; } +#if 0 static inline void update_cpi(struct weighted_cpi_summary *s, unsigned long long i, unsigned long long c) { @@ -2367,6 +2362,7 @@ static inline void clear_interval_cpi(struct weighted_cpi_summary *s) { s->interval.count = 0; s->interval.instructions = 0; } +#endif static inline void print_cpu_affinity(struct cycle_summary *s, char *p) { if(s->count) { @@ -2647,6 +2643,23 @@ void interval_cr3_value_check(struct cr3_value_struct *cr3) { } } +int cr3_time_compare(const void *_a, const void *_b) { + struct cr3_value_struct *a=*(typeof(&a))_a; + struct cr3_value_struct *b=*(typeof(&a))_b; + + if(a->total_time.interval.cycles < b->total_time.interval.cycles) + return 1; + else if(b->total_time.interval.cycles == a->total_time.interval.cycles) { + if(a->total_time.interval.count < b->total_time.interval.count) + return 1; + else if(a->total_time.interval.count == b->total_time.interval.count) + return 0; + else + return -1; + } else + return -1; +} + void interval_cr3_schedule_ordered_output(void) { struct cr3_value_struct *p; int i; @@ -2654,23 +2667,6 @@ void interval_cr3_schedule_ordered_output(void) { struct cr3_value_struct **qsort_array; int N=0; - int cr3_time_compare(const void *_a, const void *_b) { - struct cr3_value_struct *a=*(typeof(&a))_a; - struct cr3_value_struct *b=*(typeof(&a))_b; - - if(a->total_time.interval.cycles < b->total_time.interval.cycles) - return 1; - else if(b->total_time.interval.cycles == a->total_time.interval.cycles) { - if(a->total_time.interval.count < b->total_time.interval.count) - return 1; - else if(a->total_time.interval.count == b->total_time.interval.count) - return 0; - else - return -1; - } else - return -1; - } - for(p=P.cr3.head; p; p=p->gnext) N++; @@ -2966,6 +2962,23 @@ void update_eip(struct eip_list_struct **head, unsigned long long eip, update_summary(&p->summary, cycles); } +int eip_compare(const void *_a, const void *_b) { + struct eip_list_struct *a=*(typeof(&a))_a; + struct eip_list_struct *b=*(typeof(&a))_b; + + if(a->summary.cycles < b->summary.cycles) + return 1; + else if(b->summary.cycles == a->summary.cycles) { + if(a->summary.count < b->summary.count) + return 1; + else if(a->summary.count == b->summary.count) + return 0; + else + return -1; + } else + return -1; +} + void dump_eip(struct eip_list_struct *head) { struct eip_list_struct *p; int i; @@ -2974,23 +2987,6 @@ void dump_eip(struct eip_list_struct *head) { struct eip_list_struct **qsort_array; int N=0; - int eip_compare(const void *_a, const void *_b) { - struct eip_list_struct *a=*(typeof(&a))_a; - struct eip_list_struct *b=*(typeof(&a))_b; - - if(a->summary.cycles < b->summary.cycles) - return 1; - else if(b->summary.cycles == a->summary.cycles) { - if(a->summary.count < b->summary.count) - return 1; - else if(a->summary.count == b->summary.count) - return 0; - else - return -1; - } else - return -1; - } - for(p=head; p; p=p->next) { total += p->summary.count; @@ -3557,6 +3553,50 @@ struct outstanding_ipi *find_vec(struct vlapic_struct *vla, int vec) return o; } +void ipi_send(struct vcpu_data *ov, int vec) +{ + struct vlapic_struct *vla; + struct outstanding_ipi *o = NULL; + + if(ov->runstate.state == RUNSTATE_LOST) { + if(opt.dump_all) + fprintf(warn, "%s: v%d in state RUNSTATE_LOST, not counting ipi\n", + __func__, ov->vid); + return; + } + + vla = &ov->vlapic; + + o = find_vec(vla, vec); + + if(!o) + { + fprintf(warn, "%s: Couldn't find an open slot!\n", + __func__); + return; + } + + if(!o->first_tsc) + o->first_tsc = P.now; + + if(opt.dump_all && o->count == 0 && o->injected) + printf(" [vla] Pre-injection\n"); + + o->count++; + + if((opt.dump_all) +#if 0 + && (ov->runstate.state != RUNSTATE_RUNNING + || ov->hvm.vmexit_valid) +#endif + ) + printf(" [vla] d%dv%d vec %d state %s (outstanding ipis %d)\n", + ov->d->did, ov->vid, + o->vec, + runstate_name[ov->runstate.state], + o->count); +} + void hvm_vlapic_icr_handler(struct hvm_data *h) { struct mmio_info *m = &h->inflight.mmio; @@ -3575,50 +3615,6 @@ void hvm_vlapic_icr_handler(struct hvm_data *h) }; } icr = { .val = m->data }; - void ipi_send(struct vcpu_data *ov, int vec) - { - struct vlapic_struct *vla; - struct outstanding_ipi *o = NULL; - - if(ov->runstate.state == RUNSTATE_LOST) { - if(opt.dump_all) - fprintf(warn, "%s: v%d in state RUNSTATE_LOST, not counting ipi\n", - __func__, ov->vid); - return; - } - - vla = &ov->vlapic; - - o = find_vec(vla, vec); - - if(!o) - { - fprintf(warn, "%s: Couldn't find an open slot!\n", - __func__); - return; - } - - if(!o->first_tsc) - o->first_tsc = P.now; - - if(opt.dump_all && o->count == 0 && o->injected) - printf(" [vla] Pre-injection\n"); - - o->count++; - - if((opt.dump_all) -#if 0 - && (ov->runstate.state != RUNSTATE_RUNNING - || ov->hvm.vmexit_valid) -#endif - ) - printf(" [vla] d%dv%d vec %d state %s (outstanding ipis %d)\n", - ov->d->did, ov->vid, - o->vec, - runstate_name[ov->runstate.state], - o->count); - } - if(m->is_write) { if(opt.dump_all) { printf(" [vla] d%dv%d icr vec %d %s\n", @@ -4124,23 +4120,23 @@ void cr3_prealloc_unpin(struct vcpu_data *v, unsigned long long gmfn) { gmfn, cr3->prealloc_unpin.count); } +int cr3_compare_start(const void *_a, const void *_b) { + struct cr3_value_struct *a=*(typeof(&a))_a; + struct cr3_value_struct *b=*(typeof(&a))_b; + + if(a->first_time > b->first_time) + return 1; + else if(b->first_time == a->first_time) + return 0; + else + return -1; +} + void cr3_dump_list(struct cr3_value_struct *head){ struct cr3_value_struct *p; struct cr3_value_struct **qsort_array; int i, N=0; - int cr3_compare_start(const void *_a, const void *_b) { - struct cr3_value_struct *a=*(typeof(&a))_a; - struct cr3_value_struct *b=*(typeof(&a))_b; - - if(a->first_time > b->first_time) - return 1; - else if(b->first_time == a->first_time) - return 0; - else - return -1; - } - if(!head) return;