From patchwork Wed Nov 23 18:01:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25123 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942623wrr; Wed, 23 Nov 2022 10:06:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf5dV2HLz8m/RQqJrME+r8OLaKdZHFruesCGhTrFsiQSYLv1Btr0YPLEugJwYEE8K/RnyjZz X-Received: by 2002:a05:6402:10d1:b0:467:7508:89ca with SMTP id p17-20020a05640210d100b00467750889camr12020457edu.284.1669226767765; Wed, 23 Nov 2022 10:06:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226767; cv=none; d=google.com; s=arc-20160816; b=DiioKFEpoNkQQJVRYmsU2zq//3UI9Gb4gtusi740tKvw5m6wGVOA1T6x0ILc2VSVJ8 wcMsBoEvtcSLPMp9Oxd1GQvm1R21IDAXarXcyt6iI3xCd7qv3epnDD/tETh24gykjBsE 21jzQ98bCM0UbPke4NHZ6e5xNUCwvpE26uRKkkbBiiw5spelh6vE1XPviBnWtx8X8b5G eMiEQQ57s7t2PTRwZwmy3MOTgTIkC9wX3lQEc0D5fp6T42chdMPIXc2DMs08f2He0mvW f8S12FuIiG1QobXsK7kKv614QL2TyUJna0aHxNfJgLo6ijoinW12iyogOIgegcrFYx/w ykfg== 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:sender :dkim-signature; bh=E05AU6ZdRoSB14xGjx/8Ofyvzr/jUJ5BgfZd3HvnFGE=; b=lYZciotqBeuMxelhsb5ED/Mh9U/UDfBugGJ7E1ZURG8akguhR9wPNeT06CvaIyZcjC atwDJNkbAheaihUW7qWGA3BucRLnWThZFJla0CU6oDA3hEW6xLaKBwi6iomcsJdT9ok2 V4WChCwW8Pig5wQbS45jk0ROPw+uoKohQslk0T3lssqOt7DOupXdd+cQ/0TJ24IidE9v YGJWaOw7Y5mjNvL0rsCC8WLveiJEGHnmLy2A7XHbnDOk/gy82U2uPW0ym2uhz5Op5gxC BHspkS5gUlu63Hfx6M9mTBUuaATaaDke5/0NJ6zftZ26lri898lQA4jdgz3YL42H6z8a vOHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YN510YrG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w22-20020a05640234d600b0045b293121f1si8448975edc.12.2022.11.23.10.05.31; Wed, 23 Nov 2022 10:06:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YN510YrG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239428AbiKWSCd (ORCPT + 99 others); Wed, 23 Nov 2022 13:02:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239316AbiKWSCN (ORCPT ); Wed, 23 Nov 2022 13:02:13 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4466093715; Wed, 23 Nov 2022 10:02:13 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso2837996pjt.0; Wed, 23 Nov 2022 10:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=E05AU6ZdRoSB14xGjx/8Ofyvzr/jUJ5BgfZd3HvnFGE=; b=YN510YrGVv73yVz1JaUZ70Vb4Uu5LIUt0zqlUDyzLeUIjx6DuTXI5DJn3hrPqQ7g06 oI2GQU4iaJDKP1NmgR85782K/zSMstYqX85lg64uzCgyHATPgDiwfgKSNLSk0D0MHTkl PSYwy7K6bRtqLS9eZfIq59EUTsQo8X3ZrOsI97b2AHc18p4S6s9Q0+AoApNrd7wQFnRd rdcV9O7wbNNQrvaYcyiv3ppEAO90Zp3NpdIh2Je0/i055XnyT4mvsgO/VmAl5yN5D77c iOsBzfVwNOnZhh+cpDB77mvZkdrB6NB+7wkPesVnbqsb1yrrlXwn4Yd7hDNxX768E78M wcAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=E05AU6ZdRoSB14xGjx/8Ofyvzr/jUJ5BgfZd3HvnFGE=; b=P5mUpZTsD3D5m1FowstDhJ0i7Ha9oTGaY0CyxrCgxw2/dtOTWeh8YTVC/P30hqk7zY t5LuP0IenQn2DbuBQt2Sc7RQFt2oIMrjRayu8E3E33NcYFqNoMo1YK5PNEtGcvn2jke1 rR6qPvriPaXxC+yfSVbBS4KDOnhyyX6mgFh4GPr8JfVt43faTVVsKH+ktgArX8aZCBUW u1DQn5rZN7UPqPUGo7tVCIp50Q5l3cMjVc7N+Mle2xA5v6oNSPQ6iV+yHSiNC/oye9rc sqlxchUh9Ux5DSJ+izsOGa7XDdyNzWvpDHG4NDs+DuXrM29jn6xYFk4fVgduA1chPl2T QcGA== X-Gm-Message-State: ANoB5pkkMeqkBI7/WsK5HsB0XbBVSrErviDZd5UgL6cThTYjsI1qD9ok kSYA/6bpwAzRiihliKBJLvs= X-Received: by 2002:a17:902:bd04:b0:189:38a1:30fe with SMTP id p4-20020a170902bd0400b0018938a130femr7013774pls.47.1669226532681; Wed, 23 Nov 2022 10:02:12 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:12 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 01/15] perf stat: Fix cgroup display in JSON output Date: Wed, 23 Nov 2022 10:01:54 -0800 Message-Id: <20221123180208.2068936-2-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311127106685626?= X-GMAIL-MSGID: =?utf-8?q?1750311127106685626?= It missed the 'else' keyword after checking json output mode. Fixes: 41cb875242e7 ("perf stat: Split print_cgroup() function") Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index f5501760ff2e..46e90f0bb423 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -175,7 +175,7 @@ static void print_cgroup(struct perf_stat_config *config, struct cgroup *cgrp) if (config->json_output) print_cgroup_json(config, cgrp_name); - if (config->csv_output) + else if (config->csv_output) print_cgroup_csv(config, cgrp_name); else print_cgroup_std(config, cgrp_name); From patchwork Wed Nov 23 18:01:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942471wrr; Wed, 23 Nov 2022 10:05:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf6V5tir/FfOoGUIVsxvZyjQ0hWA9rT+WlRgTBGd+tn6nL86GNHtNIxY3krlGeio6hQZJ8Cu X-Received: by 2002:aa7:c30c:0:b0:469:80b7:a16a with SMTP id l12-20020aa7c30c000000b0046980b7a16amr13630493edq.306.1669226751656; Wed, 23 Nov 2022 10:05:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226751; cv=none; d=google.com; s=arc-20160816; b=EQkp958gA+TTAy1THCMmJNthIhrZMHFKF9K6rtnerNKKiZzeBpgtVACT8Wn1alZpdU DMbXZMY8UomTdin5GkWgQE8JNc/bwy0eQJ9ioOH9c2OffRP+gAhLYc+6bONLAmzXIaKW n6PPETCyMHqJXlRLDXPw6g/PuHNpXPYVn9qXB/1u3wNyiF8bCS52wt9CxvU1Lmg7TydG uzN52qajgvjn6Edmi9K2ULjctqcf8gyqVHsXZXJHmswoEJ8Ra7PZ6UOaHj4OjfSdyLC8 ZSPE25eccKhqoxaVMJtXnTxvmEgor/fGipme0TyKve6xe+/d8wlutZcXdV/Xk8mHEEyY Onig== 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:sender :dkim-signature; bh=45F31ZAKNk8FjxfLJ7aVBA4PDnBSPJi7ky7zRGdUzFI=; b=sgydMen5Igtfj9iErqlafAyJQWK/V5uLQhW209kjGeQw5jmIo4g3hD9+Bv2Rxhda2Z uUwN4tA9xZFajoSy15vzIeLx1wiBI/0MX1j+HjYqN52Z/kgMyFLx5rWDvEV5GSWkHdd/ U+XikHpK1v3zreOGD2lZLualmnSBIfAE5alHPAJ5hn4ED+hLwqEMz5ys6nTmk7pDn/pg Cqs+saXJuMDxyPDjKQn47R+iUERd1HbXkLz4awNvCttVaEGUj0ZFKPTcMWJ7Fz6z6ClS apRAzUGF2F+RCtzhrurGvGeo2795feYGUl9ZgJ6Fyy90xmGz/BiQMSfCfKNxvHNebQXK gj2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A5Kp6O7N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a1709065d1000b007bb12ecc8besi415ejt.939.2022.11.23.10.05.16; Wed, 23 Nov 2022 10:05:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=A5Kp6O7N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239403AbiKWSC3 (ORCPT + 99 others); Wed, 23 Nov 2022 13:02:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239322AbiKWSCP (ORCPT ); Wed, 23 Nov 2022 13:02:15 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9691D60F9; Wed, 23 Nov 2022 10:02:14 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id q96-20020a17090a1b6900b00218b8f9035cso2515525pjq.5; Wed, 23 Nov 2022 10:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=45F31ZAKNk8FjxfLJ7aVBA4PDnBSPJi7ky7zRGdUzFI=; b=A5Kp6O7NIwwxm+NlPeHqQK8k67Rp3gtP6R4NLbBAN6zHWomk59ocTMCp8ZCGZR84Py 5Xex6u2PjfMaCO4Gm3suerJ3ahPPh5kbLV1ZF0HO4F1w5t7ChgnduQReHwebROXb2Ury k8Czk2pBAMyjT79W9dcTPKW1fAZtJ5QSnAYCro53YfEDZVB53C8rjsdabKCfQvhRD0mg 9QA+CvPdO9EOVMM6T/5/0IBblqneH5kPG3urNQR1Mx/zuYgunjjNRpjatnqnqs2WYm87 qjl9JY0GNwSQGwUgdDUEG2twvB6kkW8xLKEZ18nHrXw8DdSNUTBIMiL+56A6H3idxnv2 701Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=45F31ZAKNk8FjxfLJ7aVBA4PDnBSPJi7ky7zRGdUzFI=; b=k/0p3njLyku/hfSwUslqrFE9hte5tyVP4hUzdLkUJyqA8C3FT6tetbuARAjZjOUa+l jgse/Wa5ssklMuGna8s2STXoHhyGSfLSl9TXN/DNfIHvJP8i/d9JpGovQYKkQejBLWTo H6Avt9EURDzI02eLp8QHWCnaTBpH1MQlTgm1LJq26SDReY/2KbxB2QSRniVwbJMA2bcO hqQ3fHr8IeKCh7coBaXzB8vGI6BLX9DyxYfiZtwx0iyX4ugGmURWnsJAGhHAtEousoWV OcW8MP7d+FNdQl0/OGOc5HbGKOJkLNnQvOJJkfo9bH5vsT7MVYjI1ursPa5tvPhaTbBu LQgQ== X-Gm-Message-State: ANoB5pnH2lTrhAUAA/WsteqH+ylm98RDdTUPYpDglBEtGMsm/FahY348 R80F2Ld5PN43GG86WuCA38isgtTAiu0= X-Received: by 2002:a17:903:1106:b0:189:528b:7a14 with SMTP id n6-20020a170903110600b00189528b7a14mr1809147plh.62.1669226534043; Wed, 23 Nov 2022 10:02:14 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:13 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 02/15] perf stat: Move summary prefix printing logic in CSV output Date: Wed, 23 Nov 2022 10:01:55 -0800 Message-Id: <20221123180208.2068936-3-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311110460256135?= X-GMAIL-MSGID: =?utf-8?q?1750311110460256135?= It matches to the prefix (interval timestamp), so better to have them together. No functional change intended. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 46e90f0bb423..d86f2f8e020d 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -713,11 +713,6 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int nl = config->metric_only ? new_line_metric : new_line_std; } - if (!config->no_csv_summary && config->csv_output && - config->summary && !config->interval && !config->metric_only) { - fprintf(config->output, "%16s%s", "summary", config->csv_sep); - } - if (run == 0 || ena == 0 || counter->counts->scaled == -1) { if (config->metric_only) { pm(config, &os, NULL, "", "", 0); @@ -828,8 +823,13 @@ static void print_counter_aggrdata(struct perf_stat_config *config, ena = aggr->counts.ena; run = aggr->counts.run; - if (prefix && !metric_only) - fprintf(output, "%s", prefix); + if (!metric_only) { + if (prefix) + fprintf(output, "%s", prefix); + else if (config->summary && config->csv_output && + !config->no_csv_summary && !config->interval) + fprintf(output, "%16s%s", "summary", config->csv_sep); + } uval = val * counter->scale; From patchwork Wed Nov 23 18:01:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2941421wrr; Wed, 23 Nov 2022 10:04:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Cll89tGGqwq4Ak9eCAmwRKQR/LfXpd9W9AmD1qprxbnwx07ezxwm62YNf0iDrjaqhKQSU X-Received: by 2002:a17:906:3e13:b0:78d:502c:aeb5 with SMTP id k19-20020a1709063e1300b0078d502caeb5mr9617748eji.88.1669226660369; Wed, 23 Nov 2022 10:04:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226660; cv=none; d=google.com; s=arc-20160816; b=W9OeUbNcUcn+KoIYxWHW+LC6F2yrKZ6DOCFjwnvddq1Yksg+WWu5tAIGx2pYfHyvms SRNkVx2kT+coMpH445bRKKJdBl1WvMLkh2ymQsNc10xWUqUE+QTEcl8gIlrCiziV6GVP Y+1yaGvFsZfhzCapGKSEUJsCgLjuBt0dajM9GBgPl/EPlAbrrjSy6j8V+bxx59FjA2R4 7Lfct2RxSnvgaqjo/6wI4d86OgN4/xFpqXAT7ssVaYEDvL6Psl/18Q2/DINxqq6bSX6I LN9gon1KjJTYtjftiJ2EQUYmwiU+YbT5+H8AQuxIzFnfAQVFci7bh7mqenMgWkceV4Da ed4w== 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:sender :dkim-signature; bh=2+TpuAANzcP9G4GqFnOlMV6rE/MSCSJ6k6rsAEAM1JY=; b=h7LAmmHMrZa6553KBkZG2Kd1/zX/uasMW1l8XAW/2C6l6BXVIJIhozeLui3sdBjLVM DMIwiI4ycCotHHZoVnJT8Rxmz+wwS4kaIEPUJhAJ6x7WnAhUjI2ZXxfL/6pM73ypGhKu vCs+LjctmL2+4KWtNNG9IbDW3IBsFGrOYL4R3YAQAoJhCNG9r23Lr01w+V1rjRrDxzTU bDgEIlA1PLrnGVD5VnTlxg/N9zeBEMHnGNyOoFinb9XldBXjS5Ks4TtfExKO7cHSimeU Zlosk9lPHhRx6/xDniggVLLQBA8Tzoo5+0JZ5nZQfX1B2b7yrHscaRDKLYcdKWWb02A3 tgKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Qckf1ASh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a1709064a9800b007adeb7f8e5bsi11483152eju.913.2022.11.23.10.03.41; Wed, 23 Nov 2022 10:04:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Qckf1ASh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239452AbiKWSCq (ORCPT + 99 others); Wed, 23 Nov 2022 13:02:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239331AbiKWSCQ (ORCPT ); Wed, 23 Nov 2022 13:02:16 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0143260F9; Wed, 23 Nov 2022 10:02:16 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so2788706pjs.4; Wed, 23 Nov 2022 10:02:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=2+TpuAANzcP9G4GqFnOlMV6rE/MSCSJ6k6rsAEAM1JY=; b=Qckf1AShYdSF9G+SM4znSrGcL1PG0FNywXkO2Cibdzj4VjnLMOACwa0J68haTtg1HK SWmpNPJbu8jZWhj5SySKAYCrNWg4RxlUf1SpWQkIl9u5w3Ety/IzEeZxQNkEQQEYx7Qj 7Xk9/WxFT2hht4RZZV9fXwQB50IApNNyMILgEFU9Cun1jGmH/ouMDyiPwJ6cxc+kW3sT wCiraHoERWTJgIgSqe0lsndPeA+LLpgmIT3UVnL6FD2cOo7n7v4iQKLkGdK5opPsZFnp KFEGP6llqvyDSPtsPWle7Ioym2OTOWOhuU5c5WouuINBgmqmRkuBzJ4UOdIFg4q2/22y /opQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2+TpuAANzcP9G4GqFnOlMV6rE/MSCSJ6k6rsAEAM1JY=; b=f2nfvIWj4XwB19/9wUmCwqMyVRSN197yQa4vxf9tB+F4Wf9KzbLQsDVbbafH4e62vW i8f46Mrp2IXEeKxiC8wz5F34BC4n0Rw+XHm3usOBp3g5AU+jtxgd38qd/0QqrWyI2o7n AM5cnikX+ziLH4EmGsqIe5q3mpWrC4uk32FZUYoNu22D4RxNP2rGO6eivtyRUjS5KtYS hicz0QWQYNniO7zjZR7YlCP3QJ1wNrhBdzv04+4M+OsWah5wW/iAPBjqUs/416P+3v+e hjYAFVfbIZTQBk+ix3Nn60GpYEvOgFKzUQDPkMYGxAdBLpoXbernKRzXzGEpkkbYA1V2 vI1A== X-Gm-Message-State: ANoB5pnJqaerenHVK6Oz6U6/MlObf/bCDXqTihBmPQPAFIurRd3MDMeG 0VlFeNTy+ZgbpFV7pP6Ae5U= X-Received: by 2002:a17:902:8212:b0:186:85c3:98b7 with SMTP id x18-20020a170902821200b0018685c398b7mr10562086pln.31.1669226535358; Wed, 23 Nov 2022 10:02:15 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:15 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 03/15] perf stat: Do not align time prefix in CSV output Date: Wed, 23 Nov 2022 10:01:56 -0800 Message-Id: <20221123180208.2068936-4-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311014840480684?= X-GMAIL-MSGID: =?utf-8?q?1750311014840480684?= We don't care about the alignment in the CSV output as it's intended for machine processing. Let's get rid of it to make the output more compact. Before: # perf stat -a --summary -I 1 -x, true 0.001149309,219.20,msec,cpu-clock,219322251,100.00,219.200,CPUs utilized 0.001149309,144,,context-switches,219241902,100.00,656.935,/sec 0.001149309,38,,cpu-migrations,219173705,100.00,173.358,/sec 0.001149309,61,,page-faults,219093635,100.00,278.285,/sec 0.001149309,10679310,,cycles,218746228,100.00,0.049,GHz 0.001149309,6288296,,instructions,218589869,100.00,0.59,insn per cycle 0.001149309,1386904,,branches,218428851,100.00,6.327,M/sec 0.001149309,56863,,branch-misses,218219951,100.00,4.10,of all branches summary,219.20,msec,cpu-clock,219322251,100.00,20.025,CPUs utilized summary,144,,context-switches,219241902,100.00,656.935,/sec summary,38,,cpu-migrations,219173705,100.00,173.358,/sec summary,61,,page-faults,219093635,100.00,278.285,/sec summary,10679310,,cycles,218746228,100.00,0.049,GHz summary,6288296,,instructions,218589869,100.00,0.59,insn per cycle summary,1386904,,branches,218428851,100.00,6.327,M/sec summary,56863,,branch-misses,218219951,100.00,4.10,of all branches After: 0.001148449,224.75,msec,cpu-clock,224870589,100.00,224.747,CPUs utilized 0.001148449,176,,context-switches,224775564,100.00,783.103,/sec 0.001148449,38,,cpu-migrations,224707428,100.00,169.079,/sec 0.001148449,61,,page-faults,224629326,100.00,271.416,/sec 0.001148449,12172071,,cycles,224266368,100.00,0.054,GHz 0.001148449,6901907,,instructions,224108764,100.00,0.57,insn per cycle 0.001148449,1515655,,branches,223946693,100.00,6.744,M/sec 0.001148449,70027,,branch-misses,223735385,100.00,4.62,of all branches summary,224.75,msec,cpu-clock,224870589,100.00,21.066,CPUs utilized summary,176,,context-switches,224775564,100.00,783.103,/sec summary,38,,cpu-migrations,224707428,100.00,169.079,/sec summary,61,,page-faults,224629326,100.00,271.416,/sec summary,12172071,,cycles,224266368,100.00,0.054,GHz summary,6901907,,instructions,224108764,100.00,0.57,insn per cycle summary,1515655,,branches,223946693,100.00,6.744,M/sec summary,70027,,branch-misses,223735385,100.00,4.62,of all branches Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index d86f2f8e020d..15c88b9b5aa3 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -828,7 +828,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, fprintf(output, "%s", prefix); else if (config->summary && config->csv_output && !config->no_csv_summary && !config->interval) - fprintf(output, "%16s%s", "summary", config->csv_sep); + fprintf(output, "%s%s", "summary", config->csv_sep); } uval = val * counter->scale; @@ -1078,9 +1078,12 @@ static void prepare_interval(struct perf_stat_config *config, if (config->iostat_run) return; - if (!config->json_output) - sprintf(prefix, "%6lu.%09lu%s", (unsigned long) ts->tv_sec, + if (config->csv_output) + sprintf(prefix, "%lu.%09lu%s", (unsigned long) ts->tv_sec, ts->tv_nsec, config->csv_sep); + else if (!config->json_output) + sprintf(prefix, "%6lu.%09lu ", (unsigned long) ts->tv_sec, + ts->tv_nsec); else if (!config->metric_only) sprintf(prefix, "{\"interval\" : %lu.%09lu, ", (unsigned long) ts->tv_sec, ts->tv_nsec); From patchwork Wed Nov 23 18:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25102 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2941451wrr; Wed, 23 Nov 2022 10:04:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf5nCees+yFaJAuaMELIBBf/Iw/bVb1Ln+EX6Txo9eBlgLQUNfMwPI5X3BmbjM9B0/ynBHnR X-Received: by 2002:ac2:52a2:0:b0:4ac:d6e4:41d4 with SMTP id r2-20020ac252a2000000b004acd6e441d4mr9226001lfm.253.1669226662484; Wed, 23 Nov 2022 10:04:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226662; cv=none; d=google.com; s=arc-20160816; b=aD7giSKh08u+cHu4V1Hlmk8S0W4T6cOsrnfA5ZIL9qJZbJszBSeFlSyawV9ft5URAW TNTlGHm3NH6oC+H9Lluf9gs6C6M+W0OXJ0EhR99vg+07uOk85zlSL/t3YYxWBoKhu6Y1 4fVyrBwe/35vJN0C0E4D1xsLkXT0WBvCsydJ95/sMGYH44ncZt7PMSohl0VMVZyF35MC 0hvZQFEio2xQY7+0XwS68PffMf5LTSszzQyWqprSj+tvK9sAGA3i6RCFd20if8+jwZ9M sLc31yFiF5KeXlhtOvELIpf9fMGCCt6t//tZBi2oozJkqPlabQda4cPsAiEFIRuvuIyO rpfw== 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:sender :dkim-signature; bh=/XCyVoN2CehHx7RpmSNkS0ILYMPbGDge+MWsh49BZP0=; b=UslwuVTsiD8nc0J4qLlzchGbdZylUcSLxP4z6hykH+6IUdmjDPS7tjDG+79JIjfm+T V6HhliYrIhXJg8DDO7O8JX4nrRlclYnv6ZwldA8KbfufTZCGEGCClHkEM5LHBxCI2ogb fJHURvHJGJfA944u83vD9MkxCKK54nzurt3JxQuc7kJW4VWui1mPX2vC/krljUkejkjn JdWB5OrJJqFI8MjMwrSrWbsr9L2vk9z1UFZexQSe/3TDw+af0fPoE9lWK/3tE1y8itJ+ HE6ti7hL9JzlkWUhdIlBcd7Hlo68RfIGEPQYg3oq9HB7FfAJRmD/s7/+T0b+VFa/OhDS vP/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RA6XwERA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg16-20020a170907971000b0078db3f08a6bsi15893221ejc.720.2022.11.23.10.03.42; Wed, 23 Nov 2022 10:04:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RA6XwERA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239457AbiKWSCr (ORCPT + 99 others); Wed, 23 Nov 2022 13:02:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239343AbiKWSCR (ORCPT ); Wed, 23 Nov 2022 13:02:17 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5011893CC7; Wed, 23 Nov 2022 10:02:17 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id y14-20020a17090a2b4e00b002189a1b84d4so2526037pjc.2; Wed, 23 Nov 2022 10:02:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=/XCyVoN2CehHx7RpmSNkS0ILYMPbGDge+MWsh49BZP0=; b=RA6XwERAQ9oFGKRK9FwW2+BAXVuDXEcWwE98pPTTLsUP3d/uoo+JL//dsBAHnjn4YX r41ok0+UGjJ+K1LT5J3SdMujw8e0BulQwi3Lcb3Cp/GjmqYJqO+VDT9wAJbV6d2rnYju WGmkHN/N3eh3XepR7sYmi6x7gzb9c6dF8l5NxzN+k5SNSS8FLJHyg1lVrz/g/wzFltnh Im0n53P1/kfTNowa3pf9fMXGAqer8r/eGnrCNNalZx1GRcURXPsVDNkgjBkgqeEE1Roa r7RGzZB0EBZB5KcoNvu04H65LpGejG3zpHEBgWxJ3xdOiFHXNdAquYcJMz4e7Gb2nJBJ 7rfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/XCyVoN2CehHx7RpmSNkS0ILYMPbGDge+MWsh49BZP0=; b=e6dLkJ91kdtIrZ9W4/ilx+sXFmQpIFW+eIWnVluRccnPgYzpAwAyQNK4FfamAFVCXD 2xnQyZo8krq0baUDbZKbrqCqeWKRd6PD29SD1AOsWxbroEN/b1OXtr4BE+RVkMsRCkdw zJM7IHrvm8fUiOqpRsXrIrr7g/uSR21oSmLMI6S8ao0pFjcr58qD1P1pvuygkIufPEKH s1B8NQ692n8qbFAQMAfSofTaqLLqqQ+u63tN996qNQY4ayI8BRWxwESKRevfRwno3Vgc Pi96Y8wUOjXYLpnTB+65RvH32KAhmRphUm6/74HMLfD6CqhBj/8fYCkkM7SLd70BYw/L k1sg== X-Gm-Message-State: ANoB5pnQWiWIRqDivTc3GoytDahG87olscMZq9tb6T1Qph548Vgn5soc podUpHuoBe7IO7VODbZ/eGU= X-Received: by 2002:a17:902:6847:b0:183:6555:38ef with SMTP id f7-20020a170902684700b00183655538efmr13403292pln.157.1669226536694; Wed, 23 Nov 2022 10:02:16 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:16 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 04/15] perf stat: Use scnprintf() in prepare_interval() Date: Wed, 23 Nov 2022 10:01:57 -0800 Message-Id: <20221123180208.2068936-5-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311016762729674?= X-GMAIL-MSGID: =?utf-8?q?1750311016762729674?= It should not use sprintf() anymore. Let's pass the buffer size and use the safer scnprintf() instead. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 15c88b9b5aa3..744b7a40f59a 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -1073,23 +1073,23 @@ static void print_metric_headers(struct perf_stat_config *config, } static void prepare_interval(struct perf_stat_config *config, - char *prefix, struct timespec *ts) + char *prefix, size_t len, struct timespec *ts) { if (config->iostat_run) return; if (config->csv_output) - sprintf(prefix, "%lu.%09lu%s", (unsigned long) ts->tv_sec, - ts->tv_nsec, config->csv_sep); + scnprintf(prefix, len, "%lu.%09lu%s", + (unsigned long) ts->tv_sec, ts->tv_nsec, config->csv_sep); else if (!config->json_output) - sprintf(prefix, "%6lu.%09lu ", (unsigned long) ts->tv_sec, - ts->tv_nsec); + scnprintf(prefix, len, "%6lu.%09lu ", + (unsigned long) ts->tv_sec, ts->tv_nsec); else if (!config->metric_only) - sprintf(prefix, "{\"interval\" : %lu.%09lu, ", (unsigned long) - ts->tv_sec, ts->tv_nsec); + scnprintf(prefix, len, "{\"interval\" : %lu.%09lu, ", + (unsigned long) ts->tv_sec, ts->tv_nsec); else - sprintf(prefix, "{\"interval\" : %lu.%09lu}", (unsigned long) - ts->tv_sec, ts->tv_nsec); + scnprintf(prefix, len, "{\"interval\" : %lu.%09lu}", + (unsigned long) ts->tv_sec, ts->tv_nsec); } static void print_header_interval_std(struct perf_stat_config *config, @@ -1390,7 +1390,7 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf if (interval) { prefix = buf; - prepare_interval(config, prefix, ts); + prepare_interval(config, buf, sizeof(buf), ts); } print_header(config, _target, evlist, argc, argv); From patchwork Wed Nov 23 18:01:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25125 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942806wrr; Wed, 23 Nov 2022 10:06:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rQ8j2oY2kwF4wirYH8k9TZUyu3NAY6VNOKTNRAPeDJY4LdBv2Cja9ahd2IUvGTgLdhk4p X-Received: by 2002:a17:906:504:b0:7b5:2d9f:4019 with SMTP id j4-20020a170906050400b007b52d9f4019mr15468409eja.536.1669226782561; Wed, 23 Nov 2022 10:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226782; cv=none; d=google.com; s=arc-20160816; b=DVXuZcti1CCxxydB8oCq84XSbbNmDlcRpdAe1dhQ//OX7JPBat2YAv9WZ/cCa/31D8 krEE04U8QSqHT2ZuEtu1gSjptYLIa801uxpa1OFUIJ33Tyw8u7+sDZYHy5FdDRLV8GRU y5RKa6GfD0pRYUfVLCU8i4/KHmUxozWCpoIt34rbfrRhONQasG+TmVbgdlHZPjiqRFRY 5ZmliOkNcTEt6sYOHWoLoF9W9hC5DkrPyb6myyvXzs5QAtsCpJCQOW0Bl129SIMJsD06 Xuap5UQdwD9vY81/pY6CyihQHo/9Vu0adC/E/1b+K5dgiueVxNZXVP9criUTvtnawj8s 6e4g== 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:sender :dkim-signature; bh=XSagVML7GgOqlOudGxczoz0/8G87CcGh9QY51qbKYAY=; b=Fa4vwGA0IwKB4LKbng5Bk/rWx80E0BqzFYZKSC+imR01cJWS4VVwgCX6ve2cg7oEJv adKIcWaBZ+smHMDbuiJa5TkEHFultWZ2Db0+/20Q3Wxs7gWSWJKUUYLLk3leAO91R8WT N5B+CP/G4raG1njIK6J6LWT64zatE3J8NSM7xREwEvmJpQPORxM5CXx0tqWUphmUJocp x9PrNKESsJzhR/KScunpbpyfiofNpcghRQpVzMWzqq4Yg8A5DtAdyjreM3MYUGL9jFYP pborVEFVdKZIuis0dY9K/A7WQSYXMIwAhWuhIJOtJTIP7v3iEaa+RVfYVqOm0cYpHNX7 Z8bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ixqc+fmP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xc1-20020a170907074100b0078da99ecbdbsi13326378ejb.673.2022.11.23.10.05.47; Wed, 23 Nov 2022 10:06:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ixqc+fmP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239318AbiKWSC7 (ORCPT + 99 others); Wed, 23 Nov 2022 13:02:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239359AbiKWSCU (ORCPT ); Wed, 23 Nov 2022 13:02:20 -0500 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC0C160F9; Wed, 23 Nov 2022 10:02:18 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id v28so18006470pfi.12; Wed, 23 Nov 2022 10:02:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=XSagVML7GgOqlOudGxczoz0/8G87CcGh9QY51qbKYAY=; b=ixqc+fmP1EpYwjc94PYCfvYVyvk1b5Q7/lCMMoLyMbzTKtNetDuy/0FhIf8rhhTEi5 G4jqBVVV8NG8HitM5TUlTJMExA1DX4cKRAip8OLufvcBZwHPqYIaCKGd1BpzWYFLkD1o gylPTOpMhucAftwmh9v0CPo4ak1alld20Q7R5poqnbOfhPjkMhGRiTlAzQ0xDA/Vn/f5 x5tOxSMR7KphqJEMgcy7jTa5InRL8z8Zvabm/RiTmV2+kz58p1yIZey+nwChvk6z58GA ji+Gl+OvcYIomtG2t/V2aYdP8YgqrST/zg/oQpt9Tx77R5boFq4izG9abLuzrq6RI45n QzcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XSagVML7GgOqlOudGxczoz0/8G87CcGh9QY51qbKYAY=; b=XgMWds5uELM4fZFBTrQYAmej/wyEb4pCuW6vOCiseeY82n+HDVx648DtNp4Hxm1wWs ZXOSB4AsRjDzD/SXk02yM9gQiHgeePOQl1GIEAz+OcSg5G+9BJCoIYN5mmcJGRk31Z+S 0nNcA4zwVGTz+0c/e9QPlY68AjAwGATIL3snhYnBVcaq3iFVfE6K8zJOd8zIduIu6xxN L4kXP5WmqyB5WEGLKzTJCTFQCJzAlxcGY3m9GrbzxtuYViL9G3pwnMk4k4TBslLgvxuL 8P24VeShSrXEKKT8vpW6GYkq2/UbNGjwMSgUvUa+un1fD+l5F0ewwzr0Vu+hLpfx8A7t 4ruA== X-Gm-Message-State: ANoB5pmYnTJTzGyYPxReYvfk/KNTF/XQrq0gEm90I9xwQP0/rxaJ+ZQH 2h5JFig93nXAYj/vhGRLsCw= X-Received: by 2002:a63:5b44:0:b0:46f:c9e8:5752 with SMTP id l4-20020a635b44000000b0046fc9e85752mr8580769pgm.157.1669226538136; Wed, 23 Nov 2022 10:02:18 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:17 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 05/15] perf stat: Remove prefix argument in print_metric_headers() Date: Wed, 23 Nov 2022 10:01:58 -0800 Message-Id: <20221123180208.2068936-6-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311142917109094?= X-GMAIL-MSGID: =?utf-8?q?1750311142917109094?= It always passes a whitespace to the function, thus we can just add it to the function body. Furthermore, it's only used in the normal output mode. Well, actually CSV used it but it doesn't need to since we don't care about the indentation or alignment in the CSV output. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 744b7a40f59a..deed6ccf072f 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -996,10 +996,9 @@ static void print_no_aggr_metric(struct perf_stat_config *config, } static void print_metric_headers_std(struct perf_stat_config *config, - const char *prefix, bool no_indent) + bool no_indent) { - if (prefix) - fprintf(config->output, "%s", prefix); + fputc(' ', config->output); if (!no_indent) { int len = aggr_header_lens[config->aggr_mode]; @@ -1012,11 +1011,8 @@ static void print_metric_headers_std(struct perf_stat_config *config, } static void print_metric_headers_csv(struct perf_stat_config *config, - const char *prefix, bool no_indent __maybe_unused) { - if (prefix) - fprintf(config->output, "%s", prefix); if (config->interval) fputs("time,", config->output); if (!config->iostat_run) @@ -1024,7 +1020,6 @@ static void print_metric_headers_csv(struct perf_stat_config *config, } static void print_metric_headers_json(struct perf_stat_config *config, - const char *prefix __maybe_unused, bool no_indent __maybe_unused) { if (config->interval) @@ -1032,8 +1027,7 @@ static void print_metric_headers_json(struct perf_stat_config *config, } static void print_metric_headers(struct perf_stat_config *config, - struct evlist *evlist, - const char *prefix, bool no_indent) + struct evlist *evlist, bool no_indent) { struct evsel *counter; struct outstate os = { @@ -1047,11 +1041,11 @@ static void print_metric_headers(struct perf_stat_config *config, }; if (config->json_output) - print_metric_headers_json(config, prefix, no_indent); + print_metric_headers_json(config, no_indent); else if (config->csv_output) - print_metric_headers_csv(config, prefix, no_indent); + print_metric_headers_csv(config, no_indent); else - print_metric_headers_std(config, prefix, no_indent); + print_metric_headers_std(config, no_indent); if (config->iostat_run) iostat_print_header_prefix(config); @@ -1132,7 +1126,7 @@ static void print_header_interval_std(struct perf_stat_config *config, } if (config->metric_only) - print_metric_headers(config, evlist, " ", true); + print_metric_headers(config, evlist, true); else fprintf(output, " %*s %*s events\n", COUNTS_LEN, "counts", config->unit_width, "unit"); @@ -1168,7 +1162,7 @@ static void print_header_std(struct perf_stat_config *config, fprintf(output, ":\n\n"); if (config->metric_only) - print_metric_headers(config, evlist, " ", false); + print_metric_headers(config, evlist, false); } static void print_header_csv(struct perf_stat_config *config, @@ -1178,7 +1172,7 @@ static void print_header_csv(struct perf_stat_config *config, const char **argv __maybe_unused) { if (config->metric_only) - print_metric_headers(config, evlist, " ", true); + print_metric_headers(config, evlist, true); } static void print_header_json(struct perf_stat_config *config, struct target *_target __maybe_unused, @@ -1187,7 +1181,7 @@ static void print_header_json(struct perf_stat_config *config, const char **argv __maybe_unused) { if (config->metric_only) - print_metric_headers(config, evlist, " ", true); + print_metric_headers(config, evlist, true); } static void print_header(struct perf_stat_config *config, From patchwork Wed Nov 23 18:01:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25116 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942231wrr; Wed, 23 Nov 2022 10:05:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xPSOUozzGbx6Kw9s3LuMKnLVxEpDFP9dJ2bZUvLoFu+mIx0kLfj0SvWRyTdh5InFof4CD X-Received: by 2002:a05:6402:1156:b0:467:374e:5f9b with SMTP id g22-20020a056402115600b00467374e5f9bmr9773809edw.283.1669226730700; Wed, 23 Nov 2022 10:05:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226730; cv=none; d=google.com; s=arc-20160816; b=q7tDZEPYPgMBz7EmiB8CLH8WutgArnDE56z/j8+DsA+6Jm6KFMliflHtc6WYrvYccV RPkFeHWtj1Yw8Wb9zuLv+vxxUOEyNdIaZqbu5Lbrkbsle9ERlZ9/s2Bd44Q/PKhJqxgA OrB7+ReJFYnuPloLW8kal6HUOsrIK+4kLrgdnSDAqpfcgKrbK2gc9n+Lix3np3ZhQ+BD T8s+39lF4AxLNUPsQYxBmC2qzS0hbuNdS+T0sUt3NjdmOtc/eQDLtLQBJU90/NwmK5T3 Q9cu50Jf00m24VeW/M1GByL/xenm5YvNiSp1UjqvjILjV1s94Ae8DSEDBLuQSA+rUvJT KQ2g== 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:sender :dkim-signature; bh=wPQ8P3nU21IfgJbVSUsmZkRPaAsgEAfzrcAmOBgJcJc=; b=f74MeSU5IUzoMrvqsysts0uAXdD5k6CG258zBsk0AMdaEdTzPbLAOXxZvmruCgGN+B GbfzQYxPH7RkMgz8J1TKmVU8+FKTulqI7CJtNmE/wdyNRtZXI2M7frHsHvTZbzI+/+qH 8Il72Qk4BwbzzaiYx5Gstx+PPr7JgwuOhAazkf0UFTVac3ykOBqfArU90S+Kxx9v4zFg o6YBPTPwC+H+d1Rc5fEUEkB6MmX8YosB/5+l4yt6Y/3oL47LRhvrj2kJgJCgzNWyxLsK CB3kec1jb1iR8yg2ZYwzEAqNSPQ2tY7iQiPrEb0f6a+az3ojKrIHQnlXpGspGCzv5uef cyxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XodpcMZ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id js16-20020a17090797d000b0078dd7383ed8si316790ejc.414.2022.11.23.10.05.00; Wed, 23 Nov 2022 10:05:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XodpcMZ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239467AbiKWSCz (ORCPT + 99 others); Wed, 23 Nov 2022 13:02:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239358AbiKWSCU (ORCPT ); Wed, 23 Nov 2022 13:02:20 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A0708C7AC; Wed, 23 Nov 2022 10:02:20 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id z26so18043996pff.1; Wed, 23 Nov 2022 10:02:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=wPQ8P3nU21IfgJbVSUsmZkRPaAsgEAfzrcAmOBgJcJc=; b=XodpcMZ2oWHY0XKzWbfgqlzj29kXT6pHHoRLdtKPChW+Bzhl9tjvrT0tTwqi0oNGPx 9MAF3k8QiymFCay7KPLBLyWvoWWPB3bYGghigHjQhEqKuuu9uwbqhMP+b3TBvx/xM8Ct jxe05iIi9y/4gevIheL02YEAfO/rf6JGx5Kmv59J7ZHy/UKRpGHc5I1F0DrYe18iMvHZ 4ldG+Y0s1boJ98+mydOrshVX/mc8vKcNrF4hezJvgYsTd69GAvoCUeXqFKW1PwsXgIGT RO+EydA415QIBSO7jXa5PQBVejL7TWtHQtH6nzi5DNdPQCm79ClI5tKWuy0aYqbv99cm apqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wPQ8P3nU21IfgJbVSUsmZkRPaAsgEAfzrcAmOBgJcJc=; b=BVGRgXm6maPlf1qcyPxHIHQdh/4pfoVDtfkqcgoWH6U/GysbjtcV3h+t2MYwaxJTMW BEfptCrsE3sZYYLyYgHChsLOzZDX45ED/4wiStLimB6+Hu5OslNQ+94eWL53eXPIYTCc 15qphgDzsXvkKhUaNcCCJyZsvO5S41weyRm/HCwZ+lWsHYgPZmL+tKouRdzbk7piEiVq nF1mqlmWQ6zTI2QEh8YcCKjgyKF+vef986KYoVChPCJoQxubMZQy9A6yT5z9TEc94eaV ud3EFHv3ve+MeAk7L9iPnp5xfcH6xbxoi86rTFCU/nFNIfr69oF3Xr7kmIZ+7VqRAv85 qL4Q== X-Gm-Message-State: ANoB5pk4eVVjMcHjJKpXf2dAKWuofFXvPRvl+7SbKuYa8PwkldmJD3MC +2uQEBla9qoUOpxU+bdRgCY= X-Received: by 2002:a65:5541:0:b0:476:759b:7952 with SMTP id t1-20020a655541000000b00476759b7952mr8798859pgr.316.1669226539497; Wed, 23 Nov 2022 10:02:19 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:19 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 06/15] perf stat: Remove metric_only argument in print_counter_aggrdata() Date: Wed, 23 Nov 2022 10:01:59 -0800 Message-Id: <20221123180208.2068936-7-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311088532219140?= X-GMAIL-MSGID: =?utf-8?q?1750311088532219140?= It already passes the stat_config argument, then it can find the value in the config. No need to pass it separately. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index deed6ccf072f..b8432c0a0ec3 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -804,7 +804,7 @@ static void uniquify_counter(struct perf_stat_config *config, struct evsel *coun static void print_counter_aggrdata(struct perf_stat_config *config, struct evsel *counter, int s, - char *prefix, bool metric_only) + char *prefix) { FILE *output = config->output; u64 ena, run, val; @@ -813,6 +813,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, struct perf_stat_aggr *aggr = &ps->aggr[s]; struct aggr_cpu_id id = config->aggr_map->map[s]; double avg = aggr->counts.val; + bool metric_only = config->metric_only; if (counter->supported && aggr->nr == 0) return; @@ -875,7 +876,6 @@ static void print_aggr(struct perf_stat_config *config, struct evlist *evlist, char *prefix) { - bool metric_only = config->metric_only; struct evsel *counter; int s; @@ -893,8 +893,7 @@ static void print_aggr(struct perf_stat_config *config, if (counter->merged_stat) continue; - print_counter_aggrdata(config, counter, s, prefix, - metric_only); + print_counter_aggrdata(config, counter, s, prefix); } print_metric_end(config); } @@ -904,7 +903,6 @@ static void print_aggr_cgroup(struct perf_stat_config *config, struct evlist *evlist, char *prefix) { - bool metric_only = config->metric_only; struct evsel *counter, *evsel; struct cgroup *cgrp = NULL; int s; @@ -928,8 +926,7 @@ static void print_aggr_cgroup(struct perf_stat_config *config, if (counter->cgrp != cgrp) continue; - print_counter_aggrdata(config, counter, s, prefix, - metric_only); + print_counter_aggrdata(config, counter, s, prefix); } print_metric_end(config); } @@ -939,7 +936,6 @@ static void print_aggr_cgroup(struct perf_stat_config *config, static void print_counter(struct perf_stat_config *config, struct evsel *counter, char *prefix) { - bool metric_only = config->metric_only; int s; /* AGGR_THREAD doesn't have config->aggr_get_id */ @@ -950,8 +946,7 @@ static void print_counter(struct perf_stat_config *config, return; for (s = 0; s < config->aggr_map->nr; s++) { - print_counter_aggrdata(config, counter, s, prefix, - metric_only); + print_counter_aggrdata(config, counter, s, prefix); } } @@ -1339,7 +1334,7 @@ static void print_percore(struct perf_stat_config *config, if (found) continue; - print_counter_aggrdata(config, counter, s, prefix, metric_only); + print_counter_aggrdata(config, counter, s, prefix); core_map->map[c++] = core_id; } From patchwork Wed Nov 23 18:02:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2941740wrr; Wed, 23 Nov 2022 10:04:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf41hkxWJ09RgYPT2f1kkRkeqhe8VrMgbcclUXBem/Sg3heFYT4MqyBwakgM+SD0qNg6yvfJ X-Received: by 2002:a05:6512:b9a:b0:4ae:611c:6549 with SMTP id b26-20020a0565120b9a00b004ae611c6549mr11582410lfv.231.1669226688813; Wed, 23 Nov 2022 10:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226688; cv=none; d=google.com; s=arc-20160816; b=v2Q+/VWD9WAWFCS5fiZ6TEaREsTGcpSsv/WUteA3jcaG3dmxFssG7q1xKQja9osL/N lNGxztSeweoAL94Tuk37INP0BTgH+ys8n3sQXrMwxg6GxSngpa1/rka1w3yQsCU2whpO Ert0/KnxbR+JD/e4TGE+ssBCruh/sIISk2IvzsEi6Yhxl8hj8SOl/EcgkeUPAGKWioHG iCFqAvhUdiONWvd9Xf9Fx5IXoVN08TE9awGBAWnV3dxN5lE+5jSPFM/FaQwG87Roa7J8 A/ot4tWrpguoGOQAN5ev13MUV+F9uC118DEazzp6QDvbMzAXIavDFzPSdtvGFuw4DX3c 4QUg== 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:sender :dkim-signature; bh=KJjAbNczdPmI+pY4vossNpZ8T3nSlNCnYIGtcl6U+Gg=; b=fDDH0huFAyKX31VosxwT8RBDg6K4TtWIK/j407pFXhs4XSoYcx4VVuRtZnH4BmoMfU 1e19+m0QCuK0NWFr9ibBMprfNVZzf/kYD4rdXdym4NdE6HXf2WaIbA6oupGJvSse+kr4 0SyMefe3yPw+fBpyOZLs8VDA3KGh09W5xrYky+dVzcC9YnIj0hXwBrDFtFZUc57iOM0F Qbnjjz4PRjc5YRod95UwcnfEZJevRGfRRlbRMqYqRA+VF3U07p052QiEx7I8c0z+mr35 frGUwrsg3QPF6yGKfPMvrzyiiC0KvdAKOjpTZhX67dkzZ3aY3XsrF4M2Xj6MEOZsAiDi Bd6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Cuu5H+8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a170906268600b0077082e784easi11188233ejc.957.2022.11.23.10.04.15; Wed, 23 Nov 2022 10:04:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Cuu5H+8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239512AbiKWSDS (ORCPT + 99 others); Wed, 23 Nov 2022 13:03:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239369AbiKWSCW (ORCPT ); Wed, 23 Nov 2022 13:02:22 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D9160F9; Wed, 23 Nov 2022 10:02:21 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id y14-20020a17090a2b4e00b002189a1b84d4so2526268pjc.2; Wed, 23 Nov 2022 10:02:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=KJjAbNczdPmI+pY4vossNpZ8T3nSlNCnYIGtcl6U+Gg=; b=Cuu5H+8mTH7jygpCY2UXxe3pbnrfQIhaMU6p0rkTvte1Km2MeKSYJZTuy4LGGZ4fQV CbWtT4Sh771YsHRjJRBizqAvlZihRRztwBtcuezbqhthK3EFE+MasRmYGe9H27JRrVSa MmmUnr86X1depxIc1WwSs1rQnn9eprRM/XuajsgY5n++dVlrkfh9ZahatVaJYGa4V7od Sk6D30WhLENC3MGc9sCNSzcI/eRzI7rKVUIXjrsz5HDiGaqq7vgL+NmW2yH1/KuXIZW3 /gsDhP7BE5a8/WZay0s512Okedc0ZGrT3OzUwRM/GSXipeIG1W2L5q0ZVo220T1/+td1 Cu4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KJjAbNczdPmI+pY4vossNpZ8T3nSlNCnYIGtcl6U+Gg=; b=P5f+dUx3zs1Gu4NThVS4Kt2Tz+iJWEIE2j/UsiDzeIg2xQBVZgy7OkiPsbZXV236OD xanrHd1x2H2gl6opS7mcSvK2wsDYDyXo/+VLD3PJlRoO4f85IeuJuZ0ivZNnmCZvNZh2 PkTHpi+iKPDixPJ6+834sSW3b3OUMjOYw5Zyc+AIAcXCMTOvzqUScGBsbi8Zn6jyau3E nX51sGLv2IEsRrbTbDBg/GiFdN/BDtieMk7x/QtDHniL/WDVmc38rdeacaTd6fIjwGug Zcxy6BtgWEPcY/IkT63xy5mlwSkHwwc7qWlue1GamrrXkONNw+8dVXnmYI6KP8/X2E4s Ax4g== X-Gm-Message-State: ANoB5pkVUyDifnKzbxZqfGvOe41wM4vUX7EkzExJkod0tg67XNn6HXz2 3ebWmanqIy/COMxeMYU/wyU= X-Received: by 2002:a17:90a:2b44:b0:213:d66b:4973 with SMTP id y4-20020a17090a2b4400b00213d66b4973mr37992528pjc.85.1669226540963; Wed, 23 Nov 2022 10:02:20 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:20 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 07/15] perf stat: Pass const char *prefix to display routines Date: Wed, 23 Nov 2022 10:02:00 -0800 Message-Id: <20221123180208.2068936-8-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311044558215701?= X-GMAIL-MSGID: =?utf-8?q?1750311044558215701?= This is a minor cleanup and preparation for the later change. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/iostat.h | 2 +- tools/perf/util/stat-display.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/iostat.h b/tools/perf/util/iostat.h index 23c1c46a331a..c22688f87cb2 100644 --- a/tools/perf/util/iostat.h +++ b/tools/perf/util/iostat.h @@ -28,7 +28,7 @@ enum iostat_mode_t { extern enum iostat_mode_t iostat_mode; -typedef void (*iostat_print_counter_t)(struct perf_stat_config *, struct evsel *, char *); +typedef void (*iostat_print_counter_t)(struct perf_stat_config *, struct evsel *, const char *); int iostat_prepare(struct evlist *evlist, struct perf_stat_config *config); int iostat_parse(const struct option *opt, const char *str, diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index b8432c0a0ec3..d2894a519d61 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -675,7 +675,7 @@ static bool is_mixed_hw_group(struct evsel *counter) static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int nr, struct evsel *counter, double uval, - char *prefix, u64 run, u64 ena, double noise, + const char *prefix, u64 run, u64 ena, double noise, struct runtime_stat *st, int map_idx) { struct perf_stat_output_ctx out; @@ -804,7 +804,7 @@ static void uniquify_counter(struct perf_stat_config *config, struct evsel *coun static void print_counter_aggrdata(struct perf_stat_config *config, struct evsel *counter, int s, - char *prefix) + const char *prefix) { FILE *output = config->output; u64 ena, run, val; @@ -843,7 +843,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, static void print_metric_begin(struct perf_stat_config *config, struct evlist *evlist, - char *prefix, int aggr_idx, + const char *prefix, int aggr_idx, struct cgroup *cgrp) { struct perf_stat_aggr *aggr; @@ -874,7 +874,7 @@ static void print_metric_end(struct perf_stat_config *config) static void print_aggr(struct perf_stat_config *config, struct evlist *evlist, - char *prefix) + const char *prefix) { struct evsel *counter; int s; @@ -901,7 +901,7 @@ static void print_aggr(struct perf_stat_config *config, static void print_aggr_cgroup(struct perf_stat_config *config, struct evlist *evlist, - char *prefix) + const char *prefix) { struct evsel *counter, *evsel; struct cgroup *cgrp = NULL; @@ -934,7 +934,7 @@ static void print_aggr_cgroup(struct perf_stat_config *config, } static void print_counter(struct perf_stat_config *config, - struct evsel *counter, char *prefix) + struct evsel *counter, const char *prefix) { int s; @@ -952,7 +952,7 @@ static void print_counter(struct perf_stat_config *config, static void print_no_aggr_metric(struct perf_stat_config *config, struct evlist *evlist, - char *prefix) + const char *prefix) { int all_idx; struct perf_cpu cpu; @@ -1301,7 +1301,7 @@ static void print_footer(struct perf_stat_config *config) } static void print_percore(struct perf_stat_config *config, - struct evsel *counter, char *prefix) + struct evsel *counter, const char *prefix) { bool metric_only = config->metric_only; FILE *output = config->output; @@ -1345,7 +1345,7 @@ static void print_percore(struct perf_stat_config *config, } static void print_cgroup_counter(struct perf_stat_config *config, struct evlist *evlist, - char *prefix) + const char *prefix) { struct cgroup *cgrp = NULL; struct evsel *counter; From patchwork Wed Nov 23 18:02:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2941852wrr; Wed, 23 Nov 2022 10:04:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf54erWWxpEdHBCU3xrWrhLRnUTH6v2xpghb7pDfjgAPeMnbSL05+/xHr8p95aYq6ZJAcYh9 X-Received: by 2002:a2e:800b:0:b0:277:5f7e:9cad with SMTP id j11-20020a2e800b000000b002775f7e9cadmr8812890ljg.420.1669226698609; Wed, 23 Nov 2022 10:04:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226698; cv=none; d=google.com; s=arc-20160816; b=LQ9/iB7KilUsaDeUYQFHs4ZQsra+hDn/dtbHuQdSL8H+/NdSLSofubt9/Lr0XJAXE7 xswf8hwrQ9+gQFtZNDxaL3rG56RLfeuMUilQbvhCUJOQt1BtIaT4a9UOpH8XgRh4zFEX uYUd7RgERcAfZLhp0StxaeU+SUFI3N3zQ6VhmCEOHPV+yqc0o9Y9mzY60oyiuSLrVy+p DXWfIXM9gVtFvmNOsdddT1B9vnzvN+gRSniuy6u7q+Ztfy2qREP8QudAeB82UXOH5n5n mPGNxShTKtL2pV3V6Yv4zY1i4iHPeirM90vuAXY7H6eRpy9JKXEBkMS3z+/OCpXPYIaz P0hA== 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:sender :dkim-signature; bh=e5YlYwASYbZHVOyqMgrEDdQ4f+mzDqMyHGJNku61KwY=; b=gtzso5qhVs/77gTT0XLYv5zn6BwOKjyDVPblCQQAPbx39xwozmpIaEo6stwROpfWYq nI+aN/7zXIzyFgXrxXMr36QwZ2mo5ySXV7PvO6RAMr8V1KsTTXKSLb4FbXJdXQqXEHP8 VvR/sMPzOQhyhBxARgQKYDMRduBqTNFyrty+340F/6IgB3mk46z6n+ZVPcIKfd8vDo9K QdaK2xL++v0T6GS8k4JGk7ueebz1zbJeHmF6jD44JvtIuaMAJFcJor5GgCSKZGKHJ3QZ 3kTJLCXdfG29UkQYEXS7J9JAaAOWaNCDFB/oQo7fU3UWZoNEKdM8fZYMtlHepbXJs32j vWog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="T2I/KuoD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb22-20020a1709071c9600b0073daf6b44a5si16331695ejc.775.2022.11.23.10.04.24; Wed, 23 Nov 2022 10:04:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="T2I/KuoD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238922AbiKWSD3 (ORCPT + 99 others); Wed, 23 Nov 2022 13:03:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239376AbiKWSCY (ORCPT ); Wed, 23 Nov 2022 13:02:24 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E841597361; Wed, 23 Nov 2022 10:02:22 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id 62so17348211pgb.13; Wed, 23 Nov 2022 10:02:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=e5YlYwASYbZHVOyqMgrEDdQ4f+mzDqMyHGJNku61KwY=; b=T2I/KuoDwuUz9H2yYwNvWgGn38WayvSDn/DlKLrSa4DWYmZ3CdSxht/JVkV3izEfNK hq9e09W/D0d/gtZNDqU5MIlmrgM10cWrKJzTxvKqN17Uz/CTQklD8JK4uJWvlxXx8jTx XzQA9LCrZBeRJ+fwcmsmfkLt/PVIJQq9xt9Ltuz4vAuREgspV3q4orFF9pq6zVautPGK 9D8M+mEpsNhrQ5ZVl83fCGqMSnntuMxI4yl1bljPeQI8Hq6HY/B9W4C4+Jp8gRXaF3/C doBLEzxRCz+QIcToOv6ajB6pFkF1feP4UW0lyUscZknSXOPKKBgSW5nObJeqG9NPIu0C UBMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e5YlYwASYbZHVOyqMgrEDdQ4f+mzDqMyHGJNku61KwY=; b=moxPuiz5/A4wp4O7LlJz/5PZYi5tUc/+58Kydp7h77vAO1t28gs9O9SAHuJVKr7gx8 Zx7ODAx0XaCCMKKHLPPtRMAzI+wVWHNEwsnjDME4PLaj8pcJz4whNKvwvxYVqLPVzZsW 9xlwZMe8Vn5P9BT7DBSoqtecortTR8n/so7HUHHVORKlxRi3K0mrltEp6NkgUx6yiA96 UkrLNJKh6hS5CtUE/FqWYpsTK8kWlL/3ZDvf0OTeUkPBWNho9S0b8lL5lW+F5tvdO+7d mNCMKZ2+ZJSwPpAKIYEKaCGI3NDQWc8MkRLMF5d7EscKowPz7MdbOY5jGgKhpFTs9qRe e6Tg== X-Gm-Message-State: ANoB5pmVJK6tIY3ofe/DrbIUWD1MN3kMOBrQGss5DyF1H7AMbOvS0wNc eQ5jzXJq2nIarwaRme+ZwGk= X-Received: by 2002:a63:3307:0:b0:477:8fed:80fa with SMTP id z7-20020a633307000000b004778fed80famr8898244pgz.96.1669226542349; Wed, 23 Nov 2022 10:02:22 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:22 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 08/15] perf stat: Use struct outstate in evlist__print_counters() Date: Wed, 23 Nov 2022 10:02:01 -0800 Message-Id: <20221123180208.2068936-9-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311054479132624?= X-GMAIL-MSGID: =?utf-8?q?1750311054479132624?= This is a preparation for the later cleanup. No functional changes intended. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index d2894a519d61..70aebf359e16 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -1372,13 +1372,16 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf bool metric_only = config->metric_only; int interval = config->interval; struct evsel *counter; - char buf[64], *prefix = NULL; + char buf[64]; + struct outstate os = { + .fh = config->output, + }; if (config->iostat_run) evlist->selected = evlist__first(evlist); if (interval) { - prefix = buf; + os.prefix = buf; prepare_interval(config, buf, sizeof(buf), ts); } @@ -1390,35 +1393,35 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf case AGGR_SOCKET: case AGGR_NODE: if (config->cgroup_list) - print_aggr_cgroup(config, evlist, prefix); + print_aggr_cgroup(config, evlist, os.prefix); else - print_aggr(config, evlist, prefix); + print_aggr(config, evlist, os.prefix); break; case AGGR_THREAD: case AGGR_GLOBAL: if (config->iostat_run) { - iostat_print_counters(evlist, config, ts, prefix = buf, + iostat_print_counters(evlist, config, ts, buf, print_counter); } else if (config->cgroup_list) { - print_cgroup_counter(config, evlist, prefix); + print_cgroup_counter(config, evlist, os.prefix); } else { - print_metric_begin(config, evlist, prefix, + print_metric_begin(config, evlist, os.prefix, /*aggr_idx=*/0, /*cgrp=*/NULL); evlist__for_each_entry(evlist, counter) { - print_counter(config, counter, prefix); + print_counter(config, counter, os.prefix); } print_metric_end(config); } break; case AGGR_NONE: if (metric_only) - print_no_aggr_metric(config, evlist, prefix); + print_no_aggr_metric(config, evlist, os.prefix); else { evlist__for_each_entry(evlist, counter) { if (counter->percore) - print_percore(config, counter, prefix); + print_percore(config, counter, os.prefix); else - print_counter(config, counter, prefix); + print_counter(config, counter, os.prefix); } } break; From patchwork Wed Nov 23 18:02:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25114 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942219wrr; Wed, 23 Nov 2022 10:05:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4POUK7DF4xLosLm6BFQeHm15JzRwJ0ibokkSdhlAbOrdpDAB1M/wcpbKxQR90tEMJnNIlQ X-Received: by 2002:a2e:8645:0:b0:279:7b24:641c with SMTP id i5-20020a2e8645000000b002797b24641cmr1158370ljj.344.1669226729437; Wed, 23 Nov 2022 10:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226729; cv=none; d=google.com; s=arc-20160816; b=QMbWfAaKW4X05nLKrpuT+MLTb591aB2yQjz4Zx+wehNKiwxBs9pJ5Ns4OE/+CPdYW5 MPGxMqCd5PjmvOAQEROYXyO4URvYRKG+L7mnbi2k2gjbgR3eYDTRkg5yXveifgUw+Sky aIMkzffG8sOZkdACW+H8PeFpWq1juEhKMpUgguV2wi0ip9J46wxw/v99KLNmrhbFKZ11 QRsuU5FAfXXr9XRoqcCk+OU+2buWnrhGIWvzw18OncEf2Wg5hsYPM1b4tLAfjN5p3zF+ UYT52BKmmyyDg2z/Yz2Tq2RnDnctx6y9gBReAvMY18zSLXy5Q2pNhRBeNfSFQqJnhlT0 popw== 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:sender :dkim-signature; bh=gVc+cia53gYtJDOA2aNz2UfR6QciW5fvjNYuKXlTXq4=; b=EkyO4+GitfB0IUrqTimyX+UeOFhRy/fCWq/1/xCgy2fhmz9sh2SSsu+3DJhzXsaHEC rfE5tM1mhtAC9GTtJgDteJNmZCqF69ZNGAbEZhiVcOALJussHAaGt4AFPln4Dic4aZNh x588fRtSMsbWQ7NH+RppPV0Cilq90mIrYw5D1JV0JESaYtVgNyZbwuHrzozhIp/zUtTT kJLJk3JWUDTctjhaPK64rl7Slxs9/pWbyyr2PwBeOl9LoDZ1k7VVwhiyR2g136UTfHn/ L/DqeZiHt03AzOIFSrnkysncb6NYyDezGuYLg2zX2vKFHMlY0Fzz9T/ADt8htHuwDdVm /BFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CVU4aHfH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m8-20020a056402430800b0045d27c0ba90si506256edc.577.2022.11.23.10.04.57; Wed, 23 Nov 2022 10:05:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CVU4aHfH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239357AbiKWSEG (ORCPT + 99 others); Wed, 23 Nov 2022 13:04:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239297AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AEA99371F; Wed, 23 Nov 2022 10:02:24 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id 136so17438688pga.1; Wed, 23 Nov 2022 10:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=gVc+cia53gYtJDOA2aNz2UfR6QciW5fvjNYuKXlTXq4=; b=CVU4aHfH1HjPYDPbgIAAAamraN9t24VDNKqRMivTDypso3RSvXpqA3MFB9n+mCtog5 pijZ5QdJRp87JBFrf3Ww6F0AdPdDUDr9XlrICyukYBt+leeGh+llI2CUk96OjdUXMfor muKQ3M3l7WA2qLfztGoxphabOD3XeIwhwndqtdgvK93WJrwC5R4WAeVCE8MT6ZUluWc/ j412ZWOTU4++8uCJgkV7FKFjzaHuQZHEHyCW36vBCALmh/QegKRzWY1wYPir0Lr7b5MK WqbqGelDFP6+pYFJCDsP8+s+253mgjQEUO76UnfzQiWU34DBE59z+YlfevnF/+mfcd5z DPDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=gVc+cia53gYtJDOA2aNz2UfR6QciW5fvjNYuKXlTXq4=; b=H/8OSAF0n64w2RWUN4zEXvGKSTiQSzU9iIJm4J7zK3El/ZHeUYq5rcNgxbMRIf/HUp ydVcMJbvbcV4+LlTkacWvVgQjpuvOtEwbX/84n54q7FqFTue5ZswpilmJiRc+Oheei5a BNmyo9ltaSoRck7+zNQ/GGu0Np4lsfA7BRJWof/Sg+iXDCDcHkFOwHuNxIp1xfSlFbIa uVWAFEqh0z09Gpk4vnUGgvbtHvce2U85K3f7rqMBu36xCNLiij89eY0xor+mMjag+c0z SmuQHrA22W+OrsmpU1YB9MpOxZWPLxx6mAR2AkgwWbI5z/lQnic2q5sAiYjYeSIFT4fZ BJVg== X-Gm-Message-State: ANoB5pmfOZzOaxc7TskGKJi9RfxLNqdPXJOuW5JlGmjYr8x5DiE3Ey1G X4QPIHHJ27PSYTqrHMfLw0h8zhRenZs= X-Received: by 2002:a65:638a:0:b0:46f:1261:ab62 with SMTP id h10-20020a65638a000000b0046f1261ab62mr10227094pgv.414.1669226543726; Wed, 23 Nov 2022 10:02:23 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:23 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 09/15] perf stat: Pass struct outstate to print_metric_begin() Date: Wed, 23 Nov 2022 10:02:02 -0800 Message-Id: <20221123180208.2068936-10-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311086958638814?= X-GMAIL-MSGID: =?utf-8?q?1750311086958638814?= It passes prefix and cgroup pointers but the outstate already has them. Let's pass the outstate pointer instead. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 50 +++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 70aebf359e16..3ed63061d6f8 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -843,8 +843,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, static void print_metric_begin(struct perf_stat_config *config, struct evlist *evlist, - const char *prefix, int aggr_idx, - struct cgroup *cgrp) + struct outstate *os, int aggr_idx) { struct perf_stat_aggr *aggr; struct aggr_cpu_id id; @@ -853,15 +852,15 @@ static void print_metric_begin(struct perf_stat_config *config, if (!config->metric_only) return; - if (prefix) - fprintf(config->output, "%s", prefix); + if (os->prefix) + fprintf(config->output, "%s", os->prefix); evsel = evlist__first(evlist); id = config->aggr_map->map[aggr_idx]; aggr = &evsel->stats->aggr[aggr_idx]; aggr_printout(config, evsel, id, aggr->nr); - print_cgroup(config, cgrp); + print_cgroup(config, os->cgrp); } static void print_metric_end(struct perf_stat_config *config) @@ -877,6 +876,9 @@ static void print_aggr(struct perf_stat_config *config, const char *prefix) { struct evsel *counter; + struct outstate os = { + .prefix = prefix, + }; int s; if (!config->aggr_map || !config->aggr_get_id) @@ -887,7 +889,7 @@ static void print_aggr(struct perf_stat_config *config, * Without each counter has its own line. */ for (s = 0; s < config->aggr_map->nr; s++) { - print_metric_begin(config, evlist, prefix, s, /*cgrp=*/NULL); + print_metric_begin(config, evlist, &os, s); evlist__for_each_entry(evlist, counter) { if (counter->merged_stat) @@ -904,26 +906,28 @@ static void print_aggr_cgroup(struct perf_stat_config *config, const char *prefix) { struct evsel *counter, *evsel; - struct cgroup *cgrp = NULL; + struct outstate os = { + .prefix = prefix, + }; int s; if (!config->aggr_map || !config->aggr_get_id) return; evlist__for_each_entry(evlist, evsel) { - if (cgrp == evsel->cgrp) + if (os.cgrp == evsel->cgrp) continue; - cgrp = evsel->cgrp; + os.cgrp = evsel->cgrp; for (s = 0; s < config->aggr_map->nr; s++) { - print_metric_begin(config, evlist, prefix, s, cgrp); + print_metric_begin(config, evlist, &os, s); evlist__for_each_entry(evlist, counter) { if (counter->merged_stat) continue; - if (counter->cgrp != cgrp) + if (counter->cgrp != os.cgrp) continue; print_counter_aggrdata(config, counter, s, prefix); @@ -956,6 +960,9 @@ static void print_no_aggr_metric(struct perf_stat_config *config, { int all_idx; struct perf_cpu cpu; + struct outstate os = { + .prefix = prefix, + }; perf_cpu_map__for_each_cpu(cpu, all_idx, evlist->core.user_requested_cpus) { struct evsel *counter; @@ -973,8 +980,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config, id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); if (first) { - print_metric_begin(config, evlist, prefix, - counter_idx, /*cgrp=*/NULL); + print_metric_begin(config, evlist, &os, counter_idx); first = false; } val = ps->aggr[counter_idx].counts.val; @@ -1347,22 +1353,23 @@ static void print_percore(struct perf_stat_config *config, static void print_cgroup_counter(struct perf_stat_config *config, struct evlist *evlist, const char *prefix) { - struct cgroup *cgrp = NULL; struct evsel *counter; + struct outstate os = { + .prefix = prefix, + }; evlist__for_each_entry(evlist, counter) { - if (cgrp != counter->cgrp) { - if (cgrp != NULL) + if (os.cgrp != counter->cgrp) { + if (os.cgrp != NULL) print_metric_end(config); - cgrp = counter->cgrp; - print_metric_begin(config, evlist, prefix, - /*aggr_idx=*/0, cgrp); + os.cgrp = counter->cgrp; + print_metric_begin(config, evlist, &os, /*aggr_idx=*/0); } print_counter(config, counter, prefix); } - if (cgrp) + if (os.cgrp) print_metric_end(config); } @@ -1405,8 +1412,7 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf } else if (config->cgroup_list) { print_cgroup_counter(config, evlist, os.prefix); } else { - print_metric_begin(config, evlist, os.prefix, - /*aggr_idx=*/0, /*cgrp=*/NULL); + print_metric_begin(config, evlist, &os, /*aggr_idx=*/0); evlist__for_each_entry(evlist, counter) { print_counter(config, counter, os.prefix); } From patchwork Wed Nov 23 18:02:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25118 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2942361wrr; Wed, 23 Nov 2022 10:05:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ywFzNVXeIBtJZZ3pYCx6PqD8bPc4HSOtMz+rXEds0S7pxPDyLnKlbGvZLdkxko1KIzZdX X-Received: by 2002:a17:907:1a53:b0:7b2:b15e:86e6 with SMTP id mf19-20020a1709071a5300b007b2b15e86e6mr12437804ejc.410.1669226741291; Wed, 23 Nov 2022 10:05:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226741; cv=none; d=google.com; s=arc-20160816; b=EflruMohdXjdVqBxIAdLQVspkQPp5xEpTFglblXkP7U8h4qA3TQAI4WWjEk+fzY6O+ FRMyjZnIl7Ey/v5r4Ttvx64ycuDwyQnJ6L6PMYPHKsBl5MX4Jav2vSnRJ+dvjfNLZI2Z YMwDoe/+/h/qhzCd7UpovmNIojmp/KrZbBy/GQq+rQJN+7j6FpR1xrh/kIFcqNneDJcd rXJT5d6uNHqsSf/B84iGoQwU6LpRqdBSzai71VwqQmXyPRYOXIVeX+MMN+Pem+SXQhC+ H6uBANIEb5SGhFtaKKhncKDLoWAHjOQeRHF0DMViuyzVFfVLNeynAdYxVjRMFGt0ZCAt wnyA== 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:sender :dkim-signature; bh=Z7/IN2ZK+T3PH7QZiJw53n5Bc5bJOMsHQZPX+sQ32KA=; b=leuZ26UlgvvJyvcZCI4MgWQG1jUvSD18Ud917h7DY+gWBFneSY/oLVVy4ScUM4USpx n3su1WmnFFrweT/qPb+1lGtWKXpJhcI19vuYGnWpTKb2QabOfpovEudPlCTw4/W8urp/ +Zy2I3cfrE2ndzKNOI+EexW6nBPh309Q7ZBjZ1zrcfPWDDEC3Z4+2DE/wnHBCx3nYVCp 0qjo5M6PQ3XG4B9Zd/Jt+GhqlOHS0fJ3PkXFtfmrtSoPJyPagTVi/FWawksbxc/9BopC tPHzAZWRJQuV87GyJOsL1IYfdycuiTJ/rRNjCCF7jPxcEYqsAivecJcWwKjv9fKO315E 1QkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="H2/E7pDe"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn19-20020a1709070d1300b007313312730esi287622ejc.85.2022.11.23.10.05.06; Wed, 23 Nov 2022 10:05:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="H2/E7pDe"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239520AbiKWSET (ORCPT + 99 others); Wed, 23 Nov 2022 13:04:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239404AbiKWSC3 (ORCPT ); Wed, 23 Nov 2022 13:02:29 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B297F97AAD; Wed, 23 Nov 2022 10:02:25 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id j12so17327390plj.5; Wed, 23 Nov 2022 10:02:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Z7/IN2ZK+T3PH7QZiJw53n5Bc5bJOMsHQZPX+sQ32KA=; b=H2/E7pDeLeUnIttCMj54h68ZJtX3hF4JwGs4ltH0jeDgik+tJS3Pyxkv27c6oryxsX hCmA/MaEt37OC9aDHxYzGsVoUvWXyEawiVY8GV7kQH9vscA9liTMKP86MeXL2X/L+uz6 hsQaAdi3bPNq4woxvUBy56trLk//HSuI8wPlQrg0AOn8cfCs60fNoaQHaua/hohGyBu0 29HultPMnuRnRPleLeI1f5pCjqsV+PfMqBl5lt2nqN2YGK3inHnyR0SQMDuTHTqHmVKM 1tdadkml2r1ECbpOl0182H2WJrg83s07YCYxVOCFL2lnu96l2UQIRn8TMuVJCSOnwCsM XXKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z7/IN2ZK+T3PH7QZiJw53n5Bc5bJOMsHQZPX+sQ32KA=; b=kwsr4zL/84A8RIVB/DrqnTpgTSklh2H3MI59/RGs9kuf9bEM8bL/GaljH6xSd5sVWS 6y94Hs0uIA97GpVwoSxGifdf8LBtaJGvxXviMeDdo30LCeg5IRosLTyXgMmEzGTN+g4F ik+icTsl5cmqhjeIvHEEAIS1OT+PttAgbLg7rLg6MTdldb2bwn4q2BelQjF3vfAt8sQR Be/QRwT9/kgZ0XopNyEo0ic3TbBDOa6CMJ8qxFXai+EOGYBJauKgrkO+JSSP5HNiM57G qlU8AGcSj2VcDTd9bcrn1lEpRCWZmal4j9W+N63ttDCt6+D8/x59K5oO5qWjVl/l4PQt tNsg== X-Gm-Message-State: ANoB5pnzG9iZB9X7tS8qJVlTxyXGqgyJt/Q1gCwEVjhlGeh8bpTjtpw1 o+jJKpmezoVzNuE8JNcDQS0= X-Received: by 2002:a17:902:b611:b0:189:1c94:99c3 with SMTP id b17-20020a170902b61100b001891c9499c3mr9988999pls.140.1669226545113; Wed, 23 Nov 2022 10:02:25 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:24 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 10/15] perf stat: Pass struct outstate to printout() Date: Wed, 23 Nov 2022 10:02:03 -0800 Message-Id: <20221123180208.2068936-11-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311099702174478?= X-GMAIL-MSGID: =?utf-8?q?1750311099702174478?= The printout() takes a lot of arguments and sets an outstate with the value. Instead, we can fill the outstate first and then pass it to reduce the number of arguments. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 38 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 3ed63061d6f8..dd190f71e933 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -673,22 +673,15 @@ static bool is_mixed_hw_group(struct evsel *counter) return false; } -static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int nr, - struct evsel *counter, double uval, - const char *prefix, u64 run, u64 ena, double noise, +static void printout(struct perf_stat_config *config, struct outstate *os, + double uval, u64 run, u64 ena, double noise, struct runtime_stat *st, int map_idx) { struct perf_stat_output_ctx out; - struct outstate os = { - .fh = config->output, - .prefix = prefix ? prefix : "", - .id = id, - .nr = nr, - .evsel = counter, - }; print_metric_t pm; new_line_t nl; bool ok = true; + struct evsel *counter = os->evsel; if (config->csv_output) { static const int aggr_fields[AGGR_MAX] = { @@ -704,7 +697,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int pm = config->metric_only ? print_metric_only_csv : print_metric_csv; nl = config->metric_only ? new_line_metric : new_line_csv; - os.nfields = 3 + aggr_fields[config->aggr_mode] + (counter->cgrp ? 1 : 0); + os->nfields = 3 + aggr_fields[config->aggr_mode] + (counter->cgrp ? 1 : 0); } else if (config->json_output) { pm = config->metric_only ? print_metric_only_json : print_metric_json; nl = config->metric_only ? new_line_metric : new_line_json; @@ -715,7 +708,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int if (run == 0 || ena == 0 || counter->counts->scaled == -1) { if (config->metric_only) { - pm(config, &os, NULL, "", "", 0); + pm(config, os, NULL, "", "", 0); return; } @@ -732,11 +725,11 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int out.print_metric = pm; out.new_line = nl; - out.ctx = &os; + out.ctx = os; out.force_header = false; if (!config->metric_only) { - abs_printout(config, id, nr, counter, uval, ok); + abs_printout(config, os->id, os->nr, counter, uval, ok); print_noise(config, counter, noise, /*before_metric=*/true); print_running(config, run, ena, /*before_metric=*/true); @@ -814,6 +807,13 @@ static void print_counter_aggrdata(struct perf_stat_config *config, struct aggr_cpu_id id = config->aggr_map->map[s]; double avg = aggr->counts.val; bool metric_only = config->metric_only; + struct outstate os = { + .fh = config->output, + .prefix = prefix ? prefix : "", + .id = id, + .nr = aggr->nr, + .evsel = counter, + }; if (counter->supported && aggr->nr == 0) return; @@ -834,8 +834,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, uval = val * counter->scale; - printout(config, id, aggr->nr, counter, uval, - prefix, run, ena, avg, &rt_stat, s); + printout(config, &os, uval, run, ena, avg, &rt_stat, s); if (!metric_only) fputc('\n', output); @@ -971,14 +970,14 @@ static void print_no_aggr_metric(struct perf_stat_config *config, evlist__for_each_entry(evlist, counter) { u64 ena, run, val; double uval; - struct aggr_cpu_id id; struct perf_stat_evsel *ps = counter->stats; int counter_idx = perf_cpu_map__idx(evsel__cpus(counter), cpu); if (counter_idx < 0) continue; - id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); + os.evsel = counter; + os.id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); if (first) { print_metric_begin(config, evlist, &os, counter_idx); first = false; @@ -988,8 +987,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config, run = ps->aggr[counter_idx].counts.run; uval = val * counter->scale; - printout(config, id, 0, counter, uval, prefix, - run, ena, 1.0, &rt_stat, counter_idx); + printout(config, &os, uval, run, ena, 1.0, &rt_stat, counter_idx); } if (!first) print_metric_end(config); From patchwork Wed Nov 23 18:02:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25127 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2943516wrr; Wed, 23 Nov 2022 10:07:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf661eqxyjC/CatT1jRtC/WLSYb9OaZIbuXA5k5pUSDO3XspMCEof5PaPsRWKnNIT31Ea99M X-Received: by 2002:a05:6402:104b:b0:461:7d1f:1a7b with SMTP id e11-20020a056402104b00b004617d1f1a7bmr9098808edu.400.1669226853317; Wed, 23 Nov 2022 10:07:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226853; cv=none; d=google.com; s=arc-20160816; b=d3YMOpX/J/KgqtC33Pyff57L5cgDPnm7/xYCFxf5niW4Xt1lSp5cpewhuERz/cW5JM KzU7fQd3TRMZ6zJN6gmVq3CNlDOi9rL49FNkQZJBBLeKRvZ2imVTx1xnBMqy14YcQLIo u4+4MpJvqCWcy97C1p6d8JLnn2ceROf1ZF+o75JaBElfg18ittr1q8WAuX2F2KN3Rh5G GTeVjmotxF1i3iK/2kPVx+DecwrzMJYGA+ndDJW/BqUgyFJo9YJYa+JtzHuaA0DQLVon znuEoTu6O+DpUG0XRxPFIeVL6lz8812tdPOsv0C7yJnHL/2TU/uQ7SmyHptCl1uVELUb 6saQ== 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:sender :dkim-signature; bh=i58ch+3MvSovbxgHuPI+VzjhA43rzCO6VyOVuXc7lHM=; b=VssOEhWG5Y1mIWIXmywnL+yEV7UvohtpgDq37769UYF3G9BlnUXd4blxlAtH+wvUlt yCDUuDRmQpASMTjv+ZtHRcficOeKo7HdMwyZxMGe3/OumynnE8CmV9GCUtVDZRBse9CL IxAQ3NrvwHUPpX4vGxQa7Fd9Di8VunvLZ6zR35IrCZNShqv4h6wrIGFSH5MxOKzy58uH WitLOk+h2PoydqEZBxLomO+NnsSv8fuMTsk7GMh2AvNrvFiP3dKZJxt6rrAt43yFDQhF b2OiWWF9vUErco66XEl4scdIITnKCslp9OWd3wVmxKCaMUh2k7u/BcPO3A6CcQZbnG65 nh8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="FfVOR/9W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a056402440700b0045d3e06e4d5si16329589eda.389.2022.11.23.10.07.07; Wed, 23 Nov 2022 10:07:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="FfVOR/9W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238957AbiKWSE4 (ORCPT + 99 others); Wed, 23 Nov 2022 13:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239439AbiKWSCi (ORCPT ); Wed, 23 Nov 2022 13:02:38 -0500 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82BF45FA6; Wed, 23 Nov 2022 10:02:27 -0800 (PST) Received: by mail-pl1-x629.google.com with SMTP id d20so17310802plr.10; Wed, 23 Nov 2022 10:02:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=i58ch+3MvSovbxgHuPI+VzjhA43rzCO6VyOVuXc7lHM=; b=FfVOR/9WaGv3WxhuuUQHJxjW/D1aSEBu4+EtTJgE50WZYia6oDCf4kd0Kz3jliWGnq 3DzdvlZqj7jehx/mNc6CNbouCeQOFRw+taifsc0WfwnYLdH6gplhgNpOTDCfk1d9xmXI 6qORHso09UzO2W+VoHwTKpurA9d07uLIdKgdn8VaE0DV+N2Pdo3sd6QrigCfPt+YXMUL jX7esb+h0WGEisVeZjCuykJsodrhvOpP/tBopASz11Ey2tVEt+h5SKOtgbkD4HIP9wzT Ehxd7B7EUtqBMi1PAZCZOV5aLJFnfOE2QEMf7j0E6vGK2scDNC9VWRvE6KMa88+Iy4Bd Bw+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=i58ch+3MvSovbxgHuPI+VzjhA43rzCO6VyOVuXc7lHM=; b=NSqa1wK+Mql7VczFQlf4Ylpjfq+sz34lwL61c7Epf/zJ0aeZYENDjsQAKnyvolLsvW An4+OB9/MbJh/Swg4PgvwjIoNsRKB9bVGgbRqMFnFSdRpyP4B6g8XbtixeeV14Gb2Fon IkrHWAtSrjn2f+d5qlm+AfrTAsg5ZWgHp7QQMUMVWoBXODiixJnARlOCM/09qp7z7JFG 0z5SV5NZ3Fl7CB3EJT6wxQEgi5SFKaDtSoaFL576GFLPEVWKHVwzfTtXhUzbjvs66c9n /PVzPUpmYquLQNN2BVwjbe7Ajam9dqwnJTRr5ISqw3M3bO95wJnCiSLPLuDGs9n0q3F7 orSg== X-Gm-Message-State: ANoB5pmfTCqXmmC72McCtKNRCVcJih45y3BgyVDCEfBZowZ4L9huaGXF x+LgQ/AEv54djdpfyYVwMa0= X-Received: by 2002:a17:902:9686:b0:189:24b3:c54 with SMTP id n6-20020a170902968600b0018924b30c54mr9943652plp.96.1669226546627; Wed, 23 Nov 2022 10:02:26 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:26 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 11/15] perf stat: Do not pass runtime_stat to printout() Date: Wed, 23 Nov 2022 10:02:04 -0800 Message-Id: <20221123180208.2068936-12-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311216823374913?= X-GMAIL-MSGID: =?utf-8?q?1750311216823374913?= It always passes a pointer to rt_stat as it's the only one. Let's not pass it and directly refer it in the printout(). Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index dd190f71e933..cdf4ca7f6e3a 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -674,8 +674,7 @@ static bool is_mixed_hw_group(struct evsel *counter) } static void printout(struct perf_stat_config *config, struct outstate *os, - double uval, u64 run, u64 ena, double noise, - struct runtime_stat *st, int map_idx) + double uval, u64 run, u64 ena, double noise, int map_idx) { struct perf_stat_output_ctx out; print_metric_t pm; @@ -737,7 +736,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os, if (ok) { perf_stat__print_shadow_stats(config, counter, uval, map_idx, - &out, &config->metric_events, st); + &out, &config->metric_events, &rt_stat); } else { pm(config, &os, /*color=*/NULL, /*format=*/NULL, /*unit=*/"", /*val=*/0); } @@ -834,7 +833,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, uval = val * counter->scale; - printout(config, &os, uval, run, ena, avg, &rt_stat, s); + printout(config, &os, uval, run, ena, avg, s); if (!metric_only) fputc('\n', output); @@ -987,7 +986,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config, run = ps->aggr[counter_idx].counts.run; uval = val * counter->scale; - printout(config, &os, uval, run, ena, 1.0, &rt_stat, counter_idx); + printout(config, &os, uval, run, ena, 1.0, counter_idx); } if (!first) print_metric_end(config); From patchwork Wed Nov 23 18:02:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25128 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2943581wrr; Wed, 23 Nov 2022 10:07:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PeppWtuVh2N1Pf20dht4zBeLvYd2ueh8Y9kGzlP023IPjkd2va83ZbvUdl+Ct4NzOCS51 X-Received: by 2002:a05:6402:14ce:b0:469:9395:beef with SMTP id f14-20020a05640214ce00b004699395beefmr14621759edx.316.1669226859114; Wed, 23 Nov 2022 10:07:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669226859; cv=none; d=google.com; s=arc-20160816; b=sdvkCw1i/vzwSpZo8bs1A9IjNhwh74vyJrpfaljXGLOUIm2eN+3pDICKpSX+/dWRUm HWobK/xVQNgQVXgmkVNgEI/l1YOXUfMY3kTVGgGM1I53OMypMPcbpM8l1U9LyfeObZLM 2eDGj4lSQY0QMNX0WSpz+lwPLVrnyzWYzSQILAHTE0Qs4wMKF5BENzD+xLuWtsY1NWTO /T1e8OsUMXmOc7yjE22lxXJ1Vshrk2+21oozVmdnZlVTnXAElxmoA7EOFyN8cp19jSzz so6dw6Hb7FP8ZRK8eD7t4AACDGeuzUCht/nR//CrQoPLSIVAN7stiPRsCZLCUgKfzDFk /83A== 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:sender :dkim-signature; bh=wLOHc0kNNvswzQicgM/c9gpdZABR952YZCIn6DOjwMU=; b=ooDkQQ8XRkYGCfWTQSTCpz3VR2Ac/2QRvaTnOXwnKd2HRGBPikMDu/Gnjd2x5NsTCf qEL4t2w74lk9hw+Kkx1kY4t4Zdu+SneSVIoqNgh0gVOfbzykLvAZJKB+K8jwIRLyERDq Sm2NuZVVlANQ7rU8bpM9yuqrWw9tIFwgW7+2IILRYERvppYXONYKM+SRCBrvcXpGKx71 bHvD5Pq91srojNb7sMcA1bBC6IkTEsEN4qk7AiF4gpXHFK2FcF6/BwWFu7eKDQQz6vfc 08+4ANWF3cEJ34dbHUcbzt0IVmpkXyUfNIPCLwpef4QLfiYwLnY64c1IzN1aGIkmx32U yOzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jfron7PH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020a05640211cb00b0046627848e32si250829edw.634.2022.11.23.10.07.12; Wed, 23 Nov 2022 10:07:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Jfron7PH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239606AbiKWSE7 (ORCPT + 99 others); Wed, 23 Nov 2022 13:04:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239445AbiKWSCk (ORCPT ); Wed, 23 Nov 2022 13:02:40 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5D75FC0; Wed, 23 Nov 2022 10:02:28 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id 62so17348431pgb.13; Wed, 23 Nov 2022 10:02:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=wLOHc0kNNvswzQicgM/c9gpdZABR952YZCIn6DOjwMU=; b=Jfron7PHVA8BP+OdFqiGy6CZW9na10jyamInmtDZkotnRkYXaMR5X1Z+Nbsx0n33bn 8IbRAAfld4Ao8N3ckQfQkJTVwXZR0JAVHkrtOLCxOYwnPrL8ELyNvLwh14TqWnkPolW1 FQEkWKiH3AXW7KBhCDAkGQnOLWYqN+9gxnIpQq1DXGbgxYvRyiV/G3SKc9onA7M5I0q0 s+F43t8oR95FFizfdJj8zv6alqquuH8fbY2M+bU89xjUowaoPibjHD0iU7ujmFvzolYd gJliQc08iD1I5Y//IRSI0OxiBzFU9tEn0s5kqJOVNKtzjS6VXHkvLFsl6sy6ZCTBhP6I Apjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wLOHc0kNNvswzQicgM/c9gpdZABR952YZCIn6DOjwMU=; b=TjHmaHbk5JtwiTD0wZrEGQ/ZrumJoVgmMS1fYZ9Xhp4QF8isEGnqBUHzAXC3JOYfWZ GCeSh47voAig+03ojOrGIN8HPtL8gyCcRFT8y2JIGmNQl0Tsdtxy8wPS59EqEMCD0fSN qcKk4QaZeoGILf/N5IJOEF5ioZd21fVQa+xSwYy47HJTSEQfKbXTPOJPl4H3RusqSWac MSB4zSid6UIYLhN5mksbfx0I51pFL+8ZtTpFeK32QrLuhmAWI6LgroYJe6FKW3/fRv/e VV+Cop2poaPTcJ9jPDRDdc5YeKzUk7F0aR/ojOtFt+WeSV5JQxX3ijUCxJndCHyxPS0d iVEw== X-Gm-Message-State: ANoB5pnENt23Cwrz1hSmMYk3OknKHZR6oSByhswi1uavHtPgIhGdSSIP A3ocKwOjr/kaq72OK69KeM67gw5d9XI= X-Received: by 2002:a65:60c7:0:b0:476:aad3:90e2 with SMTP id r7-20020a6560c7000000b00476aad390e2mr8461159pgv.217.1669226548002; Wed, 23 Nov 2022 10:02:28 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:27 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 12/15] perf stat: Pass through struct outstate Date: Wed, 23 Nov 2022 10:02:05 -0800 Message-Id: <20221123180208.2068936-13-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311222929961538?= X-GMAIL-MSGID: =?utf-8?q?1750311222929961538?= Now most of the print functions take a pointer to the struct outstate. We have one in the evlist__print_counters() and pass it through the child functions. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/arch/x86/util/iostat.c | 4 +- tools/perf/util/iostat.c | 3 +- tools/perf/util/iostat.h | 4 +- tools/perf/util/stat-display.c | 102 +++++++++++++----------------- 4 files changed, 50 insertions(+), 63 deletions(-) diff --git a/tools/perf/arch/x86/util/iostat.c b/tools/perf/arch/x86/util/iostat.c index 404de795ec0b..7eb0a7b00b95 100644 --- a/tools/perf/arch/x86/util/iostat.c +++ b/tools/perf/arch/x86/util/iostat.c @@ -449,7 +449,7 @@ void iostat_print_metric(struct perf_stat_config *config, struct evsel *evsel, void iostat_print_counters(struct evlist *evlist, struct perf_stat_config *config, struct timespec *ts, - char *prefix, iostat_print_counter_t print_cnt_cb) + char *prefix, iostat_print_counter_t print_cnt_cb, void *arg) { void *perf_device = NULL; struct evsel *counter = evlist__first(evlist); @@ -464,7 +464,7 @@ void iostat_print_counters(struct evlist *evlist, iostat_prefix(evlist, config, prefix, ts); fprintf(config->output, "\n%s", prefix); } - print_cnt_cb(config, counter, prefix); + print_cnt_cb(config, counter, arg); } fputc('\n', config->output); } diff --git a/tools/perf/util/iostat.c b/tools/perf/util/iostat.c index 57dd49da28fe..b770bd473af7 100644 --- a/tools/perf/util/iostat.c +++ b/tools/perf/util/iostat.c @@ -48,6 +48,7 @@ __weak void iostat_print_counters(struct evlist *evlist __maybe_unused, struct perf_stat_config *config __maybe_unused, struct timespec *ts __maybe_unused, char *prefix __maybe_unused, - iostat_print_counter_t print_cnt_cb __maybe_unused) + iostat_print_counter_t print_cnt_cb __maybe_unused, + void *arg __maybe_unused) { } diff --git a/tools/perf/util/iostat.h b/tools/perf/util/iostat.h index c22688f87cb2..a4e7299c5c2f 100644 --- a/tools/perf/util/iostat.h +++ b/tools/perf/util/iostat.h @@ -28,7 +28,7 @@ enum iostat_mode_t { extern enum iostat_mode_t iostat_mode; -typedef void (*iostat_print_counter_t)(struct perf_stat_config *, struct evsel *, const char *); +typedef void (*iostat_print_counter_t)(struct perf_stat_config *, struct evsel *, void *); int iostat_prepare(struct evlist *evlist, struct perf_stat_config *config); int iostat_parse(const struct option *opt, const char *str, @@ -42,6 +42,6 @@ void iostat_print_metric(struct perf_stat_config *config, struct evsel *evsel, struct perf_stat_output_ctx *out); void iostat_print_counters(struct evlist *evlist, struct perf_stat_config *config, struct timespec *ts, - char *prefix, iostat_print_counter_t print_cnt_cb); + char *prefix, iostat_print_counter_t print_cnt_cb, void *arg); #endif /* _IOSTAT_H */ diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index cdf4ca7f6e3a..335627e8542d 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -796,7 +796,7 @@ static void uniquify_counter(struct perf_stat_config *config, struct evsel *coun static void print_counter_aggrdata(struct perf_stat_config *config, struct evsel *counter, int s, - const char *prefix) + struct outstate *os) { FILE *output = config->output; u64 ena, run, val; @@ -806,13 +806,10 @@ static void print_counter_aggrdata(struct perf_stat_config *config, struct aggr_cpu_id id = config->aggr_map->map[s]; double avg = aggr->counts.val; bool metric_only = config->metric_only; - struct outstate os = { - .fh = config->output, - .prefix = prefix ? prefix : "", - .id = id, - .nr = aggr->nr, - .evsel = counter, - }; + + os->id = id; + os->nr = aggr->nr; + os->evsel = counter; if (counter->supported && aggr->nr == 0) return; @@ -824,8 +821,8 @@ static void print_counter_aggrdata(struct perf_stat_config *config, run = aggr->counts.run; if (!metric_only) { - if (prefix) - fprintf(output, "%s", prefix); + if (os->prefix) + fprintf(output, "%s", os->prefix); else if (config->summary && config->csv_output && !config->no_csv_summary && !config->interval) fprintf(output, "%s%s", "summary", config->csv_sep); @@ -833,7 +830,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, uval = val * counter->scale; - printout(config, &os, uval, run, ena, avg, s); + printout(config, os, uval, run, ena, avg, s); if (!metric_only) fputc('\n', output); @@ -871,12 +868,9 @@ static void print_metric_end(struct perf_stat_config *config) static void print_aggr(struct perf_stat_config *config, struct evlist *evlist, - const char *prefix) + struct outstate *os) { struct evsel *counter; - struct outstate os = { - .prefix = prefix, - }; int s; if (!config->aggr_map || !config->aggr_get_id) @@ -887,13 +881,13 @@ static void print_aggr(struct perf_stat_config *config, * Without each counter has its own line. */ for (s = 0; s < config->aggr_map->nr; s++) { - print_metric_begin(config, evlist, &os, s); + print_metric_begin(config, evlist, os, s); evlist__for_each_entry(evlist, counter) { if (counter->merged_stat) continue; - print_counter_aggrdata(config, counter, s, prefix); + print_counter_aggrdata(config, counter, s, os); } print_metric_end(config); } @@ -901,34 +895,31 @@ static void print_aggr(struct perf_stat_config *config, static void print_aggr_cgroup(struct perf_stat_config *config, struct evlist *evlist, - const char *prefix) + struct outstate *os) { struct evsel *counter, *evsel; - struct outstate os = { - .prefix = prefix, - }; int s; if (!config->aggr_map || !config->aggr_get_id) return; evlist__for_each_entry(evlist, evsel) { - if (os.cgrp == evsel->cgrp) + if (os->cgrp == evsel->cgrp) continue; - os.cgrp = evsel->cgrp; + os->cgrp = evsel->cgrp; for (s = 0; s < config->aggr_map->nr; s++) { - print_metric_begin(config, evlist, &os, s); + print_metric_begin(config, evlist, os, s); evlist__for_each_entry(evlist, counter) { if (counter->merged_stat) continue; - if (counter->cgrp != os.cgrp) + if (counter->cgrp != os->cgrp) continue; - print_counter_aggrdata(config, counter, s, prefix); + print_counter_aggrdata(config, counter, s, os); } print_metric_end(config); } @@ -936,7 +927,7 @@ static void print_aggr_cgroup(struct perf_stat_config *config, } static void print_counter(struct perf_stat_config *config, - struct evsel *counter, const char *prefix) + struct evsel *counter, struct outstate *os) { int s; @@ -948,19 +939,16 @@ static void print_counter(struct perf_stat_config *config, return; for (s = 0; s < config->aggr_map->nr; s++) { - print_counter_aggrdata(config, counter, s, prefix); + print_counter_aggrdata(config, counter, s, os); } } static void print_no_aggr_metric(struct perf_stat_config *config, struct evlist *evlist, - const char *prefix) + struct outstate *os) { int all_idx; struct perf_cpu cpu; - struct outstate os = { - .prefix = prefix, - }; perf_cpu_map__for_each_cpu(cpu, all_idx, evlist->core.user_requested_cpus) { struct evsel *counter; @@ -975,10 +963,10 @@ static void print_no_aggr_metric(struct perf_stat_config *config, if (counter_idx < 0) continue; - os.evsel = counter; - os.id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); + os->evsel = counter; + os->id = aggr_cpu_id__cpu(cpu, /*data=*/NULL); if (first) { - print_metric_begin(config, evlist, &os, counter_idx); + print_metric_begin(config, evlist, os, counter_idx); first = false; } val = ps->aggr[counter_idx].counts.val; @@ -986,7 +974,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config, run = ps->aggr[counter_idx].counts.run; uval = val * counter->scale; - printout(config, &os, uval, run, ena, 1.0, counter_idx); + printout(config, os, uval, run, ena, 1.0, counter_idx); } if (!first) print_metric_end(config); @@ -1304,7 +1292,7 @@ static void print_footer(struct perf_stat_config *config) } static void print_percore(struct perf_stat_config *config, - struct evsel *counter, const char *prefix) + struct evsel *counter, struct outstate *os) { bool metric_only = config->metric_only; FILE *output = config->output; @@ -1315,7 +1303,7 @@ static void print_percore(struct perf_stat_config *config, return; if (config->percore_show_thread) - return print_counter(config, counter, prefix); + return print_counter(config, counter, os); core_map = cpu_aggr_map__empty_new(config->aggr_map->nr); if (core_map == NULL) { @@ -1337,7 +1325,7 @@ static void print_percore(struct perf_stat_config *config, if (found) continue; - print_counter_aggrdata(config, counter, s, prefix); + print_counter_aggrdata(config, counter, s, os); core_map->map[c++] = core_id; } @@ -1348,30 +1336,28 @@ static void print_percore(struct perf_stat_config *config, } static void print_cgroup_counter(struct perf_stat_config *config, struct evlist *evlist, - const char *prefix) + struct outstate *os) { struct evsel *counter; - struct outstate os = { - .prefix = prefix, - }; evlist__for_each_entry(evlist, counter) { - if (os.cgrp != counter->cgrp) { - if (os.cgrp != NULL) + if (os->cgrp != counter->cgrp) { + if (os->cgrp != NULL) print_metric_end(config); - os.cgrp = counter->cgrp; - print_metric_begin(config, evlist, &os, /*aggr_idx=*/0); + os->cgrp = counter->cgrp; + print_metric_begin(config, evlist, os, /*aggr_idx=*/0); } - print_counter(config, counter, prefix); + print_counter(config, counter, os); } - if (os.cgrp) + if (os->cgrp) print_metric_end(config); } void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *config, - struct target *_target, struct timespec *ts, int argc, const char **argv) + struct target *_target, struct timespec *ts, + int argc, const char **argv) { bool metric_only = config->metric_only; int interval = config->interval; @@ -1397,34 +1383,34 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf case AGGR_SOCKET: case AGGR_NODE: if (config->cgroup_list) - print_aggr_cgroup(config, evlist, os.prefix); + print_aggr_cgroup(config, evlist, &os); else - print_aggr(config, evlist, os.prefix); + print_aggr(config, evlist, &os); break; case AGGR_THREAD: case AGGR_GLOBAL: if (config->iostat_run) { iostat_print_counters(evlist, config, ts, buf, - print_counter); + (iostat_print_counter_t)print_counter, &os); } else if (config->cgroup_list) { - print_cgroup_counter(config, evlist, os.prefix); + print_cgroup_counter(config, evlist, &os); } else { print_metric_begin(config, evlist, &os, /*aggr_idx=*/0); evlist__for_each_entry(evlist, counter) { - print_counter(config, counter, os.prefix); + print_counter(config, counter, &os); } print_metric_end(config); } break; case AGGR_NONE: if (metric_only) - print_no_aggr_metric(config, evlist, os.prefix); + print_no_aggr_metric(config, evlist, &os); else { evlist__for_each_entry(evlist, counter) { if (counter->percore) - print_percore(config, counter, os.prefix); + print_percore(config, counter, &os); else - print_counter(config, counter, os.prefix); + print_counter(config, counter, &os); } } break; From patchwork Wed Nov 23 18:02:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2947108wrr; Wed, 23 Nov 2022 10:13:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf5WXcfhJhxvhwhCcDO00lC1tbDE8pSAHIK3zNLPAWOUl4mGPEgKRu4bqixoXVRAmNc5+g7z X-Received: by 2002:a17:902:b613:b0:188:f570:7bd6 with SMTP id b19-20020a170902b61300b00188f5707bd6mr9936336pls.97.1669227229196; Wed, 23 Nov 2022 10:13:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669227229; cv=none; d=google.com; s=arc-20160816; b=wdmUePmW7CR9qvTuDkdxYxuXNMWQdzSHW3ODsW8ICY+zmxnb3iV4n9beeFbrc9h7MO tFbhhiVcGMQM2sI/KcyeNNxuJJMPEsstJzdgYmNBKHooCOz+n0r0Q7uBGHIuP+sJDjX0 zsNK5j9zyE/N1P99WcsYa2JkYg07/LKTlxz1METv41+vWzp8oSXxO9O53huEj6L9uSot oB0vo2nIM4SteJ5mw0QSBddG09+pxj7USyR//kkeYQ3mzJ9XiihLF1+OUZ4FGjGqBYxn cIUxopTv7yLvsh4FkTnOVKIOE0SsyarYj30oYymOXg7aPTLbl5Dyn9ZQpyYFZm8F+EDO 2SfQ== 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:sender :dkim-signature; bh=PTDdto5/eoDl85LlqvUb3DgMBRg+irZ3fXZplmAmP/4=; b=aA5aKNESSYjgWj98Ni4ELq2qZBMJaqC1RkSSSG4+tMJcWFO7TnYwd+RAlZa9sbEkMs C82rMo+Cls8r/qLINYms04j0X27kI2MO+khk2C18h4kxh8k66Jbza5mj5yc4lVEkxaIQ K+d/eDwOpU02Tr+uZ4mh6QMejztvOF33UEL863JZ/PbWGyY8GJasM2DrnuUg/AUXnLs6 TlRV1+gUho6H8DHEZPFjtdfrFyXFHtd4VWd0hKDEsvA5w1Lns6y21pxl8lcS5CzM5Eno GgxrOjQn0jlbTQIjzamgyCt1TPFM9A1e/P6Jrisa+Uwxsj79+PcdC85hV+4DcQPumCQ6 5Guw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RLxVPfnd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd32-20020a056a0027a000b005739d652a89si223535pfb.223.2022.11.23.10.13.36; Wed, 23 Nov 2022 10:13:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RLxVPfnd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239625AbiKWSFN (ORCPT + 99 others); Wed, 23 Nov 2022 13:05:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239479AbiKWSDE (ORCPT ); Wed, 23 Nov 2022 13:03:04 -0500 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 906AD642F; Wed, 23 Nov 2022 10:02:30 -0800 (PST) Received: by mail-pf1-x429.google.com with SMTP id 9so1289771pfx.11; Wed, 23 Nov 2022 10:02:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=PTDdto5/eoDl85LlqvUb3DgMBRg+irZ3fXZplmAmP/4=; b=RLxVPfndBEBdljQ6gVY3mhbDKukmqmEcOIg4Q+pjS4LHRqm5wBHtggVHo/n7bNsAE/ +g48UoG0UvFjeyogFsfA5/t8p4wCKlFzmWxYA+rTPmNEQZpb+WGt8G1psMGz9/Io9ALz qgPGUVI0NqMogwZ5iIO0q2IYifR1RHfGZquKge1jyxcrOLAGIml/fyk8YSm0FJg6JEe7 IsgJX9P3N6HzH0Rozj0pMW0B8aI5IiHvfhkgNH9cWXx3tmtb6xYVbIjYkg30I8n+3ac4 jOftQ1EAHPacjPSuPp9ao2K+Aj9+IxbuYBCBWStrxRm9vRdcIFNWTqIMVp0MmmtYONg4 wsMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PTDdto5/eoDl85LlqvUb3DgMBRg+irZ3fXZplmAmP/4=; b=ysaEIIV4OlKQ3O9urR15CSzewfdUbMyvVJfS3XpHsxWZM/w+m8dW57Ql2o7wKvxv0r rNrfY6eVbrz8vrfrdnQlg19MjvHs9FWNmCX0oxD0m2LynTLkVT+lXs7Nvwgff9lLXtWv pUgZbpORbRFCCcLnO7ZyW9jKPAHH+9znaXqGV7AXtJtpkJDRGZKCIvYytYkdURDswOsE h6qnV9aXQot8fYSJR7KQYHXTjpbBsX2fw8r3jWkBXGHDjrt7IqWVkNIEdXc+2h6BmSYS sdoiVVRCZ/DuzehO9oUal1+HRuA+coCosgRFIMJwgvzxvQO0i/lHCheJ5PglVpfguYJv 06Sg== X-Gm-Message-State: ANoB5pmVhwVgUIXlPQT+J58C14xia6/rnuyqb1KZrnAKHF6wnBGFTXgI 1pPNDEw9afpznoEvJRnYyVo= X-Received: by 2002:a63:5359:0:b0:46f:7e1c:e6e6 with SMTP id t25-20020a635359000000b0046f7e1ce6e6mr27668686pgl.138.1669226549483; Wed, 23 Nov 2022 10:02:29 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:29 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 13/15] perf stat: Fix JSON output in metric-only mode Date: Wed, 23 Nov 2022 10:02:06 -0800 Message-Id: <20221123180208.2068936-14-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311611047696658?= X-GMAIL-MSGID: =?utf-8?q?1750311611047696658?= It generated a broken JSON output when aggregation mode or cgroup is used with --metric-only option. Also get rid of the header line and make the output single line for each entry. It needs to know whether the current metric is the first one or not. So add 'first' field in the outstate and mark it false after printing. Before: # perf stat -a -j --metric-only true {"unit" : "GHz"}{"unit" : "insn per cycle"}{"unit" : "branch-misses of all branches"} {{"metric-value" : "0.797"}{"metric-value" : "1.65"}{"metric-value" : "0.89"} ^ # perf stat -a -j --metric-only --per-socket true {"unit" : "GHz"}{"unit" : "insn per cycle"}{"unit" : "branch-misses of all branches"} {"socket" : "S0", "aggregate-number" : 8, {"metric-value" : "0.295"}{"metric-value" : "1.88"}{"metric-value" : "0.64"} ^ After: # perf stat -a -j --metric-only true {"GHz" : "0.990", "insn per cycle" : "2.06", "branch-misses of all branches" : "0.59"} # perf stat -a -j --metric-only --per-socket true {"socket" : "S0", "aggregate-number" : 8, "GHz" : "0.439", "insn per cycle" : "2.14", "branch-misses of all branches" : "0.51"} Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 42 +++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 335627e8542d..43640115454c 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -279,9 +279,6 @@ static void print_aggr_id_json(struct perf_stat_config *config, { FILE *output = config->output; - if (!config->interval) - fputc('{', output); - switch (config->aggr_mode) { case AGGR_CORE: fprintf(output, "\"core\" : \"S%d-D%d-C%d\", \"aggregate-number\" : %d, ", @@ -335,6 +332,7 @@ static void aggr_printout(struct perf_stat_config *config, struct outstate { FILE *fh; bool newline; + bool first; const char *prefix; int nfields; int nr; @@ -491,6 +489,7 @@ static void print_metric_only(struct perf_stat_config *config, color_snprintf(str, sizeof(str), color ?: "", fmt, val); fprintf(out, "%*s ", mlen, str); + os->first = false; } static void print_metric_only_csv(struct perf_stat_config *config __maybe_unused, @@ -512,6 +511,7 @@ static void print_metric_only_csv(struct perf_stat_config *config __maybe_unused ends++; *ends = 0; fprintf(out, "%s%s", vals, config->csv_sep); + os->first = false; } static void print_metric_only_json(struct perf_stat_config *config __maybe_unused, @@ -532,7 +532,8 @@ static void print_metric_only_json(struct perf_stat_config *config __maybe_unuse while (isdigit(*ends) || *ends == '.') ends++; *ends = 0; - fprintf(out, "{\"metric-value\" : \"%s\"}", vals); + fprintf(out, "%s\"%s\" : \"%s\"", os->first ? "" : ", ", unit, vals); + os->first = false; } static void new_line_metric(struct perf_stat_config *config __maybe_unused, @@ -561,7 +562,7 @@ static void print_metric_header(struct perf_stat_config *config, unit = fixunit(tbuf, os->evsel, unit); if (config->json_output) - fprintf(os->fh, "{\"unit\" : \"%s\"}", unit); + return; else if (config->csv_output) fprintf(os->fh, "%s%s", unit, config->csv_sep); else @@ -821,6 +822,8 @@ static void print_counter_aggrdata(struct perf_stat_config *config, run = aggr->counts.run; if (!metric_only) { + if (config->json_output) + fputc('{', output); if (os->prefix) fprintf(output, "%s", os->prefix); else if (config->summary && config->csv_output && @@ -844,9 +847,12 @@ static void print_metric_begin(struct perf_stat_config *config, struct aggr_cpu_id id; struct evsel *evsel; + os->first = true; if (!config->metric_only) return; + if (config->json_output) + fputc('{', config->output); if (os->prefix) fprintf(config->output, "%s", os->prefix); @@ -855,7 +861,7 @@ static void print_metric_begin(struct perf_stat_config *config, aggr = &evsel->stats->aggr[aggr_idx]; aggr_printout(config, evsel, id, aggr->nr); - print_cgroup(config, os->cgrp); + print_cgroup(config, os->cgrp ? : evsel->cgrp); } static void print_metric_end(struct perf_stat_config *config) @@ -863,6 +869,8 @@ static void print_metric_end(struct perf_stat_config *config) if (!config->metric_only) return; + if (config->json_output) + fputc('}', config->output); fputc('\n', config->output); } @@ -1005,11 +1013,9 @@ static void print_metric_headers_csv(struct perf_stat_config *config, fputs(aggr_header_csv[config->aggr_mode], config->output); } -static void print_metric_headers_json(struct perf_stat_config *config, +static void print_metric_headers_json(struct perf_stat_config *config __maybe_unused, bool no_indent __maybe_unused) { - if (config->interval) - fputs("{\"unit\" : \"sec\"}", config->output); } static void print_metric_headers(struct perf_stat_config *config, @@ -1049,7 +1055,9 @@ static void print_metric_headers(struct perf_stat_config *config, &config->metric_events, &rt_stat); } - fputc('\n', config->output); + + if (!config->json_output) + fputc('\n', config->output); } static void prepare_interval(struct perf_stat_config *config, @@ -1058,17 +1066,14 @@ static void prepare_interval(struct perf_stat_config *config, if (config->iostat_run) return; - if (config->csv_output) + if (config->json_output) + scnprintf(prefix, len, "\"interval\" : %lu.%09lu, ", + (unsigned long) ts->tv_sec, ts->tv_nsec); + else if (config->csv_output) scnprintf(prefix, len, "%lu.%09lu%s", (unsigned long) ts->tv_sec, ts->tv_nsec, config->csv_sep); - else if (!config->json_output) - scnprintf(prefix, len, "%6lu.%09lu ", - (unsigned long) ts->tv_sec, ts->tv_nsec); - else if (!config->metric_only) - scnprintf(prefix, len, "{\"interval\" : %lu.%09lu, ", - (unsigned long) ts->tv_sec, ts->tv_nsec); else - scnprintf(prefix, len, "{\"interval\" : %lu.%09lu}", + scnprintf(prefix, len, "%6lu.%09lu ", (unsigned long) ts->tv_sec, ts->tv_nsec); } @@ -1365,6 +1370,7 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf char buf[64]; struct outstate os = { .fh = config->output, + .first = true, }; if (config->iostat_run) From patchwork Wed Nov 23 18:02:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25130 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2945925wrr; Wed, 23 Nov 2022 10:11:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7VlNpbN4kSNq33XmVc5e2Rxi6xIdeVSWPev9QnF2wqh3ie4Hl8BppUTa4higsBDqI48/ga X-Received: by 2002:a17:902:f68a:b0:176:71be:cc64 with SMTP id l10-20020a170902f68a00b0017671becc64mr11608341plg.141.1669227097417; Wed, 23 Nov 2022 10:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669227097; cv=none; d=google.com; s=arc-20160816; b=vWCxupRmvjHjY6KIvpDUNJZQPj0GorFZ9vl3m1AvWVVSFMStEvt+rNkXzCpvoX2HVR hK/dg9l8yLmZ8L+0VYR4RkNqdycl/13mtWHuGg2k0vTbIA0GJ0LHR/nHzXCsU2hqUhZj 08Ctvmc1hCeAVpoXZOHBn90rOHjnmIyAsqlaqXhe+UXLPiQrmOX0hfJIzHb1qEm926co H0My6rp4bh2pg1VTVhWVPy204mA+XPH0hbUQDFsN/hbTcHa87F9oe8Ah9lIe0w/aWwUj W352iQXQj/4W1bFQH1hID1uEWm9+pJ+xmEjMu1XDqJoBAuPqKTPSPpFlZT0Gx4HHv04K Zzrg== 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:sender :dkim-signature; bh=6JY8VK7mm86rFloCYzzq/VVEp4y79oTf5pSVCAGXfaQ=; b=szNdcAMFC2SMcpwQ+4SGZqli72QHgVbeVdMGWFA+GSsRrleStccLaxZ1HI+knG9EJn 2pEZBoJ/FID00IrXiuvbKd5yswl1vKIhs0obN2bKIFftDOZ1CodqFvPYvsDH96Jfa4hI xMvj0C2irpxzAG+YETdVwRr7mDmsZtdwu3bpok6Zlj5UzbybgYJpBETWit9ymkpn5yvJ z+LNn+wweqkzD5h2oZ9t2J8BTSYfVuLupaEP9PbKG0o0hUw5cMvdB5QCi74xGUnQd0DH e3Y5MY6oUOwd44EVcNCPc3QxvGwnzzLllD/A4NrZoy7OHHQyOwQa1oAI5tskgt4i86es EbSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C3zIKkzc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cq17-20020a056a00331100b005712b7c5b2fsi15011774pfb.78.2022.11.23.10.11.23; Wed, 23 Nov 2022 10:11:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C3zIKkzc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239612AbiKWSFD (ORCPT + 99 others); Wed, 23 Nov 2022 13:05:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239477AbiKWSDE (ORCPT ); Wed, 23 Nov 2022 13:03:04 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F705AE52; Wed, 23 Nov 2022 10:02:31 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id q1so17382336pgl.11; Wed, 23 Nov 2022 10:02:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=6JY8VK7mm86rFloCYzzq/VVEp4y79oTf5pSVCAGXfaQ=; b=C3zIKkzcOV1TrjDmX6L0bR17gpwYhWEv+xiT26HBcW84xtlj6fhBFmAhqs/3COFcXC VTliI5vz+jWa/qL3CuqC093JzQaTYQxGRYsJeu5E2Vh0A6KPTTX9RK6v13oH7FxofezU ELMK78JeU0oKkj2ajvHSsRcYpyNJofsveA+3B59/AmnyY1QaxmIH7gnJpDe3QcjgadXd +st0ZbMXUBZIHN1Q1Zvdzag9tlDQl6Vi2la14+gtB3OrvY3AcudiCunKfvFclQNUCoCG r17Y0gOQnWapFlBkd5ZSyxrgB9j8Kdk8uJHxx5Jy5tSnwzgyI5AFZMQfVoldKaIW/wG1 EmkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=6JY8VK7mm86rFloCYzzq/VVEp4y79oTf5pSVCAGXfaQ=; b=28iQmFTaojSpc/AkvzOwSBnydjfQBOOOo+qOqj2DuBT7E31E7d1/TrJYd/b1/SzkbO caM2ZnJK/EMRRITVrlfC3s9dn/wvUYM9i/Xb+NYgbHTSJjBmrkM5noig8YN3hM0Ko3S0 ahye8tjiJTXm+LNziGUYM2PEXktPgXBgIZ2l11BV0Cw0TVa6jElgjIEX6AistyOvHRzx ANOZWXHdrFRuoHy9kov6evgicKRtzmZonlWY92Zs8Kg/0BY+QffqQ9MlhDtYMszb5BMy MuiXTGbOCgqFI4yagxDUBWXJxAIB39FxQR3B5w9w3PgJAHqllDmcCHy42spNB5NQO/OB 7U2g== X-Gm-Message-State: ANoB5pkG/Za2xy2rO1gKZG6mrG0HcnUV4b0IgTH/Gd32lJyJ1Cfh5C8j 4N2KcX0ksfokdHOAc+JECJ0= X-Received: by 2002:a63:ff5f:0:b0:46f:b6df:3107 with SMTP id s31-20020a63ff5f000000b0046fb6df3107mr8603480pgk.454.1669226550830; Wed, 23 Nov 2022 10:02:30 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:30 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 14/15] perf stat: Rename "aggregate-number" to "cpu-count" in JSON Date: Wed, 23 Nov 2022 10:02:07 -0800 Message-Id: <20221123180208.2068936-15-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311472702271170?= X-GMAIL-MSGID: =?utf-8?q?1750311472702271170?= As the JSON output has been broken for a little while, I guess there are not many users. Let's rename the field to more intuitive one. :) Signed-off-by: Namhyung Kim --- tools/perf/util/stat-display.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 43640115454c..7a39a1a7261d 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -281,19 +281,19 @@ static void print_aggr_id_json(struct perf_stat_config *config, switch (config->aggr_mode) { case AGGR_CORE: - fprintf(output, "\"core\" : \"S%d-D%d-C%d\", \"aggregate-number\" : %d, ", + fprintf(output, "\"core\" : \"S%d-D%d-C%d\", \"cpu-count\" : %d, ", id.socket, id.die, id.core, nr); break; case AGGR_DIE: - fprintf(output, "\"die\" : \"S%d-D%d\", \"aggregate-number\" : %d, ", + fprintf(output, "\"die\" : \"S%d-D%d\", \"cpu-count\" : %d, ", id.socket, id.die, nr); break; case AGGR_SOCKET: - fprintf(output, "\"socket\" : \"S%d\", \"aggregate-number\" : %d, ", + fprintf(output, "\"socket\" : \"S%d\", \"cpu-count\" : %d, ", id.socket, nr); break; case AGGR_NODE: - fprintf(output, "\"node\" : \"N%d\", \"aggregate-number\" : %d, ", + fprintf(output, "\"node\" : \"N%d\", \"cpu-count\" : %d, ", id.node, nr); break; case AGGR_NONE: From patchwork Wed Nov 23 18:02:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 25135 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2947425wrr; Wed, 23 Nov 2022 10:14:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Sn4SLLNonL/O9M6SqGh7eMdFUice/EdvCqrkTh1d2ALhvLOgT6109hv05ZL1DM3ne6iKL X-Received: by 2002:a05:6a00:21c2:b0:56b:bba4:650a with SMTP id t2-20020a056a0021c200b0056bbba4650amr10119968pfj.4.1669227267343; Wed, 23 Nov 2022 10:14:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669227267; cv=none; d=google.com; s=arc-20160816; b=qHZPiO7C8ITSbcvef79QQLUKn4Ms98aqxNNwMHAQqiFYwSH+Jpa0r11Krvbxh5GvN9 HEwhQY/D/Ye4/bibsdTLSOD4OO77Cjpfj44f3NVSjKsO8pFhVO3KlB9kz0qVXCczekI3 RSQTlPMAXAm2NvfwBsTMXb+8IgdvQPGy0/1HKgUWPlo7uw/FttgrpVuFvNe6eo+uK7Av MLzbLHkvEBNd6Vf79pu7Uu+bClLPVxDwJG+HdbCja5gqQYPHAQdZSMb5ZPv4Sf8Scaz3 CZO+IP1SsZ1biQ54Gtgdb9iEW2BoiFRiLA2i+W5zw56nzdqsursulEPYxGbNjSeanKqY BBgg== 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:sender :dkim-signature; bh=5gWMIg8ivBELEJG/R0PKwrUC/7uMdDKInwMAEQaG27g=; b=CEY7cxtyVSXuqEnG/I8nHAPE0faWdfsERRb6cEsqyevFE6riroF8MsPW3EIRpVNCyp XhZUD3L3oV3NkWxwiGafgHIIpa7xWoew+8FZzDfRQbHn14GyzimzosC3yqpTBaNOU1Nq 6OPqMOkg659bfZgczYohTurFfwBWvKoWuF3LR3CCViyHDvauaAQOGChDjggmHJ0OXG3M 1NnxxvrOtSbqi4TXg7yaZwGG5y9EffT1H4LXAj1arxeyQJh7h5x/5ve6fKhnDqlBdpEa MbvgpW/jaGhQQnl4/wma90clQokDVzeorWkTnTFUuBxNBhlwqJnnjR9cV41bmHsBpUVe 6+rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qke1to8Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 3-20020a631443000000b00461f124bc4csi15370203pgu.86.2022.11.23.10.14.13; Wed, 23 Nov 2022 10:14:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qke1to8Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239641AbiKWSF0 (ORCPT + 99 others); Wed, 23 Nov 2022 13:05:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239495AbiKWSDK (ORCPT ); Wed, 23 Nov 2022 13:03:10 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7371B86B; Wed, 23 Nov 2022 10:02:32 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id io19so17330837plb.8; Wed, 23 Nov 2022 10:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=5gWMIg8ivBELEJG/R0PKwrUC/7uMdDKInwMAEQaG27g=; b=qke1to8QicpmSPkYhan1X5ZD1RXagJ2z9CmBhlLxQnhfXiTNJv8xxwutR/52394kes /01n7X41yjZGds2kUIu5G9xg2YM8+VDjSESa6fAiTsGHXfgO3j6QTC5HJDSwJN4E7eKH 1maVXeqsL+OzSug7BaPNpHQw+lJLgtlPWzSpJQrhtBCxCto4yLKv3yA+j0tGTV2Xf0zH XuELKUdwLzl+JQqJ5qv1xzNITBfylJFCh3RO/44/tN61UNXshv+B4U2FF4CwgHGR2MuW OvkT+rhMS0TMFgvbe2U5+6lolArOc4uY0IKRs67Sutu0wItPk0E03j9nrsqC5gsTvG6O Hqdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5gWMIg8ivBELEJG/R0PKwrUC/7uMdDKInwMAEQaG27g=; b=CSgyiyVa/M7uRk7X2k+g6+qsCIc11Q8TFlMn46yfxaa+tABOZhOPSZhBbarrbq6xj7 vHrw+xmuv8XZz4r6tntEDE/v3kGo0An2SD8Vui1+4gfsGO8VDVARN90xzbpv+jW5Auv5 ULERn1XPRSatCXCFGRw7YB0RSuUowJk4o++IKx+IqnjVil3ZXth8E8CrRGMc8hQ8qlT0 KuLVS+Yps21Y2Kcx9+OVesgbJFmU0vdSUi80mHmXEjg26ms3lljbrBmslDMWuF7emB3u H+NVpDjYwqAm2LhRyEiFG9mK8DCvg6IRRe6FCr8BzifLh5NOVyRroPpdQLw6GS7Bnv29 6aFQ== X-Gm-Message-State: ANoB5plyjAtva/h0YfG9QYiKimb/znui+sBSaeo0ua0luyiFY7XWWj47 rfG4B//Apn4DuaW7SKWQw6w= X-Received: by 2002:a17:903:3311:b0:186:d5b9:fbcd with SMTP id jk17-20020a170903331100b00186d5b9fbcdmr12767970plb.64.1669226552177; Wed, 23 Nov 2022 10:02:32 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:c968:76:254b:3790]) by smtp.gmail.com with ESMTPSA id i15-20020a655b8f000000b00470275c8d6dsm10792364pgr.10.2022.11.23.10.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 10:02:31 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 15/15] perf stat: Tidy up JSON metric-only output when no metrics Date: Wed, 23 Nov 2022 10:02:08 -0800 Message-Id: <20221123180208.2068936-16-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog In-Reply-To: <20221123180208.2068936-1-namhyung@kernel.org> References: <20221123180208.2068936-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750311650868997345?= X-GMAIL-MSGID: =?utf-8?q?1750311650868997345?= It printed empty strings for each metric. I guess it's needed for CSV output to match the column number. We could just ignore the empty metrics in JSON but it ended up with a broken JSON object with a trailing comma. So I added a dummy '"metric-value" : "none"' part. To do that, it needs to pass struct outstate to print_metric_end() to check if any metric value is printed or not. Before: # perf stat -aj --metric-only --per-socket --for-each-cgroup system.slice true {"socket" : "S0", "cpu-count" : 8, "cgroup" : "system.slice", "" : "", "" : "", "" : "", "" : "", "" : "", "" : "", "" : "", "" : ""} After: # perf stat -aj --metric-only --per-socket --for-each-cgroup system.slice true {"socket" : "S0", "cpu-count" : 8, "cgroup" : "system.slice", "metric-value" : "none"} Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 7a39a1a7261d..847acdb5dc40 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -532,6 +532,8 @@ static void print_metric_only_json(struct perf_stat_config *config __maybe_unuse while (isdigit(*ends) || *ends == '.') ends++; *ends = 0; + if (!unit[0] || !vals[0]) + return; fprintf(out, "%s\"%s\" : \"%s\"", os->first ? "" : ", ", unit, vals); os->first = false; } @@ -864,14 +866,19 @@ static void print_metric_begin(struct perf_stat_config *config, print_cgroup(config, os->cgrp ? : evsel->cgrp); } -static void print_metric_end(struct perf_stat_config *config) +static void print_metric_end(struct perf_stat_config *config, struct outstate *os) { + FILE *output = config->output; + if (!config->metric_only) return; - if (config->json_output) - fputc('}', config->output); - fputc('\n', config->output); + if (config->json_output) { + if (os->first) + fputs("\"metric-value\" : \"none\"", output); + fputc('}', output); + } + fputc('\n', output); } static void print_aggr(struct perf_stat_config *config, @@ -897,7 +904,7 @@ static void print_aggr(struct perf_stat_config *config, print_counter_aggrdata(config, counter, s, os); } - print_metric_end(config); + print_metric_end(config, os); } } @@ -929,7 +936,7 @@ static void print_aggr_cgroup(struct perf_stat_config *config, print_counter_aggrdata(config, counter, s, os); } - print_metric_end(config); + print_metric_end(config, os); } } } @@ -985,7 +992,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config, printout(config, os, uval, run, ena, 1.0, counter_idx); } if (!first) - print_metric_end(config); + print_metric_end(config, os); } } @@ -1348,7 +1355,7 @@ static void print_cgroup_counter(struct perf_stat_config *config, struct evlist evlist__for_each_entry(evlist, counter) { if (os->cgrp != counter->cgrp) { if (os->cgrp != NULL) - print_metric_end(config); + print_metric_end(config, os); os->cgrp = counter->cgrp; print_metric_begin(config, evlist, os, /*aggr_idx=*/0); @@ -1357,7 +1364,7 @@ static void print_cgroup_counter(struct perf_stat_config *config, struct evlist print_counter(config, counter, os); } if (os->cgrp) - print_metric_end(config); + print_metric_end(config, os); } void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *config, @@ -1405,7 +1412,7 @@ void evlist__print_counters(struct evlist *evlist, struct perf_stat_config *conf evlist__for_each_entry(evlist, counter) { print_counter(config, counter, &os); } - print_metric_end(config); + print_metric_end(config, &os); } break; case AGGR_NONE: