From patchwork Mon Nov 14 23:02: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: 20068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2408445wru; Mon, 14 Nov 2022 15:04:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf5u+zRofZil0ggM6lm+tEpl/PuGY+toV4MKLn+4/KtIVItyCdNaJnk+v7ZL4onn3W1yvvx0 X-Received: by 2002:a17:906:7e4a:b0:78d:a136:732b with SMTP id z10-20020a1709067e4a00b0078da136732bmr11489446ejr.135.1668467092439; Mon, 14 Nov 2022 15:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668467092; cv=none; d=google.com; s=arc-20160816; b=wZgp1CJIH7JLQ2ffEoviS8Ybpf7+bv7FJLqkaSU8Kh4zfsKZ0NUMlpEDXcGxOUnNiM 5HZ8RtbTpHUmmBtEGHKX4SbV54GsU7nM7iFdXlO5lXEk7m89AMKPWGK+KQJAWVeb/bAJ IAVPZ52qM2FWfFHKWL0vbD1RIHFq5ZmCwQyczh3WhZTFDTDn0Pd6T3YsY3J67MGqYP90 +gmhL8HExLHyqnz8Q12IFAvC+JkimwSl1X6d0AspqYEgIxFi4lMmQ2lNcf4SEJgtLPK1 xxCoffp8fIxb5Fym/IVdk8TlDG5roa24JTFKF7CanTkp53wqH0e8uzAN7ZpzgMphZaJH h24g== 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=nd5GkeCeE0yxKOMovgVohdgD8iFx/xVnrv4/oHPrZuI=; b=DRuhTFSiqlu4xuWGGhJ1Svz0EA/tjE6WwLzvx9Hq8MeM9tIJhyInY4d56FXihcA35Q /eGuxIassJnw36wR3EbGvdf+k6kuIhhUGjMM6tqaLTxqvr46Tk+pXIDpguM2FlAMBdtS Y6YlOFuzFUcnylSGNb9SLRFiijh+4zc+Huw7lKxWep3rf7DCEkz3geWo754t6Et4HW7T JXmGcsJTNYMliQaV0kXZ+Knq4faEeKCuzedU11MxYvXqwkcMpHRKCWk1mnNn6EWdZrvg OGHya2ubqgEtJBoUeGeL1CQ25pLhnxRj66rASmfDLHcIjKLEgUGLhepNUzA4HDVz7mEe gpMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=R9Jluqc3; 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 hp17-20020a1709073e1100b007a7d37e4681si9418243ejc.845.2022.11.14.15.04.28; Mon, 14 Nov 2022 15:04:52 -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=R9Jluqc3; 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 S238009AbiKNXDP (ORCPT + 99 others); Mon, 14 Nov 2022 18:03:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237904AbiKNXCo (ORCPT ); Mon, 14 Nov 2022 18:02:44 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9975519025; Mon, 14 Nov 2022 15:02:36 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id 62so3234502pgb.13; Mon, 14 Nov 2022 15:02:36 -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=nd5GkeCeE0yxKOMovgVohdgD8iFx/xVnrv4/oHPrZuI=; b=R9Jluqc3uYSYzKHR1fx/DQAfhMUewFc9fiC60GFBxnsjXYZkyw27kmZxriO1IPJEyG 4e+CztJ/pkBanz8uQhHc5ZYf3wPQb+H+NfCf5EXu/ZYroj3hs5NM9BaXzsl74zxFuo6P QUEw43FDRea5+HjJG0Jcj4Hvk5D7McLUPVRo9n0t78TfDN3OtQa8DWIetDNZJn5FvqQw z6MjJhqvXl2W4ZG1ORqTp6VDgzllTvfeDP56yHVB09PiL+b57k2cJ31Alr0srHUTCrnZ gdB4DbQYSq3CSECBSNk2MxLkogktK+VOSo8R+zvEQdFIPdPNTOCmcwRTwTFJ+2eBvbr8 gSvA== 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=nd5GkeCeE0yxKOMovgVohdgD8iFx/xVnrv4/oHPrZuI=; b=fz+8AvgpflIzVwencr46DblQV5RF4HKFpBYASRGhNYo45MthjTgnJLyOJ3Imbzxbje Bz1WbDyxIWet23c7xoeNLAPK39g6gT/y8pZ1gAAyUOGKM1qRWjkMyZltX7DfF3bq0Xkb QGjbrr7558MYaTUXVyiGFPlyy2zTzXpIHnEL7wUC3mK4j3lBBD/bReQ6jLs9813ppyU5 hm891Uw+HObcyqO0F121MAn6spW+ch1Ep5id4evubM+mmPpFlusgjz8ii2n6ZTT5RNwS n7+21LmnjYE9rF15nzDBrJ+IDLDr6i9tpHgd1tEXyXLan0bpJ+rvQHXYxX65SPCek+YF G5oQ== X-Gm-Message-State: ANoB5plBcDihdRWkT/sOSDr0pGdyVRVkO08NZ1Ojatk4giaxwJIYB/PT SNT7spFELdJDgkpRRswya1LvC/aZ99g= X-Received: by 2002:a63:ce04:0:b0:46b:2493:14ad with SMTP id y4-20020a63ce04000000b0046b249314admr13671274pgf.274.1668466956065; Mon, 14 Nov 2022 15:02:36 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:cf9f:e038:c19b:797e]) by smtp.gmail.com with ESMTPSA id 132-20020a62148a000000b0056c814a501dsm7534724pfu.10.2022.11.14.15.02.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 15:02:35 -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/19] perf stat: Split print_cgroup() function Date: Mon, 14 Nov 2022 15:02:12 -0800 Message-Id: <20221114230227.1255976-5-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221114230227.1255976-1-namhyung@kernel.org> References: <20221114230227.1255976-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 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?1749514549739624237?= X-GMAIL-MSGID: =?utf-8?q?1749514549739624237?= Likewise, split print_cgroup() for each output mode. Signed-off-by: Namhyung Kim --- tools/perf/util/stat-display.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index a230f65efa62..af2a561eb20c 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -106,15 +106,32 @@ static void print_noise(struct perf_stat_config *config, print_noise_pct(config, stddev_stats(&ps->res_stats), avg); } +static void print_cgroup_std(struct perf_stat_config *config, const char *cgrp_name) +{ + fprintf(config->output, " %s", cgrp_name); +} + +static void print_cgroup_csv(struct perf_stat_config *config, const char *cgrp_name) +{ + fprintf(config->output, "%s%s", config->csv_sep, cgrp_name); +} + +static void print_cgroup_json(struct perf_stat_config *config, const char *cgrp_name) +{ + fprintf(config->output, "\"cgroup\" : \"%s\", ", cgrp_name); +} + static void print_cgroup(struct perf_stat_config *config, struct evsel *evsel) { if (nr_cgroups) { const char *cgrp_name = evsel->cgrp ? evsel->cgrp->name : ""; if (config->json_output) - fprintf(config->output, "\"cgroup\" : \"%s\", ", cgrp_name); + print_cgroup_json(config, cgrp_name); + if (config->csv_output) + print_cgroup_csv(config, cgrp_name); else - fprintf(config->output, "%s%s", config->csv_sep, cgrp_name); + print_cgroup_std(config, cgrp_name); } }