Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3314654rwb; Mon, 7 Aug 2023 11:23:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVyk5hNJGSbbSjrtfFMe4HRoMHPt3pLGdej9BQoEiXS9Q2rNaZQ1WYU5sn65S6sYyTAHdk X-Received: by 2002:a05:6a20:6a0c:b0:13f:8e07:7ed4 with SMTP id p12-20020a056a206a0c00b0013f8e077ed4mr9103681pzk.13.1691432586481; Mon, 07 Aug 2023 11:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691432586; cv=none; d=google.com; s=arc-20160816; b=aFQqhpj9/gBaj+1sZZb62QBapWIM1ydv6+yEsGHa7si9ytEVSPSZVJnCjtYztg3FpF 5BcyspFArqElZWeHzr/SXEFPCVe1dbylHx2RHF6y4lHA1EruPZIsRiBLY5ulTgB4z/Cu xYRUr7yKC0o3lb9YiTYv/OLwStNwqLdto6G6yZeGbN0HyMnNqq0gx3lOluyczoE4rwn4 ABojYlgZ9PLHPTHPI/lJIpLeyGLORxKyYxIUrNzlP1qk57olErnYxRPf8zFe+IuN7YQO CZgTsMJovwshVKVGej1S6Gyhq9gwaURryY1uHmb54As9FTpPMyCPQs38DocKDKE2clcF YmMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GI8Hutnt26EHj7tuULT6Fix2Lq+EUTecU3vE9W0dfXo=; fh=OJv8zBs0cfjNTaQ5nE2jntsfIctRQ/9LZCh6bV6ZY4c=; b=au9IIaDuvK8x9TJcQ+hYRyQZblnzVxQIU/VuJjMG4ffUJ/JZqBXvwlSHpil3uMHosn Km1T1DrRVhgcEmYdc7c2CHWCIpoJUgS08WksKtgCh/cAw+SFXpMhCQ9CLwiuVnSYm7Wj 8Rhpef+LjHKHo/ElwQW1RfwXq9c3cEK/2O1IqbnnbgdK/ElYyltWrvj/n8nziRhSw3Ml +VkTJzO9H3EZ30oEzpGvYt3NgfsP4PdaRHWz9xTdfEF8DfWKv+DcNU+TvtykX1zDlYfE 47+hBKPelT7vEyW9QptOIG/iM03+3WF8qnruLQWkZGq1y3T2g7s3x0BefyyUFJyx3x87 SytA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=lxypjkYz; 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 y1-20020a63e241000000b00543e36736d3si5908183pgj.628.2023.08.07.11.22.53; Mon, 07 Aug 2023 11:23:06 -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=lxypjkYz; 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 S230270AbjHGSCR (ORCPT + 99 others); Mon, 7 Aug 2023 14:02:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjHGSCQ (ORCPT ); Mon, 7 Aug 2023 14:02:16 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64689170B for ; Mon, 7 Aug 2023 11:02:15 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5231f439968so4601463a12.0 for ; Mon, 07 Aug 2023 11:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; t=1691431332; x=1692036132; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GI8Hutnt26EHj7tuULT6Fix2Lq+EUTecU3vE9W0dfXo=; b=lxypjkYz0xj4BrP4ej7Y3x5ckVbmUAkMy+yYAqys8TO2qScWXqIHP9mTEU/Zy+ltwu I2aGtdxpPgH6zKiE4MLgmkvq8qG+2FSo6xMRBnsiU9DANkolm+RJPdif4QE023Efysn1 +MYBexoxMLstHnb8NgQ2uhe/ETP0P1K62f5f8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691431332; x=1692036132; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GI8Hutnt26EHj7tuULT6Fix2Lq+EUTecU3vE9W0dfXo=; b=UpegFrMcmB04anL8oS92uDz0uikatn+fepZhB2YFb2GFU5ksqOZatACS2BK6nAF9j1 K+fynnWQlVeSJknblCERC4jJbpqoTuOIFu8JswFISNVrepdoVUOHAXqozFEeYwunbVrQ 8XUqFZgf2Zhmmgu44Hk7kwy95rkAg6PXu66bhzI510/aslOXQfMM+Zanf+B3P9g7AcEk eyIDsbK8E5v1Ew9MzZtNLyCwMpHlMQ2fhXLAjrsrMla2XC34KssgyspQB3l26do+r22G UB7AoACDUtuarmLHn0zTX/JmHeAQIhQx1wGTtofP+DRU0Dp2AKEoQWc+/96z04jLN097 bfPg== X-Gm-Message-State: AOJu0YwUtn4huyBHoaU3jUBGvCp/cJQ/kQw4aTp8Gpq7vfP3yPveYj1a XUToDU5uiIufB88qgWdF6aqZ1cog26kj8boSmNzmjA== X-Received: by 2002:a05:6402:517a:b0:522:2f8c:8953 with SMTP id d26-20020a056402517a00b005222f8c8953mr8039951ede.39.1691431332079; Mon, 07 Aug 2023 11:02:12 -0700 (PDT) MIME-Version: 1.0 References: <20230718000737.49077-1-ivan@cloudflare.com> In-Reply-To: From: Ivan Babrou Date: Mon, 7 Aug 2023 11:02:01 -0700 Message-ID: Subject: Re: [PATCH] perf script: print cgroup on the same line as comm To: Namhyung Kim Cc: Ian Rogers , linux-perf-users@vger.kernel.org, kernel-team@cloudflare.com, linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_NONE, SPF_HELO_NONE,SPF_NONE 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 On Fri, Jul 28, 2023 at 10:57=E2=80=AFAM Ian Rogers wr= ote: > > On Fri, Jul 28, 2023 at 10:42=E2=80=AFAM Ivan Babrou wrote: > > > > On Mon, Jul 17, 2023 at 5:07=E2=80=AFPM Ivan Babrou wrote: > > > > > > 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,c= group > > > 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 (inl= ined) > > > 326e2 std::sys_common::backtrace::__rust_begin_sh= ort_backtrace > > > /idle.slice/polish.service > > > jpegtran:23f4bf 3321915 [031] 404718.592073: > > > 8474d jsimd_encode_mcu_AC_first_prepare_sse2.PADD= ING > > > 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 (inl= ined) > > > 326e2 std::sys_common::backtrace::__rust_begin_sh= ort_backtrace > > > > > > jpegtran:23f4bf 3321915 [031] 404718.592073: /idle.slice/polish.= service > > > 8474d jsimd_encode_mcu_AC_first_prepare_sse2.PADD= ING > > > 55af68e62fff [unknown] > > > > > > Signed-off-by: Ivan Babrou > > > Fixes: 3fd7a168bf51 ("perf script: Add 'cgroup' field for output") > > This change makes sense to me. Namhyung, wdyt? > > Thanks, > Ian Hi Namhyung, This is a really trivial patch and it would be good to get a word from you. Thanks. > > > --- > > > 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 =3D cgroup__find(machine->env, > > > + sample->cgroup); > > > + if (cgrp !=3D NULL) > > > + cgrp_name =3D cgrp->name; > > > + else > > > + cgrp_name =3D "unknown"; > > > + fprintf(fp, " %s", cgrp_name); > > > + } > > > + > > > if (PRINT_FIELD(IP)) { > > > struct callchain_cursor *cursor =3D 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_pa= ge_size, str)); > > > > > > - if (PRINT_FIELD(CGROUP)) { > > > - const char *cgrp_name; > > > - struct cgroup *cgrp =3D cgroup__find(machine->env, > > > - sample->cgroup); > > > - if (cgrp !=3D NULL) > > > - cgrp_name =3D cgrp->name; > > > - else > > > - cgrp_name =3D "unknown"; > > > - fprintf(fp, " %s", cgrp_name); > > > - } > > > - > > > perf_sample__fprintf_ipc(sample, attr, fp); > > > > > > fprintf(fp, "\n"); > > > -- > > > 2.41.0 > > > > > > > A friendly bump in case this slipped through the cracks.