Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32467676rwd; Fri, 7 Jul 2023 14:40:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlFIT9MajuaucJjGbM+I5bLT4VXDoyDL3gp/i/+SKS/njK+/RcE7yKQ5puOe2yI/xeZpsitl X-Received: by 2002:a17:906:77c9:b0:993:e518:279d with SMTP id m9-20020a17090677c900b00993e518279dmr545676ejn.12.1688766020504; Fri, 07 Jul 2023 14:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688766020; cv=none; d=google.com; s=arc-20160816; b=qQKUWr5RoTX8haogU96+JKshqAJ6BF3ErrMMkdOA+d/0UWseemk49wjjOUSpcmTmT3 pGFqiD1y/FpogZS2cujqh+0sjH2Kt2iCj8N4FEpAgVvtOwLG9ozUGLe4kxcVpcoikPmv 4SuMvlXSfVeUBQrCcX91y8wSXxPSusiMeaKUY/JqRgBqUD6VpggAez3TborgG0jFuwFJ haoS21felbP5/x1Fxoz5ulEmoeRTfGmBtrIrrp6s5kEWmKXExrLHARU8Qzv53jgoN2UJ U3VMtSNqkTinuAsCw6zSToSh2PDCyPzPxP8YA0aYFBEk1BLnK8sBRNcEAVfu12kbQ3z8 Nokw== 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=3+zbVeGsIu88HXn6Bzuf24zwb+/jDouBgewDVwqhr3c=; fh=ySq3lQcDqZDk4DVIg5WDWmDtxewj8RCaiNhSFwRH11M=; b=gOuwDPbiD/xcAgY/j6K7XQfA5dztZU+YNANYo1ysPipSw0taNrVDEgi/JfslEVCw9e dy5xS4O3rSPvBblf0SJ4G+zmpPZoiDGdXvyLr9h6ZlaqGjcgk2qE5zN6aA+/tgtG3wN8 85Ei+RezLvYA0C4OENQZ9+ONrdUyMyyRsIb+XejF+f/YhJX1mZKkOndf8rUogW7eMI8f T3LGejvS2zleFzmA0BaT+zKozhmR534x4i5GzV1nciA657xlu2PRuIohgYrkX8vpGRrq YFe23/UZBqB1tgwRFFP3qSg6bRixp4qNX2BYxUNZgkASnZX/bXfbEHWp9nTL4rGQKFUC mIqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ZN5rkvBZ; 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 f23-20020a170906561700b0099364d9f0e0si2746946ejq.540.2023.07.07.14.39.55; Fri, 07 Jul 2023 14:40: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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ZN5rkvBZ; 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 S232301AbjGGVND (ORCPT + 99 others); Fri, 7 Jul 2023 17:13:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232079AbjGGVNC (ORCPT ); Fri, 7 Jul 2023 17:13:02 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B683B2702; Fri, 7 Jul 2023 14:12:39 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1b8bbce9980so16786585ad.2; Fri, 07 Jul 2023 14:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688764357; x=1691356357; 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=3+zbVeGsIu88HXn6Bzuf24zwb+/jDouBgewDVwqhr3c=; b=ZN5rkvBZLv9HYk1H7ecMPvpCji31Y7vvcmqn76vlvh3LT/4P4ck5sK9vAaQmKlPmSu WfC+WZYtV1Z2gYlamzblzi142y4tr+GLuVYd6HusBcTEFMcmEpfxuSkO3EnWPUaeEnEa XOGm3Fcgobne83qKc0q2lU5D9doYk7F+jkKAK4VCHcdwdC14PdCYeXVqALdnEmxuVFEl duZY9O9ihxn/7YrLU19a+Ehnza8aRkG5/byUUYSOcYXJUL7p4jrS1QsrefRVbT+d6QPV Uq6CNE6+hBtKIXGXD7+3EEyhyvXi4iyT7wbqCzFebeGHCl5Z/8FEerZFETW7hnQjMlVU WsHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688764357; x=1691356357; 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=3+zbVeGsIu88HXn6Bzuf24zwb+/jDouBgewDVwqhr3c=; b=hby25NwqmF32F9kby6wzdMvphtDDGf7XF6bcBv+7v6vsbzZzkl0LhTgHN4meFhGtx/ 4AwSUdZ14ZRceTXW+xC4c8u55E1630SnH4HOK6olGYQ2gBQvb2ZCDgiLe9AN8JkhJCl4 azepH4ZsiXlrc0oN31X7WfWFKcyNFMS5sS+FUuNI/9610pBcAICRcfAAJ/ophhp5gHPF yI9VRkWXMb1mp5Bw6al6MWTpy8NwNsR7RVggIsUe/LzihbvRl8IkrOdEqR3GztzeufmL a9MulMzbRDrOUjuigMXnz3TMF6dk2fftKYxNG04dCx0ePxAHY7IxTOJophheFLH8sLcG oJ/Q== X-Gm-Message-State: ABy/qLY8Ung3ue98weYPDvEcTxLxysXC4ZoxUV7EnBJmxYcunoUT3cYy 2c6WyfpNZZ2wL/DaX62pnTo= X-Received: by 2002:a17:902:f546:b0:1b8:ae12:563f with SMTP id h6-20020a170902f54600b001b8ae12563fmr6246952plf.29.1688764357184; Fri, 07 Jul 2023 14:12:37 -0700 (PDT) Received: from yoga ([2400:1f00:13:8a1c:1db1:98d9:af8d:f09b]) by smtp.gmail.com with ESMTPSA id y10-20020a17090322ca00b001b03cda6389sm3687832plg.10.2023.07.07.14.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 14:12:36 -0700 (PDT) From: Anup Sharma X-Google-Original-From: Anup Sharma Date: Sat, 8 Jul 2023 02:42:29 +0530 To: Namhyung Kim Cc: Anup Sharma , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/7] scripts: python: Extact necessary information from process event Message-ID: References: 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_NONE,SPF_HELO_NONE,SPF_PASS,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 On Wed, Jul 05, 2023 at 10:35:02PM -0700, Namhyung Kim wrote: > Hi Anup, > > On Wed, Jul 5, 2023 at 12:42 PM Anup Sharma wrote: > > > > The script takes in a sample event dictionary(param_dict) and retrieves > > relevant data such as time stamp, PID, TID, thread name, and call stack > > information. If available, the call stack is parsed to include function > > names and the associated DSO, which are requires for creating json schema. > > Also few libaries has been included which will be used in later commit. > > > > Signed-off-by: Anup Sharma > > --- > > .../scripts/python/firefox-gecko-converter.py | 37 +++++++++++++++++++ > > 1 file changed, 37 insertions(+) > > create mode 100644 tools/perf/scripts/python/firefox-gecko-converter.py > > > > diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/perf/scripts/python/firefox-gecko-converter.py > > new file mode 100644 > > index 000000000000..ce663840d212 > > --- /dev/null > > +++ b/tools/perf/scripts/python/firefox-gecko-converter.py > > @@ -0,0 +1,37 @@ > > +#!/usr/bin/env python3 I believe this is not needed as we are using perf-script-python interface. > > +# SPDX-License-Identifier: GPL-2.0 > > +# > > +# Usage: > > +# > > +# perf record -a -g -F 99 sleep 1 > > +# perf script firefox-gecko-converter.py > > + > > +from __future__ import print_function > > Is this needed for python3? No, it is not needed. I will remove it. > > > +import os > > +import sys > > +import json > > +from functools import reduce > > + > > +sys.path.append(os.environ['PERF_EXEC_PATH'] + \ > > + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') > > + > > +from perf_trace_context import * > > +from Core import * > > + > > +def process_event(param_dict): > > + time_stamp = (param_dict['sample']['time'] // 1000) / 1000 > > + pid = param_dict['sample']['pid'] > > + tid = param_dict['sample']['tid'] > > + thread_name = param_dict['comm'] > > + start_time = time_stamp if not start_time else start_time > > + if param_dict['callchain']: > > + stack = [] > > + for call in param_dict['callchain']: > > + if 'sym' not in call: > > + continue > > + stack.append(call['sym']['name'] + f' (in {call["dso"]})') > > + if len(stack) != 0: > > + stack = stack[::-1] > > + else: > > + mod = param_dict['symbol'] if 'symbol' in param_dict else '[unknown]' > > Why is it 'mod' instead of 'sym' or 'func'? I will change it to 'func'. It will be more meaningful. > > Thanks, > Namhyung > > > > + dso = param_dict['dso'] if 'dso' in param_dict else '[unknown]' > > -- > > 2.34.1 > >