From patchwork Mon Nov 7 21:33: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: 16729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2308719wru; Mon, 7 Nov 2022 13:35:56 -0800 (PST) X-Google-Smtp-Source: AMsMyM61Gqa3inZARFrdMP6mxGzEQvOWe9MMk0HANn4xhRO3vqGTT792uFNXLO8ItC9T39S1RO5P X-Received: by 2002:aa7:d858:0:b0:463:12ed:3f86 with SMTP id f24-20020aa7d858000000b0046312ed3f86mr48698248eds.281.1667856955888; Mon, 07 Nov 2022 13:35:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667856955; cv=none; d=google.com; s=arc-20160816; b=XZdKjSGzPJX2AaAaWlVurAAo2er5Msud/8+VUwutG+2Hxtm3aA3F9fd7yQ3yryugPc l6LEcEuiItAfa55R8BbjbuGJ0ui0RbeEKaP0OCU7mmVdE2uQCaey/xywYQdT1JcHmKyT dJEnZTgiPa79sZC3ItN0Zg1S6FPKOInzMOaFUHEe4xOEYS8cSNCKU+x7jvmLwRPYXlc2 jnofr88vMd/ZGc1WkCKmemjuYFpRS6DOZ9oSV8PbkI8xbshnQD6WuY4CwE33kREdv9ka RllW68USkFu5LgeiFzey4wIESogQXEwD816w09TYpGJCxisPrtoOnajvXwX3YNokMJON fZTQ== 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=P/+ttTXlN3qSbb6UdL+RVJy8YHaKz6aK11BAwI0KhZk=; b=sLWmJ0cL/3S3XwKgyXOMzXYRajm3eChzK5ya5Mf2JeWxQFQ1u+WIGA4Q/OaD0Q3yDy gkgH6jJCnHY5JrvCckQwO2yYhImIgwfaLGlkTihhc3Dtzeb6Rsx7PcswK0isaIstnPnf iqJKmsHwbld9NWGlHvrFODqzoqCyru863xxz45Q8v3Jb5HPyVBpnCgrh4T7+WHaxli3p dj3garXFkXnq+uwMbMIGqe/Jl6t9rX/qaSTYsoj1XzCq68y9+T3/YT/BEkRWUvQHXMAA BN2pCIDbzCTcTUpv16uP1vbzNDb6n2knCJ3VTU+u38oVry61AKTfeLvJ13Q9LmkUwZ0R LVEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bT85bhI6; 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 sd6-20020a170906ce2600b007aa8a5131a3si7007024ejb.181.2022.11.07.13.35.31; Mon, 07 Nov 2022 13:35:55 -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=bT85bhI6; 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 S233390AbiKGVdY (ORCPT + 99 others); Mon, 7 Nov 2022 16:33:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232943AbiKGVdV (ORCPT ); Mon, 7 Nov 2022 16:33:21 -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 7DFAB2EF69; Mon, 7 Nov 2022 13:33:20 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id r61-20020a17090a43c300b00212f4e9cccdso15944550pjg.5; Mon, 07 Nov 2022 13:33: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=P/+ttTXlN3qSbb6UdL+RVJy8YHaKz6aK11BAwI0KhZk=; b=bT85bhI6QB9lAe+cK/rigjb/ajLGDmXBUw0hdSD22wbGr/UQY/Mminlke55bRAebf7 0+IuVaLVLgYwYqGGpeBn0Tv1LbZ8F04Cs8ihKMzCoi6Uk9YWxKvPweSbFSjOUGe4k1/L BfzY1VyP5MLjC2fwDRYhYiDHNnwboMZEe7+bI2nY9xKPzWJjwMterMehmFHve1RYabZl V1SylFJDb6sXgEBSdkOBwZf0CFxMwxKPCHUGMa4sZJKch/D/tOHGoY3nZkm9Spd4bsy7 z28nkpTYHByNuIxG8vQ+lBb4oe2JzIBHfk7emsPRTkroltTHnR0UPE/W9QjlPA0Y6yNx /fwA== 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=P/+ttTXlN3qSbb6UdL+RVJy8YHaKz6aK11BAwI0KhZk=; b=rBINTWAlOFLhyq/HfW2K1DagS+fEIVV7o5qQsPWuTU4ZZzuCSYvasH0r5Ciopw0BsQ Ov2OjKmFMphkgRZMCP8MBoypy1VGHG71nFJCbSqV3a+WaZE85tGN3cWHksyScZrgJbk6 a9XxRR+Z6qLVmBm1fYLgR3yK51sfDselwT/3GMS26FBVWBTkiltG/FiLtEWQTOJ3txIP HhEFPpB7HihZs+7d2kkSiALlMp/A/OdYsa0ChGgAbODhj2gXfRj3lG0f3Gm9rNqEqW2h v9sHlrNh0YfCd6U3QL2mLW1S6wcLzO/PqRAa/NuxKDBjZEt+rx9wRo9BYhpkaU6iK+RM 5HbQ== X-Gm-Message-State: ACrzQf0TVjtW2XBIENEn6W3aeK9LBH2wOhnBWsQWMphaN7Sf2uVt8XzK ckXMAMfA2Xv++ycIBRZsAq8= X-Received: by 2002:a17:902:d38d:b0:186:9fc5:6c13 with SMTP id e13-20020a170902d38d00b001869fc56c13mr52726184pld.73.1667856799881; Mon, 07 Nov 2022 13:33:19 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33: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 Subject: [PATCH 1/9] perf stat: Fix crash with --per-node --metric-only in CSV mode Date: Mon, 7 Nov 2022 13:33:06 -0800 Message-Id: <20221107213314.3239159-2-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874775310298516?= X-GMAIL-MSGID: =?utf-8?q?1748874775310298516?= The following command will get segfault due to missing aggr_header_csv for AGGR_NODE: $ sudo perf stat -a --per-node -x, --metric-only true Fixes: 86895b480a2f ("perf stat: Add --per-node agregation support") Signed-off-by: Namhyung Kim --- tools/perf/util/stat-display.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 657434cd29ee..ea41e6308c50 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -534,7 +534,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int [AGGR_CORE] = 2, [AGGR_THREAD] = 1, [AGGR_UNSET] = 0, - [AGGR_NODE] = 0, + [AGGR_NODE] = 1, }; pm = config->metric_only ? print_metric_only_csv : print_metric_csv; @@ -819,6 +819,7 @@ static int aggr_header_lens[] = { [AGGR_SOCKET] = 12, [AGGR_NONE] = 6, [AGGR_THREAD] = 24, + [AGGR_NODE] = 6, [AGGR_GLOBAL] = 0, }; @@ -828,6 +829,7 @@ static const char *aggr_header_csv[] = { [AGGR_SOCKET] = "socket,cpus", [AGGR_NONE] = "cpu,", [AGGR_THREAD] = "comm-pid,", + [AGGR_NODE] = "node,", [AGGR_GLOBAL] = "" }; From patchwork Mon Nov 7 21:33: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: 16730 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2308863wru; Mon, 7 Nov 2022 13:36:21 -0800 (PST) X-Google-Smtp-Source: AMsMyM7V/ixh2QhVS38sztw6Y4lnyLFIfbq6ay1BJK+ZStGW3jrUpOZSHWlMA6EedTykhc5Kc3ZY X-Received: by 2002:a17:907:a055:b0:7a5:587d:d313 with SMTP id gz21-20020a170907a05500b007a5587dd313mr47700434ejc.657.1667856981753; Mon, 07 Nov 2022 13:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667856981; cv=none; d=google.com; s=arc-20160816; b=ZvYnpXJWfylYkMZ/KTx7eSYesOzBRMoycrLFMypLI2qTCID57yLDIHuGUDuq4f72xF O0pSvypTJc/ogASDPRnK6iKVpbNRbiUXs9bGsUiwuJm1z2Oz97oWE+jiUlsuHleqeosa 3UiA1ik4Z9mzj0EpuMbvRadrcGuGpqz5lh6fe79ZEQQNGPJTzypklq0ycDAn/M6n/GN2 XSMq3YO47s45o5EDSnyr6BkOMVoF6XUb2XM9Zt3Rx+0+X/rl4FiihT6wmTX+XEfLcTmh +X+dLjqM/voW2avvD0zLV6E319Oc8D82BlyvwZhhTvtCRgMxmDBdbjzyt4bf2MJ0DlE4 +jzA== 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=Qv3hf1ICDXb7Hn+sXBgVCZ+pZTQGoTEBZluThFFWAXw=; b=dZgnf6OjZLptBlqveaB98fzuQ9yFE2wws/UeZo1HGWvC9wP8HTpe9GIUzCSKCEHx5c cfBFBfxr+Ogd9Bnsris3FSNDnYsCvzTr5XA2tW2TRHGVFcq/+vfrKTBu0Cq7fPsuMMTk pfghUDfUrG29sZmue5vRaSK+bhzQSx+0XxP/AJPPwm3Un3cEbGNkcBm2HSGup50rmea/ 263n6MKQ/iFHpo7JljT46T75AsWWGG/cKwVHx2oHGU5z5Sxzb1hEONkkOgg7T9XmKHJf OWnrTWm+cxh1ocZSuT81/0mOqg8DfF5YpBtgaaaletRmmE1aaJw0I6mlQUlnFj+kpSfz JEwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kE7vmIC0; 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 en20-20020a056402529400b0045d46f28533si9720726edb.377.2022.11.07.13.35.57; Mon, 07 Nov 2022 13:36:21 -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=kE7vmIC0; 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 S233424AbiKGVd3 (ORCPT + 99 others); Mon, 7 Nov 2022 16:33:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233403AbiKGVdY (ORCPT ); Mon, 7 Nov 2022 16:33:24 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8372129; Mon, 7 Nov 2022 13:33:21 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id gw22so11860952pjb.3; Mon, 07 Nov 2022 13:33: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=Qv3hf1ICDXb7Hn+sXBgVCZ+pZTQGoTEBZluThFFWAXw=; b=kE7vmIC0fkdEnNFfXn/JmPMCk/jZwZAJ6eYmSAC8mz5l/evGA37v3qWxC93WNPk1jy 7ofPD7Di5xAfJ5Ijg7llqyLpaCaGx80X0RQC3pEooX8V8F6u05/7CW6Ir25lwiiGjxBj Pd7QeBQsGrkpIfs0HO0Rt09XlchaC3p9XDIcwMWt9xPYORlsA756Sxs3S0OUShd/nrDb DfCrnzUQaLAtZREo+D5NPT9T0tOd235pwhvEzXJ1mq+exXCyyVS2H2jDLcAsO90m7jx8 Fsxpin/f+NLxS10ZEi5SPi/un+LGGAzEeADUq8rcUi/5NLVyQoUy7Xo2VLrVoAZrTkp6 9G2g== 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=Qv3hf1ICDXb7Hn+sXBgVCZ+pZTQGoTEBZluThFFWAXw=; b=ZTPplWGM4aN+EbEw/4IE6c5Pl4JMSYS2QT78mPTOLRbm4EJdRI4mhf0eZlu/BGmCD+ yvNzpeSVF0hxnD5w4PpNq3MV2FuqXE4R4mXFlYdJhIwnHJUcqeizG3kTw32JirtZGjgY UoFyvCDpm3aRySWwiOqRpdXrbRhLioNlzki52juHR4p6FV0n97FMpEcgn3lNSYPENBax pFV80pJVqCpNszqIa70nQb7reBiE7/O4yK280mp4KlAi0nh5YY1NsDGcNP3ZmCqJ+WmE 4zTHIKloPciWrlpxOMVNV5PmADmEywvgoYkiYr9eurkvNGa05H50XN60EeSzqmp4L+Zl Wung== X-Gm-Message-State: ACrzQf0u9eBlPwE9CytADiWGrLPbkDYE+pZBl9ekRbYr6K96uI7zG9GD LdRqDuTw1so98G8M+cnTygk= X-Received: by 2002:a17:90a:9dc5:b0:213:c885:bc06 with SMTP id x5-20020a17090a9dc500b00213c885bc06mr48829260pjv.223.1667856801287; Mon, 07 Nov 2022 13:33:21 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33: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 Subject: [PATCH 2/9] perf stat: Increase metric length to align outputs Date: Mon, 7 Nov 2022 13:33:07 -0800 Message-Id: <20221107213314.3239159-3-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874802774089642?= X-GMAIL-MSGID: =?utf-8?q?1748874802774089642?= When perf stat is called with very detailed events, the output doesn't align well like below: $ sudo perf stat -a -ddd sleep 1 Performance counter stats for 'system wide': 8,020.23 msec cpu-clock # 7.997 CPUs utilized 3,970 context-switches # 494.998 /sec 169 cpu-migrations # 21.072 /sec 586 page-faults # 73.065 /sec 649,568,060 cycles # 0.081 GHz (30.42%) 304,044,345 instructions # 0.47 insn per cycle (38.40%) 60,313,022 branches # 7.520 M/sec (38.89%) 2,766,919 branch-misses # 4.59% of all branches (39.26%) 74,422,951 L1-dcache-loads # 9.279 M/sec (39.39%) 8,025,568 L1-dcache-load-misses # 10.78% of all L1-dcache accesses (39.22%) 3,314,995 LLC-loads # 413.329 K/sec (30.83%) 1,225,619 LLC-load-misses # 36.97% of all LL-cache accesses (30.45%) L1-icache-loads 20,420,493 L1-icache-load-misses # 0.00% of all L1-icache accesses (30.29%) 58,017,947 dTLB-loads # 7.234 M/sec (30.37%) 704,677 dTLB-load-misses # 1.21% of all dTLB cache accesses (30.27%) 234,225 iTLB-loads # 29.204 K/sec (30.29%) 417,166 iTLB-load-misses # 178.10% of all iTLB cache accesses (30.32%) L1-dcache-prefetches L1-dcache-prefetch-misses 1.002947355 seconds time elapsed Increase the METRIC_LEN by 3 so that it can align properly. 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 ea41e6308c50..17d656566cd9 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -218,7 +218,7 @@ struct outstate { struct evsel *evsel; }; -#define METRIC_LEN 35 +#define METRIC_LEN 38 static void new_line_std(struct perf_stat_config *config __maybe_unused, void *ctx) From patchwork Mon Nov 7 21:33: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: 16739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2309609wru; Mon, 7 Nov 2022 13:38:11 -0800 (PST) X-Google-Smtp-Source: AMsMyM6x9PYo2DXtPyJ15gBBwLcG/DYCXT3VYmtm1ybQ508cdUSy1rS4Dr0ziL9rynMXoj4c3HVg X-Received: by 2002:a17:90a:7e10:b0:213:9e81:87e2 with SMTP id i16-20020a17090a7e1000b002139e8187e2mr56203738pjl.1.1667857091423; Mon, 07 Nov 2022 13:38:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667857091; cv=none; d=google.com; s=arc-20160816; b=MKjLvQVoVC0reABME46J41jh4fRQL+xGN4DH249gURktkiBy0vQArfqMNk+ooF0i1g YbjDruVWbD210Zkk5DZ2YNmYFI+FgKo7Qqw9aTNqueTjEnJXERRqs8ZIY7a6HALjDJhb LvqsBpyLpgCFh3UTpZ4tiKc4lvSNVd8IlKD/BbodqUsiQ0GpmgFXBk6dM97f6emk+HHZ olGdpC4444vkrAcYrYg8VX3w1kO0OfNbJ5sHizsQkrD6U9RTeeGHW4iag/gV7zPAJoO6 Ly04d4q7tW0YyEOiH2BARnKBHawTOX+NcFe3Eqy8chhHT1K7EQL2NjbgC+9MI3SbXBmP KTBQ== 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=7OYL7vpqm8L3ADcCJc6hKNFYnwJB/S0aPLCXr3zst78=; b=VclXKmKGZ6OTCiT5WotMKZ00R/63tNkg5TccpNc7MQKYTl7qeEzqg0QGFa7my41sgY knAKVuuHll9depsSKKIASA/QuZNCa/6L6id9TvvrzlRasFcOSjuxtOUbtIglN1XAi+/B 6+8NHHitNh40AXv86bcoAK6VKk0QSUxd7gUwHDaN4CsjUoyIxzGIBlpCH63npX142lNp kw39n0gLEOLo0sKsybHQe9+6+JRr4aFXd/PoxICxA8VkVgD4EsMTLtrZRd3DUdyBtz0g CJfqgpTpj1YUNGIcVj7biZ+awv92d7kZHtJ4JnAF8JJa9T1o0QlK/8z1SYkm4pRQqeeN 1zNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="CESh0/Zb"; 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 n12-20020a170902d2cc00b001868277386dsi13782772plc.192.2022.11.07.13.37.55; Mon, 07 Nov 2022 13:38:11 -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="CESh0/Zb"; 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 S233481AbiKGVdg (ORCPT + 99 others); Mon, 7 Nov 2022 16:33:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233405AbiKGVdY (ORCPT ); Mon, 7 Nov 2022 16:33:24 -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 1FD79328; Mon, 7 Nov 2022 13:33:23 -0800 (PST) Received: by mail-pf1-x432.google.com with SMTP id k22so11912408pfd.3; Mon, 07 Nov 2022 13:33:23 -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=7OYL7vpqm8L3ADcCJc6hKNFYnwJB/S0aPLCXr3zst78=; b=CESh0/ZbpAqv78rvTm8npz/mdldte6JqrpQpXmkhJ2wRVcw0OaAFcL7610kd1GdKl8 AZCMrJ9+Fs+7tIV9NG0S4KQq/FViPJ+GxPNZg5ErU7py8WNJmC716PJCcJ3NKBDpkVC0 xTzO6S6hKRmmYXSM5FtGZYrsRN6DufyRAY9noU6V7TwryqQRIz7PAiORUIAZwdCOGtRG TQZE32AFfYDUYjXo5n+KUygsPtM/N/UdLqjpylqsmJqrf7h0JP3WScHuthqjjoywNV5i GG2fqxjkgycjEBQsNbmHSCwgfzuhZYojwxUFKW94EHDJAjtXmLofBafb/AdjMS5CfY+m /D/w== 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=7OYL7vpqm8L3ADcCJc6hKNFYnwJB/S0aPLCXr3zst78=; b=Gsk8NJHsaKlyseXSHVyi43sTCcqumycHxBkRHw55Dj7H7zF0hr1dXbzXx2xFzG+dwA aR9BwCA1noYhTuiTqIBqtlkC6HqUDyFSbdemfNVL3wCNztLM27imDn8vwJVbaXsCAVfj Ul8KlujcZkT3hb330FYjWm1jqcUsrFjRanVL70M7QWMTiVyTFtwQlQOdF89GM8RBlOOc Cm5BCPMRCH7MEUYvWFIulfn/5MJaaRM5eGifBz+VJypjhXpj9tFsMeCEaVNiSKZhAJC+ yHKGnsijxjN/mEht8tKyKQL5qLXCz4lo10GxFDk6lp4+rmbLlgesAwcyxueEidAmCWXa vUzw== X-Gm-Message-State: ACrzQf2pj+rdmyjVSS5yGMXW6hKeUqWXliPXxlozkPb/bTnsybCkTAn5 PlUTxi332PrXWA5EEI6u/lU= X-Received: by 2002:a65:6950:0:b0:439:51cd:8b8b with SMTP id w16-20020a656950000000b0043951cd8b8bmr45185677pgq.230.1667856802573; Mon, 07 Nov 2022 13:33:22 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33: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 Subject: [PATCH 3/9] perf stat: Clear screen only if output file is a tty Date: Mon, 7 Nov 2022 13:33:08 -0800 Message-Id: <20221107213314.3239159-4-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874917251559317?= X-GMAIL-MSGID: =?utf-8?q?1748874917251559317?= The --interval-clear option makes perf stat to clear the terminal at each interval. But it doesn't need to clear the screen when it saves to a file. Signed-off-by: Namhyung Kim --- 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 17d656566cd9..d4936a502560 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -892,7 +892,7 @@ static void print_interval(struct perf_stat_config *config, FILE *output = config->output; static int num_print_interval; - if (config->interval_clear) + if (config->interval_clear && isatty(fileno(output))) puts(CONSOLE_CLEAR); if (!config->iostat_run && !config->json_output) From patchwork Mon Nov 7 21:33:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 16733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2308945wru; Mon, 7 Nov 2022 13:36:34 -0800 (PST) X-Google-Smtp-Source: AMsMyM5C8BNRwSBbLfh+gQ9qjKRaoJlYvm6juBpI+ktAF7hueMxBJc1Gkgh37fAMfjZUl0ToLrfg X-Received: by 2002:a17:906:4bd3:b0:731:3bdf:b95c with SMTP id x19-20020a1709064bd300b007313bdfb95cmr51056134ejv.677.1667856994635; Mon, 07 Nov 2022 13:36:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667856994; cv=none; d=google.com; s=arc-20160816; b=X0eCmZiyZqj/rsTRyD2yti3jK8FcGfSZ+UyZE/OYypL1Uvg/zTZrVObCMB+hi+aGXT m1sWcTue8xWMr2H2eplpovsf7qDvJpNzdMK0qdaFTAONkDcTvK5poIRV6z491BJoQY4R T21AW2hVhytuJLg6MOQjSGvi20JLZNh0WNBu8amGyCWjjmQkiDIBDuqNVTT5C2tS/zcH U3+MCvyW/+62gB9L2l4QlfjRd2jn5OGjpAxPp8Y6Wdm6WQYIJNB86akr8mTKWCKSSWbH k2SVeBP4knvYdZX8/awPphX20aMo8M3bbesDey4Ck+HewLRjyuvTr54AdLSr8XRC7kyf SopA== 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=AIzOeW4bqFAI0ZH2XjiJS5dG7CBesFCQCZcY4ffv/5k=; b=D9Qccxd0VaALT4ZHF7a3+8CVOxZ6Kt9RLpczsYdPdxzMPCs0nEybJISQjd4WrFM/zL q2H3S3FA6LPI9hdRz18idum2y5nQ0CpxS1oGwChseMQe2FXPPJhoW/JBK10JJklQPMPm 0/cdE3nLzPhudP9300SndDZuGpitErktWSchIMSE2WBU6tl5zXBMvCP23RRV4fsNEtfP 6nUqtD5S6JOcGirdG4Kx0M+/lWzRWe1hXDq+k188DGIoGmIQVbBxHtozqjaPriwDc2Q0 Z8lGHZv4ebT+KBUTrBqKPhBCtXFMb+OEZt0zte7rQNLBN/sGpZDevx3CK8F0xNPKKWzW e4cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Rdq9AtpQ; 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 z10-20020a170906714a00b0078a891e407dsi8174595ejj.974.2022.11.07.13.36.11; Mon, 07 Nov 2022 13:36:34 -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=Rdq9AtpQ; 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 S233532AbiKGVdu (ORCPT + 99 others); Mon, 7 Nov 2022 16:33:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233477AbiKGVd3 (ORCPT ); Mon, 7 Nov 2022 16:33:29 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A39FDA2; Mon, 7 Nov 2022 13:33:24 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id v3so11629342pgh.4; Mon, 07 Nov 2022 13:33: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=AIzOeW4bqFAI0ZH2XjiJS5dG7CBesFCQCZcY4ffv/5k=; b=Rdq9AtpQ8XqcN3B/WunTUwRM/esIVOLGUjjW0IkrxsTEQDcHBwSY2wQIXEWg/sdJS5 rarfpDM9YCvt5+LMJohUnxBSQXo6pgGP2kxUFXcwA0cj408Z5u2TR9GedsgRndqnO79I 9REV/ya38OwppOAY5PKuKzVk4GTzrm1DTfk07FRrzUeKtLqaV8kS3aY31LXl3O3Ik8a/ E1y0DdGllTSXmnh/wit5D7kyii3XanD79Voxw+NqwLlGvlRrF9it3SKKBOJ3NWl8vvGd vQc8upcdNm8xB9fdsed8VEbpGlDKGHtjeFC8p8nM0b7mlHivMZfn9G1F0QpPektOlTsn 59lA== 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=AIzOeW4bqFAI0ZH2XjiJS5dG7CBesFCQCZcY4ffv/5k=; b=QBWJISr+Etq3HBF+F6pMPoC7gBY4Gy13pTJ3Mo4e6ynOJPD094G/DIq2K3pE+X57dZ sYTzfPwqdBtz87wZrpjfjdCn01J3CXEq93HA1gcmrgpqrzBeRlYeVTjoh54uR/1s0e9n +nhAzI2zlLRXTFdWs0ZiruGJJLSxrAFUFRkaOcNB0CyYUQjtDxaDiZBwUFASogKEyQ3N K3fYiXJUYQqzmgm5hLpo9xv/G/8wwyA+kR1jrX2a6+i5QSOJFzrl8YgXWSo+CS9Hps7a RWC5oS1JzZVG/HWb1UZ7HxR7WSvZH7X5ECoeGLfY312nec3r9yDjI+yMX2YDUKcgNzMg 2Abw== X-Gm-Message-State: ACrzQf1kv48I5JoI21YX8J+ZFM9b0N4iaLiXT63UEnPoWnEu6jjwE5Ug cNSoev++4WxzDssYtp2a6ySrLdxMsqE= X-Received: by 2002:a05:6a00:240b:b0:56c:f55a:65b4 with SMTP id z11-20020a056a00240b00b0056cf55a65b4mr887433pfh.35.1667856803802; Mon, 07 Nov 2022 13:33:23 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33: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 Subject: [PATCH 4/9] perf stat: Move common code in print_metric_headers() Date: Mon, 7 Nov 2022 13:33:09 -0800 Message-Id: <20221107213314.3239159-5-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874816119540596?= X-GMAIL-MSGID: =?utf-8?q?1748874816119540596?= The struct perf_stat_output_ctx is set in a loop with the same values. Move the code out of the loop and keep the loop minimal. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index d4936a502560..115477461224 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -837,11 +837,16 @@ static void print_metric_headers(struct perf_stat_config *config, struct evlist *evlist, const char *prefix, bool no_indent) { - struct perf_stat_output_ctx out; struct evsel *counter; struct outstate os = { .fh = config->output }; + struct perf_stat_output_ctx out = { + .ctx = &os, + .print_metric = print_metric_header, + .new_line = new_line_metric, + .force_header = true, + }; bool first = true; if (config->json_output && !config->interval) @@ -865,13 +870,11 @@ static void print_metric_headers(struct perf_stat_config *config, /* Print metrics headers only */ evlist__for_each_entry(evlist, counter) { os.evsel = counter; - out.ctx = &os; - out.print_metric = print_metric_header; + if (!first && config->json_output) fprintf(config->output, ", "); first = false; - out.new_line = new_line_metric; - out.force_header = true; + perf_stat__print_shadow_stats(config, counter, 0, 0, &out, From patchwork Mon Nov 7 21:33:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 16731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2308862wru; Mon, 7 Nov 2022 13:36:21 -0800 (PST) X-Google-Smtp-Source: AMsMyM6ZYd+2sV8j7ez+kFzQqP30LFGNSbLW5t1NHD/wUj3pxIOdFqoZJjs0SvwCn+gsq7i2ZWJg X-Received: by 2002:a17:907:7250:b0:791:9093:47f7 with SMTP id ds16-20020a170907725000b00791909347f7mr49795696ejc.278.1667856981755; Mon, 07 Nov 2022 13:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667856981; cv=none; d=google.com; s=arc-20160816; b=TsFtQtW6lelN26Rs7t7jnZJDQxSpKyvGTE5FJR5nNPMN7Ffhk4IEv9Pnu1dogWkkYo HlO5g106wy5O9hZ9OF9Oquryf4qUzhWBnQpBonouSrNsCUfKBT5IbOKtjoPnQo4PLO7B 12oqk8YPusWE4jf06yLho4A9HQ00OygwLZXNSl1R5qHAVAVYNEv0TBLasmOmxYzTZ/9v 0UWpRWUSLn+RWxvbCGg2P2UDMjJVuVO4b4IY75Xc5pup/2LFfTLfBmR+qZEt8fTjJsbU pszFZthsUajhQJ+MJ1qqXA3VKh2Xmx2F8hDiD7ar62iikztQBsT3bpCmtwen6mENkRHr sw0g== 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=lU4ETOkJBeJhSBeHInOj845NFGd1yJAeswjzuBLmc/c=; b=uxhoB99yDNRYmjDOdViz1iAX8PwhdWY/Lw/cvVcqch3m6g+gIU+MUp75OeZyc7OJ/v BWTEQ7xN3fT1adsbGljhx46WkdgNBeAl8b2KSJSLjLyV3NUAnBtq6a93kDBmJCXmt1BB gxjKKeZUct/sMQeUtycSp/VOKo0E8rV/3qkPE1hEfZw7Abukn7WhouNYgUA2lzvniDtp 9mfOq1PhDQzBJyfBoK14hJd1ZnZr+bwo+hrtigv4KZVINwHVLrny10oXXvqtBTiie+xj AkuGct0ONdU+ZWDFpVC4VuXL9D+RwCk16L1yJuk/W1LOn2rSwEaiZXbK2RHqGCePfqdl Ki+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eungdUUV; 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 cn25-20020a0564020cb900b004608b4f28b7si8558490edb.106.2022.11.07.13.35.56; Mon, 07 Nov 2022 13:36:21 -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=eungdUUV; 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 S233493AbiKGVdo (ORCPT + 99 others); Mon, 7 Nov 2022 16:33:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233404AbiKGVd2 (ORCPT ); Mon, 7 Nov 2022 16:33:28 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B065B1087; Mon, 7 Nov 2022 13:33:25 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so11115477pjs.4; Mon, 07 Nov 2022 13:33: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=lU4ETOkJBeJhSBeHInOj845NFGd1yJAeswjzuBLmc/c=; b=eungdUUVcH+EwVUeFD1iyPkNP2trdMfx+ha6MJtTRKbg6VneXkw/DV6FfYrf4HNAOO tUvqDOlNAvv2e5ABQRxmLd0WtI2bgfiDFXkb6kOneau3LHHlYpZeF7zVPZsHlUQjMAXn PthKxHaNQkSv14q/YIfOYaZLXnTVUNieDSHXGJc7/9T5WLC0jBVatr1hQs4bKYkFj3D7 l7bv5cH8jljFLkx4RhWF9Q4GWrHD0gVwgVv7TcMV5Zm+gWSC8t8ve5AW7wGZnL1eA4iE VPHZbj3IfngL/oIuUtrUhBzFWTw9Nu1plH8lQTojWe3zx1soCPLaONdqF8YPRjODAma1 Vabw== 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=lU4ETOkJBeJhSBeHInOj845NFGd1yJAeswjzuBLmc/c=; b=TjKiW+Ee6b7OMrWgtoTJE6qDK4mCGBR7S2T78jnncOjio3nrM3T5mf/Ty7zjXLXNaV Bh0aNGNBGHf1WMJ9H3BZTocPkCZtzwBR4bEbAIOZXuzPgR32p//29ef1aioFLGbsRBYE CctsusO/qO0IIEMk6wDfbPpbdc9bWEd+CGPo/BnxX0her2mng4anb/+8Dk8mLfAAqCqE QhycyV6itYwZxNS4DRdfS4M4WaxwrBh4RkZY9ajqP+9531HuuiqwQu6S2TimcuMp0iq0 xanVuWfbo6TOkKif6jc2ysfVuU+bAxs+jOa3OUPyoVEGTyNe849iw79Z9lTd+QxkrdQK +jjw== X-Gm-Message-State: ACrzQf3ABlK5kvklOQJY6obzZQJnHA4iaXfIAsw5gml80yi3QlssbXy2 68ADqJPYzJEawG6y9jnwr+c= X-Received: by 2002:a17:902:ebc5:b0:186:b848:c6a with SMTP id p5-20020a170902ebc500b00186b8480c6amr52209955plg.46.1667856805071; Mon, 07 Nov 2022 13:33:25 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33: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 Subject: [PATCH 5/9] perf stat: Fix --metric-only --json output Date: Mon, 7 Nov 2022 13:33:10 -0800 Message-Id: <20221107213314.3239159-6-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874802744284745?= X-GMAIL-MSGID: =?utf-8?q?1748874802744284745?= Currently it prints all metric headers for JSON output. But actually it skips some metrics with valid_only_metric(). So the output looks like: $ perf stat --metric-only --json true {"unit" : "CPUs utilized", "unit" : "/sec", "unit" : "/sec", "unit" : "/sec", "unit" : "GHz", "unit" : "insn per cycle", "unit" : "/sec", "unit" : "branch-misses of all branches"} {"metric-value" : "3.861"}{"metric-value" : "0.79"}{"metric-value" : "3.04"} As you can see there are 8 units in the header but only 3 metric-values are there. It should skip the unused headers as well. Also each unit should be printed as a separate object like metric values. With this patch: $ perf stat --metric-only --json true {"unit" : "GHz"}{"unit" : "insn per cycle"}{"unit" : "branch-misses of all branches"} {"metric-value" : "4.166"}{"metric-value" : "0.73"}{"metric-value" : "2.96"} Signed-off-by: Namhyung Kim --- tools/perf/util/stat-display.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 115477461224..515fb6db3d67 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -430,12 +430,12 @@ static void print_metric_header(struct perf_stat_config *config, os->evsel->priv != os->evsel->evlist->selected->priv) return; - if (!valid_only_metric(unit) && !config->json_output) + if (!valid_only_metric(unit)) return; unit = fixunit(tbuf, os->evsel, unit); if (config->json_output) - fprintf(os->fh, "\"unit\" : \"%s\"", unit); + fprintf(os->fh, "{\"unit\" : \"%s\"}", unit); else if (config->csv_output) fprintf(os->fh, "%s%s", unit, config->csv_sep); else @@ -847,10 +847,6 @@ static void print_metric_headers(struct perf_stat_config *config, .new_line = new_line_metric, .force_header = true, }; - bool first = true; - - if (config->json_output && !config->interval) - fprintf(config->output, "{"); if (prefix && !config->json_output) fprintf(config->output, "%s", prefix); @@ -871,18 +867,12 @@ static void print_metric_headers(struct perf_stat_config *config, evlist__for_each_entry(evlist, counter) { os.evsel = counter; - if (!first && config->json_output) - fprintf(config->output, ", "); - first = false; - perf_stat__print_shadow_stats(config, counter, 0, 0, &out, &config->metric_events, &rt_stat); } - if (config->json_output) - fprintf(config->output, "}"); fputc('\n', config->output); } @@ -954,14 +944,8 @@ static void print_interval(struct perf_stat_config *config, } } - if ((num_print_interval == 0 || config->interval_clear) - && metric_only && !config->json_output) + if ((num_print_interval == 0 || config->interval_clear) && metric_only) print_metric_headers(config, evlist, " ", true); - if ((num_print_interval == 0 || config->interval_clear) - && metric_only && config->json_output) { - fprintf(output, "{"); - print_metric_headers(config, evlist, " ", true); - } if (++num_print_interval == 25) num_print_interval = 0; } From patchwork Mon Nov 7 21:33:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 16732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2308923wru; Mon, 7 Nov 2022 13:36:31 -0800 (PST) X-Google-Smtp-Source: AMsMyM5/FQ1BeYZ95Glrcvs3jptjKOzWwu+1peVTckSZjN00ZSSSAXzKAlD/qXv3w4YvWleeETBb X-Received: by 2002:a05:6402:518a:b0:464:5ec3:c5a with SMTP id q10-20020a056402518a00b004645ec30c5amr21324717edd.90.1667856991131; Mon, 07 Nov 2022 13:36:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667856991; cv=none; d=google.com; s=arc-20160816; b=y4TSXTTcsoaO3CQkXuf3OrlfCS2Mln+H6w2CIa20dlpkPhiqr4WVUoB55nyFHDHWAk By1Gd0k1BHJ85A8sIJNvGTpdm/O9KTvTAdji57HMHdYLMSxTv1/QqLxYW9OjHJpme73T 5E1PxKzUCUhmnz0uSSzCHdyAST6u7mG91jg5c2E1w6Y/4RR1FrAIoGBqW5O5UJAQL2Iz WMLyGiR3JXh5Tc+/hNBGayh3MRPrEIGmxpJ2cLf4AfDbRq6ozGhwGgYCmqJbjo2O0Qiw Cj/j56dMg9kRfQ+kE3oOXrHy8fGDTzLzXt6YDlipeHYTL8WwuBj/DGHnaobvHoFH4Yl9 uIiQ== 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=uEwG62U2ocTRAE+zcAm5Rx1np9/Wr63UQVaH+5ioR9I=; b=QkOzUFbc4c1+PnZO4pLuPsNmVaC1x394a9nx0J37Gv5hFSWg+uRZlseD6BPa424LvZ HI6OGDJdFeTl1Y5Com+G0aGjkkPt80pSFHQAo8QYj4HxNKXpKGcPUH96RvQMOzdO0h9x Aw8ZNeXt4zOgMWTIUamRNMqhwPzju8oEP0RLIi68rcIC1wKbP2yZsAE864Nd+9fjkgBY l3gIG1OCeRpS1+e6my3MBYXZ5XXRPcPmqVcB+Igx3z+xjK3JGCibt0P4kOuHcPiOX+m8 TdbhzvJNe+2PPSfQhUp6882bxrmVFepyWv2POa0i/7PWMG8uw9f3EBNEuaD6o4ehMk7W eHqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Hc+KCEIH; 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 ds16-20020a170907725000b0078e06df0d29si8200363ejc.705.2022.11.07.13.36.07; Mon, 07 Nov 2022 13:36:31 -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=Hc+KCEIH; 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 S233370AbiKGVdr (ORCPT + 99 others); Mon, 7 Nov 2022 16:33:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233400AbiKGVd2 (ORCPT ); Mon, 7 Nov 2022 16:33:28 -0500 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E59BAB1B; Mon, 7 Nov 2022 13:33:26 -0800 (PST) Received: by mail-pl1-x62e.google.com with SMTP id b21so12303325plc.9; Mon, 07 Nov 2022 13:33:26 -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=uEwG62U2ocTRAE+zcAm5Rx1np9/Wr63UQVaH+5ioR9I=; b=Hc+KCEIHI0yjOOxQWtJwjkjcfiZXxl/jTVZifw/Fon9yqTKXtKv5u4DbvdbdDg7b0G kG8o1emeN56chtVXqrb982qGiSNzp6P3NbXfUnbckq0ANeuDN0wppNwD3xQ8hwOtMNNP jwLuRjW0Jab1wVy26+mMwtVkZWLgj8c/5rtJ2OB2wJc/HT7E/JOe9wAXDm3ZTXd7mZKC kATtnMx12FaYWV0jgws7UYZWrWyxSZNjbVW6m3EaXFE+58au9jrY1kz0hkdR+tDplIDh 4kKLsAadGt7rZXfbu1QFAbgkvLbeUVLIFa1aHcdq9aDMZmqGE9m+/XC6BMp2PlomTXff Bwxw== 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=uEwG62U2ocTRAE+zcAm5Rx1np9/Wr63UQVaH+5ioR9I=; b=VwnpDz7gviu5bMT5MQ4ANzsk1SfuyKfqbWY0UeZ5ZX5TyT9b9ArFhMBnRTPXkjXoe6 xdVnCafIM4ozPsp63rXmVvKUL44hEBWMEY+uYYWLWEMJpxpxYnIZLL4wg7ktH36lFV+f Deprk4l3OKl0NYw8TtevbSxrFJxmvs/YjUjQbrIRDCH4B353GMvb0zz5me9bVgtCT1fd k+5onsCND3m/UNLeJx8Iue8HnKexYjIVmH0LixKPANRh182no98OAGAyx0WKUnj4GvSZ qNnzkf9BLNR+Jw8cCG0WR4seh2wgyJz35DPIu0AzS3jUqRT4Hx6TK6E/1olrYHP8Wi6p l6wA== X-Gm-Message-State: ACrzQf3I52dlikkKv/1pbCAfnYH4KYGpY69szDPERkuMWyZiMbXPTdXj JkrXneT6dtkvC+fuqoevOro= X-Received: by 2002:a17:902:9a41:b0:188:50c2:89cf with SMTP id x1-20020a1709029a4100b0018850c289cfmr27538355plv.34.1667856806361; Mon, 07 Nov 2022 13:33:26 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33: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 Subject: [PATCH 6/9] perf stat: Do not indent headers for JSON Date: Mon, 7 Nov 2022 13:33:11 -0800 Message-Id: <20221107213314.3239159-7-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874811934027774?= X-GMAIL-MSGID: =?utf-8?q?1748874811934027774?= Currently --metric-only with --json indents header lines. This is not needed for JSON. $ perf stat -aA --metric-only -j true {"unit" : "GHz"}{"unit" : "insn per cycle"}{"unit" : "branch-misses of all branches"} {"cpu" : "0", {"metric-value" : "0.101"}{"metric-value" : "0.86"}{"metric-value" : "1.91"} {"cpu" : "1", {"metric-value" : "0.102"}{"metric-value" : "0.87"}{"metric-value" : "2.02"} {"cpu" : "2", {"metric-value" : "0.085"}{"metric-value" : "1.02"}{"metric-value" : "1.69"} ... Note that the other lines are broken JSON, but it will be handled later. 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 515fb6db3d67..25f67fb37f6d 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -851,7 +851,7 @@ static void print_metric_headers(struct perf_stat_config *config, if (prefix && !config->json_output) fprintf(config->output, "%s", prefix); - if (!config->csv_output && !no_indent) + if (!config->csv_output && !config->json_output && !no_indent) fprintf(config->output, "%*s", aggr_header_lens[config->aggr_mode], ""); if (config->csv_output) { From patchwork Mon Nov 7 21:33:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 16735 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2309120wru; Mon, 7 Nov 2022 13:37:01 -0800 (PST) X-Google-Smtp-Source: AMsMyM4vXz5YfsG/ijlFNAAJa4rq+3Y86uVsT811a9k+nIbbmSvL6jt7fsZQpsV9XiZpnjYBymSU X-Received: by 2002:a17:907:744:b0:741:36b9:d2cc with SMTP id xc4-20020a170907074400b0074136b9d2ccmr48142035ejb.613.1667857020931; Mon, 07 Nov 2022 13:37:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667857020; cv=none; d=google.com; s=arc-20160816; b=Tz8kSN6M4Ga5RRcK9VzHZ/qhzK5C7Zrp1JsbMhfd5zaJiIvRXyx1c8dVFQ9DrLmz2R 2+9Uh6O41dRJ1k8c/jyWtjYdCg/71ePdXRGqkebeYIWr+3aOSRzK1RVqLRJ3kOAA11jf Y/gPw8fiFzOMaONXIzxOjQyQFEcoXRvtuDxDWGDzS9ZOLcZmqVeE+N6SGBMvQGZNEbZH byaTBPHimr5ZbrODgSmz3+lSyLfkqaNVy5dq2ek+3Z/qGsWqiZ5K0GLIe+9v7anyujFZ 9Jq3Kucc5Bazo1CfOynDHef9G4XR9wx8KNf/On7Sd5lWbs23Ri3OcWeWQuHMaY9MPk89 UCRQ== 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=mWSDNfZ2wImW4xPzQ9jDtU6vpg7XH7BhaLU95Jwpr2Y=; b=oj0nCoCJUs5DUrM4Arf95NuN2UaSrZAVnXgsHhzmCQmmceGWQxKMt+u4+P4VlFaGuU p1/XH24FHQt93ErL3VVHlYEUfm6ZFYAM4osH/bTNkERrmUMOxvP6/laUXZ7ZYWvjBth7 DWriOJYsq5QIK7bOrWF7k4alF5R0SfXDb0r1eb/qbVn1sHiR2Ju94Gt4GtM8+a/pbDb/ 0hrxDst+DliGq/z4pFzN+bNljzVUZStHwfCZ+ooneMK8zfkI7rRdjsd//gxB0G4Ss2BP tBC9kt/kwBERMHyAubsYOvldySKY6mQEYQAypoTAEkZZV0TVXVj46MSsGyxNnWk+Rt87 +xSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BqNGbFdH; 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 h3-20020a1709060f4300b007a7fc67c880si6904111ejj.71.2022.11.07.13.36.37; Mon, 07 Nov 2022 13:37:00 -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=BqNGbFdH; 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 S233571AbiKGVeC (ORCPT + 99 others); Mon, 7 Nov 2022 16:34:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233510AbiKGVdp (ORCPT ); Mon, 7 Nov 2022 16:33:45 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35EAACFC; Mon, 7 Nov 2022 13:33:28 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id y203so11915803pfb.4; Mon, 07 Nov 2022 13:33: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=mWSDNfZ2wImW4xPzQ9jDtU6vpg7XH7BhaLU95Jwpr2Y=; b=BqNGbFdHwFQxBhVekowAdOUNERDGn2+AWTAyyiZCzt5B/9GCH0SUZ66R7ZrHk9eGZf BfkM9JDgUIkojWuYTxAGCA0Lpd4t21URmF/n/ybGbQaCggsJgy6F7/EbwPflwodxtq9Q 8queCZb++T6Aqvi9QoVSdlpoua1q/gjjTpRJuVuq8M4f6JO5KPxJboIil3/T0bbZ3imc 7M6KNqczmjl/QRcX3jMKvHFQA+rtlEsdd+LMI59y49ANRrEv3Wdswe6XfrUQku825XaL PPObpYYXhLJE3ocialaJlNqBvAnxLpmAkDSRCqva3pCXPoviaatiREdqAAsJK1/FLa08 yq+g== 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=mWSDNfZ2wImW4xPzQ9jDtU6vpg7XH7BhaLU95Jwpr2Y=; b=qYiBIrbG+w+dSjXp3xiEsesSVaNlwoEU32EtRqdQMyWRwFtN5accz9nlui58vssFJM qQB3a9l/0Eakq9r4UvIey2nCDWuSnoNv6HesZNhb1urN3lSB7qek3ooNBdXO54byxZkq f0hG9TNo6h1Y9k0ofQtY7aCsXYsjZYrck8ur345gglh3rdg1kLjA8PnXfk00KeMq8h8q ypGmX4GVXOjZu1F81oCXVEVXQe68j5mDhz+ZRJlI2TQTBO/itaQgRTmjGzxuJMOlTQzq XpuWeO3ewE0ibObd6t8bO9SbuPkyZyqNz355OenoRE9BJPND6bIFg2roOKvtgs7Fwzlp A2hw== X-Gm-Message-State: ACrzQf0mbs/Dl82bhzwvLopK6HzJ6RMAT3pzODQ2sNqbqo6KqeyjOPsj 11LLWGqi9AsriLERay+ExJ8= X-Received: by 2002:a62:860b:0:b0:56d:a2be:ebe4 with SMTP id x11-20020a62860b000000b0056da2beebe4mr873244pfd.28.1667856807633; Mon, 07 Nov 2022 13:33:27 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33: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 Subject: [PATCH 7/9] perf stat: Add header for interval in JSON output Date: Mon, 7 Nov 2022 13:33:12 -0800 Message-Id: <20221107213314.3239159-8-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874843230701235?= X-GMAIL-MSGID: =?utf-8?q?1748874843230701235?= It missed to print a matching header line for intervals. Before: # perf stat -a -e cycles,instructions --metric-only -j -I 500 {"unit" : "insn per cycle"} {"interval" : 0.500544283}{"metric-value" : "1.96"} ^C After: # perf stat -a -e cycles,instructions --metric-only -j -I 500 {"unit" : "sec"}{"unit" : "insn per cycle"} {"interval" : 0.500515681}{"metric-value" : "2.31"} ^C Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 25f67fb37f6d..aab2576bd40f 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -860,6 +860,10 @@ static void print_metric_headers(struct perf_stat_config *config, if (!config->iostat_run) fputs(aggr_header_csv[config->aggr_mode], config->output); } + if (config->json_output) { + if (config->interval) + fputs("{\"unit\" : \"sec\"}", config->output); + } if (config->iostat_run) iostat_print_header_prefix(config); From patchwork Mon Nov 7 21:33:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 16736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2309144wru; Mon, 7 Nov 2022 13:37:05 -0800 (PST) X-Google-Smtp-Source: AMsMyM6PsfljI5jHVshWTTHen7jvcMPMuiL9Kw96Uw1WTSJ03g5bN6+iGlVTflM8JHX9zufr/Cx/ X-Received: by 2002:a17:907:7626:b0:7aa:987f:4e8f with SMTP id jy6-20020a170907762600b007aa987f4e8fmr50271169ejc.204.1667857024959; Mon, 07 Nov 2022 13:37:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667857024; cv=none; d=google.com; s=arc-20160816; b=bPuM1S5BXjgMlCBl4BfWux1XQxhao4Wy5sEgsSy1FyPhZtM9dpJcN019gy8MPGf8+k z0jZaMMZJ766rjk59h0zjbxafcxgp4OdN6KGMiz5qXMGKh5wwNzQG3QhTNPFtWn7AvKn /h7sSFjJ0b0QkRa+vrf67jWyKoOHmu2eoaipsiQjmHX7POJwAho4IWxSgROs6R3YPHya fwxf5JJ2YNHKEN3x0BkmuB2smSuzlTcIkFwtMdUWlY9o88tB0M4EUSCXqffP62WyCXh/ YvKIQ7ZNaxRrT0LO4oSiZOqx1Rx2oPvnzmhU07uftClC70CskTeEvRk6BjQN41gZsflK HnDw== 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=F3kWpBC1NLbl49EVyM6kuTlOZ/tQuDbS9uiyiK9Bcd8=; b=LDUlxod7ViWAsoA9ds6vBfdPq8Lu99RouzyIduKFFo8zoSqcYJrvfb36b1xixVqT2S EeiWbjv7SsHwCnNa6ANuqPsFC3CLPsBmbS0TElae7aWNMynh3sdXV00asImTEo2dxksE zs9FD4JD8t/uHJDR1wVyZuENfTh/ewaXWCtNcU2Hb5+Rg7O1Yvv1g44+c8s3YQ4Dw6vp Awz+6cClAiE9//cmpL4VoguYOp3WPTVm8bQBDy6ZIJmcksGG8i/mR9wXxVpWuNTMvmgK KZLFWf5tYbwWrtrjOPi9rA9p/dtRCPZI9g+a1i7jH7rt2RVvETwlTcpp7HhqJbjusqY+ VCYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FcSbzoNL; 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 hv13-20020a17090760cd00b007add164bc81si7915329ejc.222.2022.11.07.13.36.41; Mon, 07 Nov 2022 13:37:04 -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=FcSbzoNL; 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 S233584AbiKGVeF (ORCPT + 99 others); Mon, 7 Nov 2022 16:34:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233514AbiKGVdq (ORCPT ); Mon, 7 Nov 2022 16:33:46 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCD1F2195; Mon, 7 Nov 2022 13:33:29 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id z5-20020a17090a8b8500b00210a3a2364fso182795pjn.0; Mon, 07 Nov 2022 13:33:29 -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=F3kWpBC1NLbl49EVyM6kuTlOZ/tQuDbS9uiyiK9Bcd8=; b=FcSbzoNLCo8OoQLRTy1AojjTte1miTZf2JSnw5QprLwVDsrGsELCcwIEOdIuBoGpuI v5+QS0SkLzYXJtsLG8JJ19RCg1oSgUJNg6OMEKclucZVbPXotCqihsfZWk9GZfFgIqWG 0Tl69ccf++bhhstTYh68opUzCqfz0nKNORwqH72toYynd+9Jvq6gLdU+gMo7f7qyAQuh 5G+CqBcYQ/S6LR6b0mn8ceudSUEWwh0AXmK31d4feFd0YjHjQpivKkBuzRUyNhc4EFiv wCaAwr6Q2pvBvaNONSW5yJSEmo4bYtd8WrOoqJLnYK/xo4Z/eGoOTlgvZa8MJpV7pZu9 HUxA== 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=F3kWpBC1NLbl49EVyM6kuTlOZ/tQuDbS9uiyiK9Bcd8=; b=x4KYb1PdRWFTJFwHweqkRg2bJdPCyxNasrfpt8O8tTyvHeoi6n5JOiPNMnsjfVlLbV G8uiFLTnhPMQlufccdSENX4Z+1kUQeqsg2W96qtfR3UZ/WJ9nApnyTNXU5Qge13mYk6N 2OhkxzedUVuuqiP0Ije5l9SfcWkiO5ylRyz91VYjo2Li0t1InFsCdd2Rsn9meL90t1Kp 3E72IveYcUFRIqPanYGUEpZgNfjaWrkFiWQh2M1DjLkjnT5R7lx0HrWkJDPuel3SDEzB Ykc/KhlZ8uG9IMwcL7ZWtTOSKJ3Owso+1JfPIMPo/85mc4Zeiq8QjWZKygEg3R0LRTo4 rYEQ== X-Gm-Message-State: ACrzQf1/Fwohts8nM9NW4IcMleU+elBHttkM3z9HpsiqbtnPUbFa0eBz eBcPoblCH/eMIGPuExFthQM= X-Received: by 2002:a17:902:e846:b0:187:2127:cbb with SMTP id t6-20020a170902e84600b0018721270cbbmr44249969plg.125.1667856808976; Mon, 07 Nov 2022 13:33:28 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33:28 -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 Subject: [PATCH 8/9] perf stat: Fix condition in print_interval() Date: Mon, 7 Nov 2022 13:33:13 -0800 Message-Id: <20221107213314.3239159-9-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874847782184430?= X-GMAIL-MSGID: =?utf-8?q?1748874847782184430?= The num_print_interval and config->interval_clear should be checked together like other places like later in the function. Otherwise, the --interval-clear option could print the headers for the CSV or JSON output unnecessarily. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index aab2576bd40f..a10af26c26ab 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -902,8 +902,8 @@ static void print_interval(struct perf_stat_config *config, sprintf(prefix, "{\"interval\" : %lu.%09lu}", (unsigned long) ts->tv_sec, ts->tv_nsec); - if ((num_print_interval == 0 && !config->csv_output && !config->json_output) - || config->interval_clear) { + if ((num_print_interval == 0 || config->interval_clear) && + !config->csv_output && !config->json_output) { switch (config->aggr_mode) { case AGGR_NODE: fprintf(output, "# time node cpus"); From patchwork Mon Nov 7 21:33:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 16734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2309061wru; Mon, 7 Nov 2022 13:36:52 -0800 (PST) X-Google-Smtp-Source: AMsMyM7hMY0apAr7/qlCa98GTRamP+LyUfg+6qdKUaufWJhWM2rD+lGK1+xKpdeGQbHQguMhqXoZ X-Received: by 2002:a17:906:6a13:b0:7ad:b598:9a52 with SMTP id qw19-20020a1709066a1300b007adb5989a52mr49271016ejc.205.1667857011973; Mon, 07 Nov 2022 13:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667857011; cv=none; d=google.com; s=arc-20160816; b=jc0+eI9Vq5TGrP+zgjDdAZ5+4MamJ/Yau6YzTOzRqfAj+7SQ5PV2+ljKMtvCypDSgk l5zOlMG2YkbrCp31g4b2XqRhjAmILABnko6XtoUk7CLQ4onGZVL2JtMKrOg9tcnr1fMd Nj1AuRdNlfqiNLKZW8KKPx/cdOZQ/yoljGE0H+f14lm/Bs/9wizHkToj1rRhPtoa43dO bqg1ZvbTjN0c4ZRkZ+XXvBTOVLYV7vTAe1RANIaWK19Nf6Ez9XVIPnz2ijzOPD9hHfL4 QrsuK7MLzlM6JVl0dxqSVikzm/5tjOkCZRiYp3m6yv1EUrtUEXGgSfffu9p1SOPOrF4T hwKg== 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=tWKNNag4dwKiJExBOGweLXLb/8nFtKqU9STsZaykkGI=; b=tetaZwZT540IK6oBewcDLwOoPJj2isI4RN+dJMNFQZmkbIjkXxGKGRTsWBKxnBsbNH 4+lcWwUShN6NA/y9M+1ST+6PMK4M2nEgraJbm2owTm6x2MwmtBNxtm6VdMgZ1JQnSx4a FI3F8934eTVw+reR8tZukWcAT3LaMGk4j+CpNoufSeGmKAd3abVlEimqH0UCL7JBshQ3 dn4hAu8UyRpElbWI8CRruVYOGPp1C28kRd+Yq1YzzLrdmrKpgK//QOtMld/ot2W/nu2B 3kYR29A9Ilxh+JX1zK7GbcRD7eaMAvSqgz6n4d9cDXv1Eq8Rmw4TwPKwmJXQ3VUxzXI1 zcrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=nGjJh+u1; 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 b4-20020a0564021f0400b004571c47b13csi9291618edb.418.2022.11.07.13.36.27; Mon, 07 Nov 2022 13:36: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=nGjJh+u1; 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 S233490AbiKGVdw (ORCPT + 99 others); Mon, 7 Nov 2022 16:33:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233483AbiKGVdk (ORCPT ); Mon, 7 Nov 2022 16:33:40 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D567DD2DE; Mon, 7 Nov 2022 13:33:30 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id gw22so11861576pjb.3; Mon, 07 Nov 2022 13:33: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=tWKNNag4dwKiJExBOGweLXLb/8nFtKqU9STsZaykkGI=; b=nGjJh+u1cT5OcLzNsc5z5NXn3K+ih9o0FvHL2x/uWnazjn2jGmuuTlQD3O1KmcteJm UygjpYZP8GJ+VoNgshCb4dvhzIir2Je/de7WZhyGFrQyAIEE9M6Jr+G7IxwS8kVsgE2U 3CGxv/94tzRcBIgMzedh6NJctPvssF7nWKmVLVecWLC3HiPSpLMG+VDinxKsId/26+KK 5OG5//yDxHa507fdLJo7f9lHIZpl5/dPWVy5Id9vnAC+8IRRjFKnJyMqqS7O/LcU2oTY HumI4hF0T6ie/juL1fKJVCJ9R36t8HNl8I7vfyKEjGhiWLRt4szY+KnbANh1IL3pn4Ew aDzA== 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=tWKNNag4dwKiJExBOGweLXLb/8nFtKqU9STsZaykkGI=; b=kUB09Y9nXnBqTv8Hx+TZY2gl39BbaKWXm6ptpTtUFhKJXy+Yw3BvBRLA4uXzRgV/S8 YNNavW2sUHcxq0LYS/G7GJufJmN++WluXO1xKBq+Y1NGhkSMDIOnqy0i8AC8AjCpeBcd mpGItqNbJfIe+XNP8DhGKz7tL4Gg2glpi5Dd0uExvNrrbq0+TWGOPLV2wYQ14kefjQl4 YB2VUkPYEwrjhJHVWXNQqMXaq69dfLYjwh2cRZL4VU35nkw+8MBnoS8Vn7+/3fmkaR4g xHPHd6Jc3GywxtXpI0e5JDodrUCPLVH8EQHYFUYsb875qkxZif3ZkT4lB67J7+D75jn2 GWAg== X-Gm-Message-State: ACrzQf20+4OvLtXvMVpKeeHcRwwtrTwj3BjiXE5s9vsWcUVf2+NukjfZ hJRDKP5ATo5KgipkA/z1Zjo= X-Received: by 2002:a17:90b:84:b0:213:de0c:1253 with SMTP id bb4-20020a17090b008400b00213de0c1253mr45777292pjb.74.1667856810221; Mon, 07 Nov 2022 13:33:30 -0800 (PST) Received: from youngsil.svl.corp.google.com ([2620:15c:2d4:203:5850:5958:9c77:f623]) by smtp.gmail.com with ESMTPSA id a1-20020a1709027e4100b0017f5ba1fffasm5366413pln.297.2022.11.07.13.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 13:33: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 Subject: [PATCH 9/9] perf stat: Consolidate condition to print metrics Date: Mon, 7 Nov 2022 13:33:14 -0800 Message-Id: <20221107213314.3239159-10-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221107213314.3239159-1-namhyung@kernel.org> References: <20221107213314.3239159-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 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?1748874834075906297?= X-GMAIL-MSGID: =?utf-8?q?1748874834075906297?= The pm variable holds an appropriate function to print metrics for CSV anf JSON already. So we can combine the if statement to simplify the code a little bit. This also matches to the above condition for non-CSV and non-JSON case. Signed-off-by: Namhyung Kim Acked-by: Ian Rogers --- tools/perf/util/stat-display.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index a10af26c26ab..4d3999673dde 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -600,9 +600,7 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int pm(config, &os, NULL, NULL, "", 0); print_noise(config, counter, noise); print_running(config, run, ena); - if (config->csv_output) - pm(config, &os, NULL, NULL, "", 0); - else if (config->json_output) + if (config->csv_output || config->json_output) pm(config, &os, NULL, NULL, "", 0); return; }