Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5789650rwp; Mon, 17 Jul 2023 09:25:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHLKYoZBcXcr6rwfK6YVsycIRzRuNhiollcAa63A4SbHFEO55H4t7tz/p/bFyJcprAvM37f X-Received: by 2002:a17:90a:5a0a:b0:262:f0d0:97c0 with SMTP id b10-20020a17090a5a0a00b00262f0d097c0mr11542596pjd.32.1689611136335; Mon, 17 Jul 2023 09:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689611136; cv=none; d=google.com; s=arc-20160816; b=grknOJI8LKQWpW5CakRmEhijurcW7xSN4F/TRkMlEzhPCc6acYBzt6DWZ97qKx90Zj RSp4fBBKDl9AsasWDRYGq2kfQGwpFz5EvfjLSq2pohjfjsbWxjqJD4uM/aIL3QOAaef6 cqzFcBbkgTrrbM+Q1iwQphSg4cd/SFY4she3UKabBI3znm04QNvEGtDIrZUCRqMBClFa TlZ88KYCiZMggO4ZbF+kCKOOXuOby9PC7WgHwy6rMQfLkx2y5vgppbVjg/9H6wx4gAgM ImvwwWaQJgf9A0B8w4ZZRuFLANKLp16NHkuqJJdtDUTbd8jS1vsR6e2XkNOd5rZkm7aN HP2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=7HKpP5mcDRv5ySS4JCo6NCH3S1mQJkLAnPgImOv+RPo=; fh=joMrn8Mz5jnh8tOM11EGBYbPMherebfVbQk+RnjCBtg=; b=iztm418XXSL2z3NbH/nFsBsoirT33WAkoCaOmGXVsHegWLAO48QEvshSn2OKALICQi /gd4swovo0YqdiTN/5cW/ERA0TwgvdL+atNOQlHRBSA6fssuJCatBhSrR4Q0AQ4D9sRp VWENyZUfv4Lj9IDGlTdZva7Kx+MeNm7itN009wRmQvv1H2ZkB5NOzjIbHrc/grgTawrO IUxsrz7aqQn5RSTNwb/Z+nCVCYq4/YYiF+qLgkDOw9kAL6BfyQNRdA1eTYsu9FLlsNvx 3fz91CbPItp31LzQuMoUZQgoWptk3owWT/CA/7aB5t/d1zYAHuXiR16mG1pUau6n4Hwn NGIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=CDTNYz2M; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a65508a000000b0050fa9bc63cbsi16084pgp.432.2023.07.17.09.25.23; Mon, 17 Jul 2023 09:25:36 -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=@gmail.com header.s=20221208 header.b=CDTNYz2M; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231854AbjGQPxT (ORCPT + 99 others); Mon, 17 Jul 2023 11:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbjGQPxR (ORCPT ); Mon, 17 Jul 2023 11:53:17 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EF2EA4; Mon, 17 Jul 2023 08:53:16 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b895a06484so27916525ad.1; Mon, 17 Jul 2023 08:53:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689609196; x=1692201196; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from:from:to :cc:subject:date:message-id:reply-to; bh=7HKpP5mcDRv5ySS4JCo6NCH3S1mQJkLAnPgImOv+RPo=; b=CDTNYz2M6URSjOeVtrgzuniiP0wvyMOI+rJcwCi45OxdlEfIBIUtLEkQkv3m5UQKoH zxDYMbVrfhx4UJYGAg6PpQBkjjANVjNZbf1J/w7YU/cvlqrByRi75/l4UVf/PSjNoKJW N28UnmiycbJzi02ySJEPWlBnEIRMBdMjCRzEYwM6ZTxHCJCib+vGdQqzOn33tzZMs6sS WVjg6e5iZ3FjIx9d85yECVT7exQN/tveiGFsGx5w8bLM2xfjl7a5HeRqZPkmmktbeI4i 1yPO/TncgrbDqbbEhXs/tHZhx04g992qbmy+mxslj9UhjZTpCzyH1uUeokCrqb9vEkRk mCcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689609196; x=1692201196; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7HKpP5mcDRv5ySS4JCo6NCH3S1mQJkLAnPgImOv+RPo=; b=iVYE8RtQ8dQaOXS+9S9uQsxMV2/VFY+d97/LFZEEVvzVqUFtbLBUSjmzvkJawQSbtl 8ZxDpHRDm5P7x6YQ99cn3oVeHW/COcxult63ZUz/BXfBhoE5JXaVCwoXpRaR0akqkESQ aBPr8izhIefCzAA+JBM+2zuVPbpsS7sVRwzHbwEyLElSFvy8+KIaaGqHDkwa2CSRt4Cr h+9ed0At/0e8TLsSVcfSrjFbE3Aa4PFPGH7IZks0KnOec1aeI1OGGwQ+rLrEwlRTT0mU emiZxt9wipubGsHmrE+eIWWGS0pjWitFMRvEReygaUBxAbyCosrWRfzGeQwKB7H5DjUS OM/A== X-Gm-Message-State: ABy/qLZvsfPWzABAvJf+em8aLaKU/Qexb6quGrlHT00O2d+8nCyywdWv V2FeSVoIQJ9OCpJ1xCWTUt8= X-Received: by 2002:a17:902:724b:b0:1b8:b436:c006 with SMTP id c11-20020a170902724b00b001b8b436c006mr10249999pll.12.1689609195574; Mon, 17 Jul 2023 08:53:15 -0700 (PDT) Received: from yoga ([2400:1f00:13:50e2:5893:783e:fde0:1bce]) by smtp.gmail.com with ESMTPSA id d13-20020a170903230d00b001b694130c05sm79160plh.1.2023.07.17.08.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 08:53:15 -0700 (PDT) From: Anup Sharma X-Google-Original-From: Anup Sharma Date: Mon, 17 Jul 2023 21:23:07 +0530 To: Namhyung Kim , Adrian Hunter Cc: Ian Rogers , Anup Sharma , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 4/6] scripts: python: Add trace end processing and JSON output Message-ID: References: <11543b39f97a7e2f9eac76c1233f1b1caa3f2c48.1689024635.git.anupnewsmail@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Thu, Jul 13, 2023 at 07:31:36PM -0700, Namhyung Kim wrote: > Hi Anup and Ian, > > On Wed, Jul 12, 2023 at 10:28 AM Ian Rogers wrote: > > > > On Mon, Jul 10, 2023 at 4:13 PM Anup Sharma wrote: > > > > > > Inside the trace end function the final output will be dumped > > > to standard output in JSON gecko format. Additionally, constants > > > such as USER_CATEGORY_INDEX, KERNEL_CATEGORY_INDEX, CATEGORIES, and > > > PRODUCT are defined to provide contextual information. > > > > > > Signed-off-by: Anup Sharma > > > > Acked-by: Ian Rogers > > I'm ok with this change too but I think it can be squashed to > patch 1/6 as I think it'd make it more self-contained. Of course > you might change time and thread to have empty values. > > > > > > --- > > > .../scripts/python/firefox-gecko-converter.py | 34 ++++++++++++++++++- > > > 1 file changed, 33 insertions(+), 1 deletion(-) > > > > > > diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py > > > index 0b8a86bdcab1..39818a603265 100644 > > > --- a/tools/perf/scripts/python/firefox-gecko-converter.py > > > +++ b/tools/perf/scripts/python/firefox-gecko-converter.py > > > @@ -24,8 +24,40 @@ from Core import * > > > thread_map = {} > > > start_time = None > > > > > > +# Follow Brendan Gregg's Flamegraph convention: orange for kernel and yellow for user > > > +CATEGORIES = [ > > > + {'name': 'User', 'color': 'yellow', 'subcategories': ['Other']}, > > > + {'name': 'Kernel', 'color': 'orange', 'subcategories': ['Other']} > > > +] > > > > A follow up could be to make these command line options, defaulting to > > orange and yellow. > > Sounds good. Nice Idea, I have added this in the next version of patch. > > > > > + > > > +# The product name is used by the profiler UI to show the Operating system and Processor. > > > +PRODUCT = os.popen('uname -op').read().strip() > > I'm not against this but having a command name (or full > command line) of the target process as a title might be better. > But I'm not sure if the python scripting engine exposed the info > (like in perf report --header-only) to the script. I tried to get the command name or any sort of header information but it seems to be not exposed to the perf-script-python interface. can anyone confirm if there is any way to get the command name or any header information from the perf-script-python interface? > Thanks, > Namhyung > > > > > + > > > def trace_end(): > > > - pass > > > + thread_array = thread_map.values())) > > > + > > > + result = { > > > + 'meta': { > > > + 'interval': 1, > > > + 'processType': 0, > > > + 'product': PRODUCT, > > > + 'stackwalk': 1, > > > + 'debug': 0, > > > + 'gcpoison': 0, > > > + 'asyncstack': 1, > > > + 'startTime': start_time, > > > + 'shutdownTime': None, > > > + 'version': 24, > > > + 'presymbolicated': True, > > > + 'categories': CATEGORIES, > > > + 'markerSchema': [] > > > + }, > > > + 'libs': [], > > > + 'threads': thread_array, > > > + 'processes': [], > > > + 'pausedRanges': [] > > > + } > > > + json.dump(result, sys.stdout, indent=2) > > > > > > def process_event(param_dict): > > > global start_time > > > -- > > > 2.34.1 > > >