From patchwork Wed Feb 17 14:30:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 8339571 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 70A7BC0553 for ; Wed, 17 Feb 2016 14:33:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D120203A4 for ; Wed, 17 Feb 2016 14:33:21 +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 7670D20383 for ; Wed, 17 Feb 2016 14:33:15 +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 1aW37v-0004RL-Fx; Wed, 17 Feb 2016 14:30:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aW37t-0004R4-KS for xen-devel@lists.xen.org; Wed, 17 Feb 2016 14:30:46 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id A2/42-24375-41484C65; Wed, 17 Feb 2016 14:30:44 +0000 X-Env-Sender: prvs=848fde4e6=Ian.Campbell@citrix.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1455719441!23228010!2 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 65243 invoked from network); 17 Feb 2016 14:30:43 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-8.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 17 Feb 2016 14:30:43 -0000 X-IronPort-AV: E=Sophos;i="5.22,460,1449532800"; d="scan'208";a="338859120" From: Ian Campbell To: , , Date: Wed, 17 Feb 2016 14:30:38 +0000 Message-ID: <1455719438-11095-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455719438-11095-1-git-send-email-ian.campbell@citrix.com> References: <1455719438-11095-1-git-send-email-ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell Subject: [Xen-devel] [PATCH 2/2] tools: gtracestat: make all functions and global data static 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 After "Drop unused functions do_cstate and single_cstate helper" make all the remaining functions and global data static and in the process allow the compiler to notice that cond_rec_init() is also unused, thus remove it. Signed-off-by: Ian Campbell Acked-by: Ian Jackson --- tools/misc/gtracestat.c | 103 ++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 55 deletions(-) diff --git a/tools/misc/gtracestat.c b/tools/misc/gtracestat.c index b54eeb8..3c2bd2c 100644 --- a/tools/misc/gtracestat.c +++ b/tools/misc/gtracestat.c @@ -49,40 +49,40 @@ struct rec { }; /********** FORWARD DECLARATION **********/ -void show_help(void); -void show_version(void); -int load_file(char *fname); -void do_digest(uint64_t start, uint64_t end, uint64_t scale); -void do_breakevents(void); -void do_count(void); -void do_px_count(void); -void do_maxmin(void); -void do_average(void); -void do_exp_ratio(void); -void do_exp_pred(void); +static void show_help(void); +static void show_version(void); +static int load_file(char *fname); +static void do_digest(uint64_t start, uint64_t end, uint64_t scale); +static void do_breakevents(void); +static void do_count(void); +static void do_px_count(void); +static void do_maxmin(void); +static void do_average(void); +static void do_exp_ratio(void); +static void do_exp_pred(void); /********** GLOBAL VARIABLES **********/ /* store simplified xentrace data */ -struct rec *data; -int64_t data_nr, data_cur; +static struct rec *data; +static int64_t data_nr, data_cur; /* store max cx state number and cpu number */ -int max_cx_num = -1, max_cpu_num = -1; -int px_freq_table[MAX_PX_NR]; -int max_px_num = 0; +static int max_cx_num = -1, max_cpu_num = -1; +static int px_freq_table[MAX_PX_NR]; +static int max_px_num = 0; -int is_menu_gov_enabled = 0; +static int is_menu_gov_enabled = 0; /* user specified translation unit */ -uint64_t tsc2ms = 2793000UL; -uint64_t tsc2us = 2793UL; -uint64_t tsc2phase = 55800000UL; +static uint64_t tsc2ms = 2793000UL; +static uint64_t tsc2us = 2793UL; +static uint64_t tsc2phase = 55800000UL; /* each cpu column width */ -int width = 0; +static int width = 0; /* digest mode variables */ -struct rec *evt[MAX_CPU_NR]; -int evt_len[MAX_CPU_NR]; +static struct rec *evt[MAX_CPU_NR]; +static int evt_len[MAX_CPU_NR]; /* hand-crafted min() */ static inline uint64_t min(uint64_t a, uint64_t b) @@ -94,7 +94,7 @@ static inline uint64_t max(uint64_t a, uint64_t b) return a > b ? a : b; } -int is_px = 0; +static int is_px = 0; int main(int argc, char *argv[]) { @@ -265,7 +265,7 @@ static int data_cmp(const void *_a, const void *_b) * max_cpu_num, max_cx_num */ #define LIST_PX 0 -int load_file(char *fname) +static int load_file(char *fname) { /* file descriptor for raw xentrace file */ int fd; @@ -436,12 +436,12 @@ int load_file(char *fname) return 0; } -void show_version(void) +static void show_version(void) { printf("gtracestat - (C) 2009-2011 Intel Corporation\n"); } -void show_help(void) +static void show_help(void) { show_version(); printf("gtracestat [-vhdselbcmau]\n"); @@ -476,7 +476,7 @@ static inline int len_of_number(uint64_t n) /* determine the cx at time t * take advantage of evt and evt_len. */ -int determine_cx(int c, uint64_t t) +static int determine_cx(int c, uint64_t t) { int i; @@ -503,7 +503,7 @@ int determine_cx(int c, uint64_t t) * cx_i - number of cx index * cx_r - residency of each cx entry */ -int process(int c, uint64_t t, uint64_t s, int *cx_i, uint64_t *cx_r) +static int process(int c, uint64_t t, uint64_t s, int *cx_i, uint64_t *cx_r) { int cx; uint64_t len; @@ -536,7 +536,7 @@ int process(int c, uint64_t t, uint64_t s, int *cx_i, uint64_t *cx_r) return n; } -void nr_putchar(int nr, int ch) +static void nr_putchar(int nr, int ch) { int i; for (i = 0; i < nr; i++) @@ -545,7 +545,7 @@ void nr_putchar(int nr, int ch) #define MAX_INTERVAL_ENTRY 1000 /* process period [start_time, start_time + time_scale) */ -void single_digest(uint64_t start_time, uint64_t time_scale) +static void single_digest(uint64_t start_time, uint64_t time_scale) { int cpu; int cx_i[MAX_CPU_NR][MAX_INTERVAL_ENTRY]; @@ -592,7 +592,7 @@ void single_digest(uint64_t start_time, uint64_t time_scale) } } -void do_digest(uint64_t start, uint64_t end, uint64_t scale) +static void do_digest(uint64_t start, uint64_t end, uint64_t scale) { int i; uint64_t ms = 0; @@ -628,14 +628,7 @@ struct cond_rec { uint64_t res; }; -void cond_rec_init(struct cond_rec *r, uint64_t min, uint64_t max) -{ - r->min = min; - r->max = max; - r->cnt = 0; -} - -void cond_rec_inc(uint64_t cur, struct cond_rec *r) +static void cond_rec_inc(uint64_t cur, struct cond_rec *r) { if (r->min <= cur && cur < r->max) { r->cnt++; @@ -648,7 +641,7 @@ void cond_rec_inc(uint64_t cur, struct cond_rec *r) * a - conditonal array * n - how many entries there are */ -void do_count_per_cpu(int c, int cx, struct cond_rec *a, int n) +static void do_count_per_cpu(int c, int cx, struct cond_rec *a, int n) { int i; /* find Cx entry first */ @@ -668,7 +661,7 @@ void do_count_per_cpu(int c, int cx, struct cond_rec *a, int n) } } -struct cond_rec *make_cond_rec(uint64_t *a, int n) +static struct cond_rec *make_cond_rec(uint64_t *a, int n) { int i; struct cond_rec *t = malloc(sizeof(struct cond_rec) * (n+1)); @@ -688,12 +681,12 @@ struct cond_rec *make_cond_rec(uint64_t *a, int n) return t; } -uint64_t max_res[MAX_CPU_NR][MAX_CX_NR]; -uint64_t min_res[MAX_CPU_NR][MAX_CX_NR]; -uint64_t max_tm[MAX_CPU_NR][MAX_CX_NR]; -uint64_t min_tm[MAX_CPU_NR][MAX_CX_NR]; +static uint64_t max_res[MAX_CPU_NR][MAX_CX_NR]; +static uint64_t min_res[MAX_CPU_NR][MAX_CX_NR]; +static uint64_t max_tm[MAX_CPU_NR][MAX_CX_NR]; +static uint64_t min_tm[MAX_CPU_NR][MAX_CX_NR]; -void do_maxmin_per_cpu(int c) +static void do_maxmin_per_cpu(int c) { int i; /* find Cx entry first */ @@ -716,7 +709,7 @@ void do_maxmin_per_cpu(int c) } } -void do_maxmin(void) +static void do_maxmin(void) { int i, j; /* init */ @@ -746,7 +739,7 @@ void do_maxmin(void) } } -void do_count(void) +static void do_count(void) { uint64_t scale[100] = { 50UL, 100UL, 200UL, 400UL, 800UL, 1000UL }; int a; @@ -820,7 +813,7 @@ static void do_px_count_per_cpu(int c, int px, struct cond_rec *cond, int n) } } -void do_px_count(void) +static void do_px_count(void) { int a[100]; uint64_t scale[100]; @@ -906,7 +899,7 @@ void do_px_count(void) } } -void do_breakevents(void) +static void do_breakevents(void) { int br[MAX_CPU_NR][257]; float pc[MAX_CPU_NR][257]; @@ -973,7 +966,7 @@ void do_breakevents(void) } } -void do_average_per_cpu(int c) +static void do_average_per_cpu(int c) { int i; uint64_t tot[MAX_CX_NR] = { 0 }; @@ -1009,7 +1002,7 @@ void do_average_per_cpu(int c) printf("\n"); } -void do_average(void) +static void do_average(void) { int i; @@ -1055,7 +1048,7 @@ static void do_exp_ratio_per_cpu(int c) } } -void do_exp_ratio(void) +static void do_exp_ratio(void) { int i; @@ -1105,7 +1098,7 @@ static void do_exp_pred_per_cpu(int c) } } -void do_exp_pred(void) +static void do_exp_pred(void) { int i;