From patchwork Tue Jul 18 00:07:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Babrou X-Patchwork-Id: 121711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1432288vqt; Mon, 17 Jul 2023 17:50:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlEgJ7F7YkcJPyzsz5rlevyaHWFnXZUIY+B96nwB4ii4QMU8e48rbS2UVk0knS4WtPbSoxuh X-Received: by 2002:a05:6a00:2451:b0:682:2fea:39f0 with SMTP id d17-20020a056a00245100b006822fea39f0mr18879448pfj.5.1689641457404; Mon, 17 Jul 2023 17:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689641457; cv=none; d=google.com; s=arc-20160816; b=IWfZ/ku6Q1OyyzOW99QFPXhenqb+imi2bxKii8pnPF71OI0P7hawlfsSVXUtiQOX7h k2M5H+BlhVNFKqtwpPtVe6FsDHgJNj17glU1JYZGWkDn182rUK+Ih8KfMeF+EHSJ9+Dd mEYOpwlM0Y8/8aa/msNY4xAN4FbZa2iylpiYOiW2ex6eOBMlH//64rZPLx9Dp1nOxsRK rfGcB2g/C16SEEWR68IbALDd9MLGfRQXh/38VPcRE8ypbJva/TyHiR548L06iDHk00jt b4dqMdz1QZ2RVWidb3dxL2jrZKtEiTKAUvut120+NI42rx1DzyV33v1C2Ato1mgu0Y7h vSgw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cn11-20020a056a00340b00b0068267c56811si610181pfb.167.2023.07.17.17.50.44; Mon, 17 Jul 2023 17:50:57 -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 S230419AbjGRAHt (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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771717481068933894 X-GMAIL-MSGID: 1771717481068933894 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") Acked-by: Namhyung Kim --- 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");