Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6225136rwp; Mon, 17 Jul 2023 17:57:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTWqTBk1kuhRduNrrzM29VHYhbtGoisAM5CuZ86uUA+QXqq5UThoQHXzNZ+ji+/APqk1Ra X-Received: by 2002:aa7:d34a:0:b0:51d:9ec4:9616 with SMTP id m10-20020aa7d34a000000b0051d9ec49616mr12245339edr.28.1689641853542; Mon, 17 Jul 2023 17:57:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689641853; cv=none; d=google.com; s=arc-20160816; b=iAQ9lNchKzAlWaJeeaUMvAQLf8VqKKbEqk21rhWV1pI2gTmFen6fCtHhnmxyuBk+ui pK7sS1kcRfY0+1T0TOxzcThYCry43G1Wu5EQvyc8+oR+KVLPZbNyHx4YLCsdqF9Kkp6W 9ivByOIRpgwphurD+6Ep9xDKHzpfDffAdpfFHhAVxc9bgWL8AYQzE4bAkDY9aEf1Rezj Y3ljwTH2/XuFi/17Yz51jSmIo3IT8v8z8E9WDJpOxD4w07AyKG+YWz88HVTxVmHUSyLY TF4x9g650HgQHvd7Sp3YnGSxqOQRLeOnp5wNFMkyaImyUWvCpVuBWBHVgfGggVLVehTD FoTw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=5A7RBP0ulBeus/Dr/u1dt97uJhS/urrd6iaA4GMRuJs=; fh=jyhmAT41mlmXtom5KRTtMY7hN3mYjiqDsUk4+KRnO6w=; b=w+gKhNOFlhNZco2qveHkHQCj/AvmsZ0qn6JvW5bGyrLkuRREufuOMz8Y38xW6xVbFR uoN+nozyrQGgcs4IHsKggagIazh7hTEcG4FzuGUWYonyM13dTZG7K/6Y2UcR4I7QJsnO vJLQ+ptdg4ubGT1S9phQHfL/+MKOskNIfMav2pMrKnIoKcWFvHSbktPar7Hoo8ySWQk5 6s+7PZkWww8jk7kj6lizruPxF9ToCotbYdDh1/0WpVKepAUlJcNxVwAFI+lJxLBujBvq HF4gE/bRLmQSNDzxta12fSh39/oGuFoojNNMnWw+pQqlMOqqmKpySODlwcaCHAkiIBZY JLag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=UgCL6Bkr; 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=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z26-20020aa7c65a000000b0051dff4f3c97si415799edr.132.2023.07.17.17.57.09; Mon, 17 Jul 2023 17:57:33 -0700 (PDT) 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=@cloudflare.com header.s=google header.b=UgCL6Bkr; 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=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbjGRAHt (ORCPT + 99 others); Mon, 17 Jul 2023 20:07:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229852AbjGRAHr (ORCPT ); Mon, 17 Jul 2023 20:07:47 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265EBFA for ; Mon, 17 Jul 2023 17:07:43 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id e9e14a558f8ab-345d6dc271dso27276355ab.0 for ; Mon, 17 Jul 2023 17:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; t=1689638862; x=1692230862; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5A7RBP0ulBeus/Dr/u1dt97uJhS/urrd6iaA4GMRuJs=; b=UgCL6BkrsuqpYPHxFkIh7zo+xkSqambpQ2uzj0Pg09bsPkJJX7jsV1Sn5smi9o64Br FAg6QOInWJEiVzCdKJIdaDLsWpeWUe4LSGtrdYEPuN2wfLY1xbnoe8Qczsx8odrHVXJf qW2uFvPRufkQ/RB1HOGjXOU+dn9XvN3Rp8Mtw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689638862; x=1692230862; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5A7RBP0ulBeus/Dr/u1dt97uJhS/urrd6iaA4GMRuJs=; b=joKduxptK89EZWHSDM/bbj5F8EkM7Eb/EtaH2Ucb0bv/fRtnoMAaan0hfPSid1De+N ZWGJQd5GyVNs7zuWStkgdA0+eO4pHI8kbGzQqFD5gU7K4smDiG+/KSFXFtyumX9161xR gFgPJYMAjHvGu4esLuh8gnu9FORPWQAvRXxM1Fw+K2chtliMOXJKgLfu2S0Im2X6eNPT yl/pESGIizgb0AplvHrS6pEUY2jfIuSNbfTpMOZWBgbqPBGK1qlEM0YxrpOEn58DK6Rv kUuxV0eUMm55xeoHjsQQRweqNZ0CYlMI/kWypdCNCY7/XzAJEszfOFhia+G/NGs9NcBf qo3Q== X-Gm-Message-State: ABy/qLbCzeNlvgmFkuKzhZPCw72HHhuj6hewpZ6qPcvOtuMinAbIzX3H 0ftJwC4tNSO82LJjasuRsVUCrw== X-Received: by 2002:a05:6e02:219b:b0:345:a818:ed3b with SMTP id j27-20020a056e02219b00b00345a818ed3bmr1293537ila.7.1689638862515; Mon, 17 Jul 2023 17:07:42 -0700 (PDT) Received: from localhost ([2601:644:200:aea:b8fa:bd5a:9379:3b89]) by smtp.gmail.com with ESMTPSA id 16-20020a17090a199000b00267a487f01bsm356703pji.48.2023.07.17.17.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 17:07:42 -0700 (PDT) From: Ivan Babrou To: linux-perf-users@vger.kernel.org Cc: kernel-team@cloudflare.com, linux-kernel@vger.kernel.org, Ivan Babrou , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter Subject: [PATCH] perf script: print cgroup on the same line as comm Date: Mon, 17 Jul 2023 17:07:37 -0700 Message-ID: <20230718000737.49077-1-ivan@cloudflare.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 Commit 3fd7a168bf51 ("perf script: Add 'cgroup' field for output") added support for printing cgroup path in perf script output. It was okay if you didn't want any stacks: $ sudo perf script --comms jpegtran:23f4bf -F comm,tid,cpu,time,cgroup jpegtran:23f4bf 3321915 [013] 404718.587488: /idle.slice/polish.service jpegtran:23f4bf 3321915 [031] 404718.592073: /idle.slice/polish.service With stacks it gets messier as cgroup is printed after the stack: $ perf script --comms jpegtran:23f4bf -F comm,tid,cpu,time,cgroup,ip,sym jpegtran:23f4bf 3321915 [013] 404718.587488: 5c554 compress_output 570d9 jpeg_finish_compress 3476e jpegtran_main 330ee jpegtran::main 326e2 core::ops::function::FnOnce::call_once (inlined) 326e2 std::sys_common::backtrace::__rust_begin_short_backtrace /idle.slice/polish.service jpegtran:23f4bf 3321915 [031] 404718.592073: 8474d jsimd_encode_mcu_AC_first_prepare_sse2.PADDING 55af68e62fff [unknown] /idle.slice/polish.service Let's instead print cgroup on the same line as comm: $ perf script --comms jpegtran:23f4bf -F comm,tid,cpu,time,cgroup,ip,sym jpegtran:23f4bf 3321915 [013] 404718.587488: /idle.slice/polish.service 5c554 compress_output 570d9 jpeg_finish_compress 3476e jpegtran_main 330ee jpegtran::main 326e2 core::ops::function::FnOnce::call_once (inlined) 326e2 std::sys_common::backtrace::__rust_begin_short_backtrace jpegtran:23f4bf 3321915 [031] 404718.592073: /idle.slice/polish.service 8474d jsimd_encode_mcu_AC_first_prepare_sse2.PADDING 55af68e62fff [unknown] Signed-off-by: Ivan Babrou Fixes: 3fd7a168bf51 ("perf script: Add 'cgroup' field for output") --- tools/perf/builtin-script.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 200b3e7ea8da..517bf25750c8 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2199,6 +2199,17 @@ static void process_event(struct perf_script *script, if (PRINT_FIELD(RETIRE_LAT)) fprintf(fp, "%16" PRIu16, sample->retire_lat); + if (PRINT_FIELD(CGROUP)) { + const char *cgrp_name; + struct cgroup *cgrp = cgroup__find(machine->env, + sample->cgroup); + if (cgrp != NULL) + cgrp_name = cgrp->name; + else + cgrp_name = "unknown"; + fprintf(fp, " %s", cgrp_name); + } + if (PRINT_FIELD(IP)) { struct callchain_cursor *cursor = NULL; @@ -2243,17 +2254,6 @@ static void process_event(struct perf_script *script, if (PRINT_FIELD(CODE_PAGE_SIZE)) fprintf(fp, " %s", get_page_size_name(sample->code_page_size, str)); - if (PRINT_FIELD(CGROUP)) { - const char *cgrp_name; - struct cgroup *cgrp = cgroup__find(machine->env, - sample->cgroup); - if (cgrp != NULL) - cgrp_name = cgrp->name; - else - cgrp_name = "unknown"; - fprintf(fp, " %s", cgrp_name); - } - perf_sample__fprintf_ipc(sample, attr, fp); fprintf(fp, "\n"); -- 2.41.0