Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1902648rwp; Thu, 13 Jul 2023 19:38:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGKxlEthUx/FXRG/FUQhMbpH8PKcHXI4A6jC2Q9F/QtocM1n/cHgLzHGssc2jwAIMiqsxTU X-Received: by 2002:a17:902:ea02:b0:1b5:2fdf:5bd8 with SMTP id s2-20020a170902ea0200b001b52fdf5bd8mr3869036plg.8.1689302300294; Thu, 13 Jul 2023 19:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689302300; cv=none; d=google.com; s=arc-20160816; b=BNBNvQgA2ggO0w4FlfDoJNY1R7rWZb+JQvt4K4sRKI3WZrrPDvYNTgg7EhtYfaHhmK 5NaMv39dwasWbdCNfY8ph3jYoHezUKgSfv65sr3GufhUN1OadTBHCRJ3fhOzGXgh5yfK oK6HzumofFMsJaWAxJv3xLYZm4ihRYJxJrSgqFsfjazYPaI2qy9LP4CVOZkLpdb1Pbrh I6Ke8Llkbu+rCUDw/Upy1RHylakZya+GE9xek7tc87+i2tvkLSCTb/fAX8ouLKTMyBX7 PEf26LJi7t5oIPMjWGaeUiD/xhphtOOlPY8c1Ipmj83/y9TIFo8+hAQxwbX0WqEqJJmi GTlg== 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; bh=ngZK+XDpBAWYX1J0uIc5fhGu5iysS5SjcU2zAr2KyGg=; fh=gd5Ehiv7h0wNPm1+QrxnyF1Ba03f35fIJkXXX2EkSaY=; b=v8fye8QLPNXHOfFIEodXjEf8qVqxj5bqnz7r2Ada0paxYWEgIDFiCMlC8qb1Mjw9/2 +DFOwinsGGkMS6JL5s8IK0GU2DQxRprjI2JpDdM2HvqXkJYRol73vAAFE7DenPI0/lsL i2En4Xf+ROzSwK6HRQ4MIsx7tpcIM0Gb42lxsD9Y54dsAaCkVWc5trpbXqM5Zp6vZ0/N tU3FSqAQnnkhu6Q240dgqbgS2Vo7SAqE7OJYa6VMTynhcaf6q1PgvBoHY3i1GOBFh3ct kgps1iQEDpASG2rzdieAqFOviNrJag/JzinMnUMTUd6NxxmcUuYGsYTfty3DBvTfDLoW zaog== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a17090301d000b001b9e39f8e21si6530684plh.127.2023.07.13.19.38.07; Thu, 13 Jul 2023 19:38:20 -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; 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 S234317AbjGNCb6 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 13 Jul 2023 22:31:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231547AbjGNCb4 (ORCPT ); Thu, 13 Jul 2023 22:31:56 -0400 Received: from mail-vk1-f169.google.com (mail-vk1-f169.google.com [209.85.221.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C429C2D63; Thu, 13 Jul 2023 19:31:49 -0700 (PDT) Received: by mail-vk1-f169.google.com with SMTP id 71dfb90a1353d-4815756d742so435313e0c.1; Thu, 13 Jul 2023 19:31:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689301909; x=1691893909; 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=3nTW7gc06oCO+awj0xYoLUkZXhqvUKiuD24Yf6fhtuE=; b=YtWDI73dY00nez3A+XO3CPqLDhZSS1sxSz4DvDpMrBcA+N/HgwY+Bv+L+hylYez5D0 4BtKlT1FuIFCAJ7jEdHucn/sv7OqMN2F1wgdFkdwVGpHcjUaXifeVh1KN1iFTCP4CKNU Sa9TlZi0JhARPCzI5P7piIOAQnO0y7B2yRQuxEiFuTEUy6raKTKKp41wGnnPbsugkjuf 6a/Zxm0LHYJ3N3ZwW7C54doaGS4LZkxTHU7obQNlM31jkMbKW9ZJV5b7zqN2UNG40xJg jnwDhpoxw3i/pSdSWSBYG4gFcudFlqEDFEXl/j4M/NDAwiGzBoZMTsR2RcMKpy0lfOmH a2ew== X-Gm-Message-State: ABy/qLYlvHJMYCoWPSNIXwlXtqbP4dl5v7I4nQBhY0T3QokMrQ6Q/Fjf w9NGWKMdTz9K/zJYoVPRgWKhL0fAKeP6iM0wE5Y= X-Received: by 2002:a1f:bfd8:0:b0:47e:6e24:7672 with SMTP id p207-20020a1fbfd8000000b0047e6e247672mr1885895vkf.13.1689301908691; Thu, 13 Jul 2023 19:31:48 -0700 (PDT) MIME-Version: 1.0 References: <11543b39f97a7e2f9eac76c1233f1b1caa3f2c48.1689024635.git.anupnewsmail@gmail.com> In-Reply-To: From: Namhyung Kim Date: Thu, 13 Jul 2023 19:31:36 -0700 Message-ID: Subject: Re: [PATCH v3 4/6] scripts: python: Add trace end processing and JSON output To: Ian Rogers Cc: Anup Sharma , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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. > > > + > > +# 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. 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 > >