Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp893796pxb; Wed, 13 Jan 2021 19:45:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwp84KBBInzefMNmiGbYX1XsFz6/q1TjhYj1WhUQuno1LCVUwIClQacIUx/PRcZGbrzf9yZ X-Received: by 2002:a05:6402:13d1:: with SMTP id a17mr4202542edx.202.1610595954244; Wed, 13 Jan 2021 19:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610595954; cv=none; d=google.com; s=arc-20160816; b=0uLMyD2vo0VPSSfH0l54IR7W14LfeB3p6akkFC0ky9UJEprY66pTy31cmN3bKBuLR7 zwPJvJI4rIALOOugTpPIyrFg/Myf1edh3s/BljkoIjoRx0mqVWDM1hXrkpbi2xnBRMNb aeydL3Sj9FhpL4LnuOH4OgBkcAN497ZjwJ2uYcpBVeMpTLTRpsTyUmtHWTK8WJvFu5n1 hHLEQHCKpn71/KInZUPZLF2xIeR5BZ3wfV796IfvqKjjER39g/epv+N+H6MGEfYt898H 7fBuvID6k4LLEak+REVxr1Of8nyq+h/FO2ZnlqCyHDXRCQvaD6pT9z7C8FJfNbSipaJW cADQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hCbfdcDygxVY1a58duhGrDZtXZg7kW86cVj3DuELBH0=; b=Y0wY9LJdR7vIgyyJbGro5B75svKbvvh2uSdffne86EKnVIjU3Y6uhMKHZcOoJcwrCl qm26C+v0lZwSdUjai4eXSLrw6GmqI1sWe88Iv1o6xiBMmDm20lcpZECZtsBBRuXto2fy R/G1uBZ33qxZp/8x4b3R8hAcA9tcAUInKkYAQfAwZTJ4u1Oufq2SSsgzSkVrJhdEuU2R IK/PxyTrMfPcZLgiX/Rn9XelJQKwW+u6FCoUepfvM5/HLjSIxaUIa3fb5rgj2qV8t5+0 l3TT9cWUyDCPzd5Vvf4DQH3ss4GZkZVJDtsfcVezbTcYNCkBO1dGKUDrIwnWmTCpKvaI OReg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CFxyjV6/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si2020954edm.143.2021.01.13.19.45.31; Wed, 13 Jan 2021 19:45:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="CFxyjV6/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727211AbhANDlA (ORCPT + 99 others); Wed, 13 Jan 2021 22:41:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbhANDk7 (ORCPT ); Wed, 13 Jan 2021 22:40:59 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F77EC0617A3 for ; Wed, 13 Jan 2021 19:40:12 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id r4so2218812pls.11 for ; Wed, 13 Jan 2021 19:40:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hCbfdcDygxVY1a58duhGrDZtXZg7kW86cVj3DuELBH0=; b=CFxyjV6/KWR7cVauE2uxI0uGbOmx9MpcHp6twtoYEP5O1IxY3Jz4wr4s6hxms720Ow roumYtF0BLOsvkKXQHRPG2eFk6lQ85jo81Ng4gpINIxoi5O/q2oJFip1M7lbFpPyjR+G VTAsde+oh4PivEA48/3UChi3+aWSRDiYIx7eoVb5mC4WWf1UQmDsmZ1ou4HzxvsiQKEg ruZ13q3z7yidYgX+XrrzYVAxvIn+ZvlfiONwUs3mjaJO/ogdnbmxl55W67uty2jeayp2 H2dfNQlt3m5QxpX/HAzgjRe3Int8ALDrxPx6+bQ+/9HGXrzi3Jd41bQyKfnGCpuwhuUH 08HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hCbfdcDygxVY1a58duhGrDZtXZg7kW86cVj3DuELBH0=; b=h9Tj3mg5hfcu6szT8iXKalS0YkCXDiF+u7e/VpKgOAgi2/+9+0PdYQ1Ukboo4JpYpo 1tsVqRR0CRtZZ0LOG3LimxtKXuGYy5yKfBl6dqzXM1cbaB4e8OynGul72nY+nTCbmp/p GIifaXis59HVRgaYSanixNWyUlZrIMKZg8ooEzWPkc/8Mmh5kDt3qOFa3SGSUaBdJXp6 w4vLfLdzJLkSosyen2+In4cnSL4lYQQFMJOLSwInRNLYgZZvTI3HZxazXQZYxIckJ5ej GWol6Vz0NpNqGcScNrysDWeS7HNcYcnHHA3sOIE5S9BSew8LZEub13peJ9tA33IqXRu+ JJ2g== X-Gm-Message-State: AOAM533EKTVH1vxDU9NlLNNdhyTLMJ/LjiK9oFgvSPfN21M64ZfpHkqL e3K/iRjQlmX5QRxZie9on0qWsA== X-Received: by 2002:a17:902:f688:b029:da:a817:1753 with SMTP id l8-20020a170902f688b02900daa8171753mr5494286plg.76.1610595611826; Wed, 13 Jan 2021 19:40:11 -0800 (PST) Received: from localhost ([45.137.216.7]) by smtp.gmail.com with ESMTPSA id w63sm3872214pfc.20.2021.01.13.19.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 19:40:11 -0800 (PST) From: Leo Yan To: Arnaldo Carvalho de Melo , Jiri Olsa , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Joe Mario , David Ahern , Don Zickus , linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v3 5/5] perf c2c: Add local variables for output metrics Date: Thu, 14 Jan 2021 11:39:39 +0800 Message-Id: <20210114033939.164538-6-leo.yan@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210114033939.164538-1-leo.yan@linaro.org> References: <20210114033939.164538-1-leo.yan@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds several local variables: "cl_output": pointer for outputting single cache line metrics; "output_str": pointer for outputting cache line metrics; "sort_str": pointer to the sorting metrics. This can improve readability for the code and it's more flexible when later extend to different strings for the output metrics. Signed-off-by: Leo Yan Acked-by: Jiri Olsa --- tools/perf/builtin-c2c.c | 59 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index fe811b8e02bb..1c5f0f8f483a 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2206,16 +2206,17 @@ static void print_pareto(FILE *out) struct perf_hpp_list hpp_list; struct rb_node *nd; int ret; + const char *cl_output; + + cl_output = "cl_num," + "cl_rmt_hitm," + "cl_lcl_hitm," + "cl_stores_l1hit," + "cl_stores_l1miss," + "dcacheline"; perf_hpp_list__init(&hpp_list); - ret = hpp_list__parse(&hpp_list, - "cl_num," - "cl_rmt_hitm," - "cl_lcl_hitm," - "cl_stores_l1hit," - "cl_stores_l1miss," - "dcacheline", - NULL); + ret = hpp_list__parse(&hpp_list, cl_output, NULL); if (WARN_ONCE(ret, "failed to setup sort entries\n")) return; @@ -2759,6 +2760,7 @@ static int perf_c2c__report(int argc, const char **argv) OPT_END() }; int err = 0; + const char *output_str, *sort_str = NULL; argc = parse_options(argc, argv, options, report_c2c_usage, PARSE_OPT_STOP_AT_NON_OPTION); @@ -2835,24 +2837,29 @@ static int perf_c2c__report(int argc, const char **argv) goto out_mem2node; } - c2c_hists__reinit(&c2c.hists, - "cl_idx," - "dcacheline," - "dcacheline_node," - "dcacheline_count," - "percent_hitm," - "tot_hitm,lcl_hitm,rmt_hitm," - "tot_recs," - "tot_loads," - "tot_stores," - "stores_l1hit,stores_l1miss," - "ld_fbhit,ld_l1hit,ld_l2hit," - "ld_lclhit,lcl_hitm," - "ld_rmthit,rmt_hitm," - "dram_lcl,dram_rmt", - c2c.display == DISPLAY_TOT ? "tot_hitm" : - c2c.display == DISPLAY_LCL ? "lcl_hitm" : "rmt_hitm" - ); + output_str = "cl_idx," + "dcacheline," + "dcacheline_node," + "dcacheline_count," + "percent_hitm," + "tot_hitm,lcl_hitm,rmt_hitm," + "tot_recs," + "tot_loads," + "tot_stores," + "stores_l1hit,stores_l1miss," + "ld_fbhit,ld_l1hit,ld_l2hit," + "ld_lclhit,lcl_hitm," + "ld_rmthit,rmt_hitm," + "dram_lcl,dram_rmt"; + + if (c2c.display == DISPLAY_TOT) + sort_str = "tot_hitm"; + else if (c2c.display == DISPLAY_RMT) + sort_str = "rmt_hitm"; + else if (c2c.display == DISPLAY_LCL) + sort_str = "lcl_hitm"; + + c2c_hists__reinit(&c2c.hists, output_str, sort_str); ui_progress__init(&prog, c2c.hists.hists.nr_entries, "Sorting..."); -- 2.25.1