From nobody Tue Oct 21 00:47:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E645AC0015E for ; Wed, 5 Jul 2023 19:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233499AbjGETmf (ORCPT ); Wed, 5 Jul 2023 15:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233314AbjGETme (ORCPT ); Wed, 5 Jul 2023 15:42:34 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 362969F; Wed, 5 Jul 2023 12:42:33 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-262fa79e9b3so36943a91.0; Wed, 05 Jul 2023 12:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688586152; x=1691178152; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=F/jsFLrmNjyiYjHyvrw+WR7HDQEG+dPkNlGKVeYGi8I=; b=TIofqNfHFQobawWnN+T6CQEsoWs4vpXuIMoceRmfmefetUob0g5QvqAoEqZcl2i7jc 2Mr8rKn7j5/6dwFuM2XU1I/z34IJR+FuRLXhnolSQhNqqvl02xQqaae2+vxrCQRLSMKK HIuIiFF0KjkmkG4oDTRRVHgHIN3Ulk/uzX+drgsTqafhvcJiuu4pE+I6CipUH3z6GIkz D0ouwF6+gtRkiBkyw3IGi1Eubc4orBkxsre0qlb9kd0uYewfH2rvX5KmdwPNDHCrlWnl btp5hmt9g/EMlHTyEoL3PZ0p/olYCCZ1cElBOt89P9UG6ftv5fLiQ84pvY3sy4xIPbZ0 81hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688586152; x=1691178152; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=F/jsFLrmNjyiYjHyvrw+WR7HDQEG+dPkNlGKVeYGi8I=; b=h8HxZlihFZnhCIHAhjWHSfyWcoYf/q0/psPhwT/no0alTgd/GPiQI7fYm4GSmHLG4a cFhx4NHsDe7gsWydqlnv2wXmlaJXvzTAn09sj24HispeyRy4QVIqi53C0aAA3dIiToCl dMJiyGKlx02dAEIre374TydTIdd//knuLxsDoxd7b1uNZOnHoGqH9tFzDmKT8LD4YZmR 2DUenN8zmCqSBEccQmtOoAkVQC/6GEhFgDHrFkWloGpOZBBrALxWffsL2ticQM4diAd9 s11hVK4oJCoECn8++v9UjYHXVxQYMJkoVBt7CohOZNDrIxxU1L4K3Ce6n9LzBQ398Bvz bqJw== X-Gm-Message-State: ABy/qLZkFu/GFsgVfKKlTJXrV98Nm+oEdYPlfjdhaVCglBOqstbLL0Qr ubc2n4TW/+Qa38tjwfl9Pg6PljXJY3i/CYZ4 X-Google-Smtp-Source: APBJJlEQL3jFIuy2rLQG/6Iqxy+qepTqVddqeBbkwO5Hsw9xmE7cFPHqYvTz3dUf4lfn7G5w5gSfEA== X-Received: by 2002:a17:90b:30c3:b0:262:df79:6f81 with SMTP id hi3-20020a17090b30c300b00262df796f81mr12562185pjb.24.1688586152492; Wed, 05 Jul 2023 12:42:32 -0700 (PDT) Received: from yoga ([2400:1f00:13:c628:31be:68ae:86f5:48b9]) by smtp.gmail.com with ESMTPSA id y17-20020a170902b49100b001b54dcd84e2sm19286004plr.240.2023.07.05.12.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:42:31 -0700 (PDT) Date: Thu, 6 Jul 2023 01:12:23 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/7] scripts: python: Extact necessary information from process event Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/p= erf/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 +# 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 +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 =3D (param_dict['sample']['time'] // 1000) / 1000 + pid =3D param_dict['sample']['pid'] + tid =3D param_dict['sample']['tid'] + thread_name =3D param_dict['comm'] + start_time =3D time_stamp if not start_time else start_time + if param_dict['callchain']: + stack =3D [] + for call in param_dict['callchain']: + if 'sym' not in call: + continue + stack.append(call['sym']['name'] + f' (in {call["dso"]})') + if len(stack) !=3D 0: + stack =3D stack[::-1] + else: + mod =3D param_dict['symbol'] if 'symbol' in param_dict else '[unknown]' + dso =3D param_dict['dso'] if 'dso' in param_dict else '[unknown]' --=20 2.34.1 From nobody Tue Oct 21 00:47:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0658C0015E for ; Wed, 5 Jul 2023 19:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233781AbjGEToz (ORCPT ); Wed, 5 Jul 2023 15:44:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233614AbjGETou (ORCPT ); Wed, 5 Jul 2023 15:44:50 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C65121990; Wed, 5 Jul 2023 12:44:39 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1b895a06484so18453565ad.1; Wed, 05 Jul 2023 12:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688586279; x=1691178279; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=yclTrzBLsbaEGvGCEpSUrAGw5ZKqNxDtNfrRanKfTkM=; b=KK357Qafb3bDy59jGWZwHPs6hzA/M9nIBL7YEFkn14veMx8Jw+PLHXDidJo2JeUUzT B0Gs0Cykr03evtx0ZNnx0o8PII8ZKrBIbdO2LgVGMN48DYjMWzzVkuYVa3Gkt42sIYRF oTVsmbnhgj1wANPd40Cxnu3ZGndhD+Bo9+yfV0qjv3j16Ipm9/Fi/jaSemgjOYXiJ10H FkJ5gEwWiG9FcpQQ4LzPTDkCqhAMmNP+h2TICzNtkU94mSqERZvSrvHETz15D7FlUhcZ XYgxXNLhA7oZoNamzQleYZnezkZO2haJoKbUft+2v3+B7UioMAMQQQU54nLVSlXXc+a0 67IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688586279; x=1691178279; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yclTrzBLsbaEGvGCEpSUrAGw5ZKqNxDtNfrRanKfTkM=; b=G7Qh8qtyK5njiWSxAytNrbSIOmMqfJ6H0c16BZcLAosmrTlPw5ZQrsQO+fnxsPs9La QJ2mhW5L/Xy78Z6xoFpd+ZV4AcWkTfzKl668KV2x0qKMH412FBURGopfFvq12//4f8Z/ OV4FbOGd34WFqpyXVrJ6YlZXq+i7yNbxXh1uAAA2jgRCvBMaBn46Ajo6PXCLuEUJLRdl 07OPIOjRpimGFdoCwpoDIXVSXv7sr04w8l1osqHEchydKHN2THJ7ECxQm2lJjPlMfghd Walf8Z6TRA0yJ9pwq5+iBw2mKKWEZb0oNTM4tAyxH6D4r66gBOgXV37oGwr7G/ymY0rQ b1Xw== X-Gm-Message-State: ABy/qLYfFi+AcwWVVThLByJdzFBJRDyJSJZUGLBHm0MSgM8S8ehWq9Hy jPOhAT8bJXYX88UAzUyUgR4= X-Google-Smtp-Source: APBJJlGhvTrWD9TaRY6Fyr9MEAhGSBRSIMAIqvbM2M6VIgtotIllmt2k9luwDXM+lQ0VP12DJuAbKQ== X-Received: by 2002:a17:902:f68c:b0:1b8:a6be:ead3 with SMTP id l12-20020a170902f68c00b001b8a6beead3mr4613918plg.57.1688586279163; Wed, 05 Jul 2023 12:44:39 -0700 (PDT) Received: from yoga ([2400:1f00:13:c628:31be:68ae:86f5:48b9]) by smtp.gmail.com with ESMTPSA id bg6-20020a1709028e8600b001b3d0aff88fsm19298830plb.109.2023.07.05.12.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:44:38 -0700 (PDT) Date: Thu, 6 Jul 2023 01:14:31 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] scripts: python: Introduce thread sample processing to create thread Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The _addThreadSample function is responsible for adding a sample to a speci= fic thread. It first checks if the thread exists in the thread_map dictionary. If not, it creates a new thread using the _createtread function and assigns it to the thread_map. Finally, it calls the 'addSample' method of the threa= d, passing the thread name, stack, and timestamp. Signed-off-by: Anup Sharma --- .../perf/scripts/python/firefox-gecko-converter.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index ce663840d212..95b061a97cbc 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -18,7 +18,20 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \ from perf_trace_context import * from Core import * =20 +thread_map =3D {} +start_time =3D None + def process_event(param_dict): + global start_time + global thread_map + + def _addThreadSample(pid, tid, threadName, time_stamp, stack): + thread =3D thread_map.get(tid) + if not thread: + thread =3D _createtread(threadName, pid, tid) + thread_map[tid] =3D thread + thread['addSample'](threadName, stack, time_stamp) + time_stamp =3D (param_dict['sample']['time'] // 1000) / 1000 pid =3D param_dict['sample']['pid'] tid =3D param_dict['sample']['tid'] --=20 2.34.1 From nobody Tue Oct 21 00:47:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7B9BC0015E for ; Wed, 5 Jul 2023 19:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233335AbjGETri (ORCPT ); Wed, 5 Jul 2023 15:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230135AbjGETrf (ORCPT ); Wed, 5 Jul 2023 15:47:35 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EAFCE3; Wed, 5 Jul 2023 12:47:35 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1b88e5b3834so18917555ad.3; Wed, 05 Jul 2023 12:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688586454; x=1691178454; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=eVgKMbQsMcOPsIdlP9IfALADbyS9NwmXrwLOYeG98C0=; b=Sso1w05kGo2fnbRz0gtCa4jHE7pHCkIUtUW3QZecc/R7sW9Q+LroXJYYhMo9PHeH+K 4mcsTVbjvwAQchMmJNoXOBj4RAqZOGjMcpXPbrte5OXx74pSPMQ/H7XY9ugof3GHShU/ szztPTrgvLDWqTYtjIeQB6UEsNqcmvxVsPRoz8t4+2zJL09qeASUPy3oHqjYeEIVNWLr XVMgTL54+KEabZHMnK46O73kLgdLNfyK+C9K9GrzRqjNNTxRZeFWJ6+WhQ35Tp4+8tLv +gGMyMr2KDlP0+Nw2OAkaT9OEOtCV3uEaFxJuleDZSOZyDCrbMjETslCFVv2hI53oiSy nwvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688586454; x=1691178454; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=eVgKMbQsMcOPsIdlP9IfALADbyS9NwmXrwLOYeG98C0=; b=dnOadaks0evvhsTngRYumcdqdbT30JtGOy6enA8dluPjCn42N/KNZvPidzWa+X28ms 3pk9MzZtmNg2nHdI6N7OutFoTGdS6T7SC2HbcQVX3HWn9twhf+fY7VrQPFdvrXvXMeBk ohZtvQHY4BU51whco7px0n9sIQSHJ1k2T8DY1QMGvHOvkdZJi7E2Ojel3u4zKAOK/hq8 WVuuGDKBGhCcaGk5E251Vn11RacsW7NpDesCqY0WrBNBVIP9cnk9zPX0S/b3CW0Lkz5A xxyGekBT25JrJ65lTPwVFRrBeqCfp8Evo2iuXTD67q5AX6umkEOTqztNqEqCRQmcdknZ 5NDg== X-Gm-Message-State: ABy/qLaAuC8HBgac37ORN5XOkofn+M2ws+y4pSUJcq7bOUGC2X+F8rad Qeyv6kKQ58Slahob/dXAH6s= X-Google-Smtp-Source: APBJJlEuCki5uVW4uNG+AFHC9qSP+9RkSDwavc1CKmEIOcK6Yyxj9pXyy8G56H7ANCpBS1RvoAlBtQ== X-Received: by 2002:a17:903:41c7:b0:1b8:b433:7fa with SMTP id u7-20020a17090341c700b001b8b43307famr7220ple.13.1688586454487; Wed, 05 Jul 2023 12:47:34 -0700 (PDT) Received: from yoga ([2400:1f00:13:c628:31be:68ae:86f5:48b9]) by smtp.gmail.com with ESMTPSA id s12-20020a170902988c00b00198d7b52eefsm19333252plp.257.2023.07.05.12.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:47:34 -0700 (PDT) Date: Thu, 6 Jul 2023 01:17:26 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] scripts: python: create threads with schemas Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The markers structure defines the schema and data for thread markers, including fields such as 'name', 'startTime', 'endTime', 'phase', 'category', and 'data'. The samples structure defines the schema and data for thread samples, including fields such as 'stack', 'time', and 'responsiveness'. The frameTable structure defines the schema and data for frame information, including fields such as 'location', 'relevantForJS', 'innerWindowID', 'implementation', 'optimizations', 'line', 'column', 'category', and 'subcategory'. The purpose of this function is to create a new thread structure These structures provide a framework for storing and organizing information related to thread markers, samples, frame details, and stack information. Signed-off-by: Anup Sharma --- .../scripts/python/firefox-gecko-converter.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index 95b061a97cbc..e56864e78dc1 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -24,6 +24,47 @@ start_time =3D None def process_event(param_dict): global start_time global thread_map + def _createtread(name, pid, tid): + markers =3D { + 'schema': { + 'name': 0, + 'startTime': 1, + 'endTime': 2, + 'phase': 3, + 'category': 4, + 'data': 5, + }, + 'data': [], + } + samples =3D { + 'schema': { + 'stack': 0, + 'time': 1, + 'responsiveness': 2, + }, + 'data': [], + } + frameTable =3D { + 'schema': { + 'location': 0, + 'relevantForJS': 1, + 'innerWindowID': 2, + 'implementation': 3, + 'optimizations': 4, + 'line': 5, + 'column': 6, + 'category': 7, + 'subcategory': 8, + }, + 'data': [], + } + stackTable =3D { + 'schema': { + 'prefix': 0, + 'frame': 1, + }, + 'data': [], + } =20 def _addThreadSample(pid, tid, threadName, time_stamp, stack): thread =3D thread_map.get(tid) --=20 2.34.1 From nobody Tue Oct 21 00:47:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E36A9EB64DD for ; Wed, 5 Jul 2023 19:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233683AbjGETsT (ORCPT ); Wed, 5 Jul 2023 15:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234363AbjGETsL (ORCPT ); Wed, 5 Jul 2023 15:48:11 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFEFE3; Wed, 5 Jul 2023 12:48:10 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5577900c06bso5445893a12.2; Wed, 05 Jul 2023 12:48:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688586490; x=1691178490; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=H8c7Bp6w5fylw1SD1uv/K3VcW7YeFvhEhx9WsbO4Uk4=; b=VwC/7T6rXHKCboVLiOSQ60+XsauCs5vu855Ri1MRU6fgeob30zBSq7qObxfjfC7lFz 7xElentszw6z26+apN7wG7/++uA0gsZwmsW4my3yX0on8r11AN9+QBueOFs9ITdMDBgJ N1TW2wLWmERtm5jU7WitNh6oOpXahSV+lOVD9aOICiufqowq4b3AnX/XTTNjYf9gi1iA UbERjSi0N3+L+edZJeR3y63Gp5l/RdoDnKG/5HiEtBVLZW8WiNxHxDda+gJlPhOoi5Xn SKD7dDxoApFBrRb4ahPajtnqcgBwfkgJOod9gWGoo8iYONTgdklDnMi239wrS4DBuX1H Xj3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688586490; x=1691178490; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=H8c7Bp6w5fylw1SD1uv/K3VcW7YeFvhEhx9WsbO4Uk4=; b=OXq1VRio4jh3Lj+s5fhwvudPQP94Ym8a2WKfebPWIMCP4nQ5E0n4srpwHsYmmZJkqX lZ4AScNtUd5Om0M3oFWRG+6oXVkiRhxljW8dEpgcOr4V/AYis49Dlbx52cJTqfNrmbUv /3VAb/JrBgyiQE96el4oZ0wkv7QAMfAxKM1en2Dl4e0fMTWLRYV5Fx0mI6biB7vj+xIh yvZx4SCkzDfyW3Ndq6i8JUwpuILLbZugmm3xljGz5Hiu3oEst91f5dyeYvUZZBjbI3Qk 8dB2r2RwHiTtioluH64eHVBJeKv6PHh+iYbFMKOBw4LxtYRD3stKD3cqNs28/DWse80T Q0Tw== X-Gm-Message-State: ABy/qLaBzpnvo+5FPSouDSvDuSG8zbaqe9DmBw5wdjEpMUKTuLhPIuM7 2xc2rOMN9semxb7ebEQAs4A= X-Google-Smtp-Source: APBJJlFask0sSoE46kwZpLV7qEUJqwpTqvU/AeUJNg80TLOzxT6fteX2wngGxbhMVEs4HOxwwGFUpA== X-Received: by 2002:a05:6a20:2588:b0:12f:cd72:ab6f with SMTP id k8-20020a056a20258800b0012fcd72ab6fmr2169640pzd.51.1688586489984; Wed, 05 Jul 2023 12:48:09 -0700 (PDT) Received: from yoga ([2400:1f00:13:c628:31be:68ae:86f5:48b9]) by smtp.gmail.com with ESMTPSA id d12-20020aa7814c000000b00682a61fa525sm3322801pfn.91.2023.07.05.12.48.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:48:09 -0700 (PDT) Date: Thu, 6 Jul 2023 01:18:02 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] scripts: python: implement get or create stack function Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The get_or_create_stack function is responsible for retrieving or creating a stack based on the provided frame and prefix. It first generates a key using the frame and prefix values. If the stack corresponding to the key is found in the stackMap, it is returned. Otherwise, a new stack is created by appending the prefix and frame to the stackTable's 'data' array. The key and the index of the newly created stack are added to the stackMap for future reference. Signed-off-by: Anup Sharma --- tools/perf/scripts/python/firefox-gecko-converter.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index e56864e78dc1..6f69c083d3ff 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -65,6 +65,17 @@ def process_event(param_dict): }, 'data': [], } + stringTable =3D [] + + stackMap =3D dict() + def get_or_create_stack(frame, prefix): + key =3D f"{frame}" if prefix is None else f"{frame},{prefix}" + stack =3D stackMap.get(key) + if stack is None: + stack =3D len(stackTable['data']) + stackTable['data'].append([prefix, frame]) + stackMap[key] =3D stack + return stack =20 def _addThreadSample(pid, tid, threadName, time_stamp, stack): thread =3D thread_map.get(tid) --=20 2.34.1 From nobody Tue Oct 21 00:47:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 750D7EB64DD for ; Wed, 5 Jul 2023 19:48:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233793AbjGETsz (ORCPT ); Wed, 5 Jul 2023 15:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233699AbjGETsn (ORCPT ); Wed, 5 Jul 2023 15:48:43 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59610FC; Wed, 5 Jul 2023 12:48:42 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6682909acadso32574b3a.3; Wed, 05 Jul 2023 12:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688586522; x=1691178522; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Nwmiw8kqzz8HG3/q8vV707Kb04avPuRY7Vptw/E/9iA=; b=XMX9vGJ3vgS1YR9suzkK1qqrmkpIqmrmAsgRRYbxxTDEBj9gP/e/b8d4VzRXQj+ZUe +QlXqk0PGs7Ht2p+i+KqE/0CHwQjCDPIwxj3J0sm9XQolhAAITmHVZIGPVzf+4jcA93L ahFqoOe59sQUzcydyip4GKLGo9GemKzuf2suRmYl3bI8jeOVQac7LZmDzAfs8znF/ioz JtKjRfKSo00wk7Ar9V5DE5h9RdOKdsCjYT32SxPi3WkFkDQRY62cSiCKMllaURNb8BFF p5tiLEFB6X3AocwXzj2R4LOVl7h00qmFJl2DDpDcJHW1E3UBNyyB8QIcaLy8R2Gyh/Kf u/rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688586522; x=1691178522; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Nwmiw8kqzz8HG3/q8vV707Kb04avPuRY7Vptw/E/9iA=; b=Ml1i0/8sqz1F0e7ME/56bpJKOkyVkIkxKsVNAXExN8baULVlqyjWUFyN0dQe2WFWPL fi4t4fSoIDwmKcSbtJMsU8cFgESH9V8+f1ZZfvmdlF1DXdp/HdHWqXV6Ra7yl096H/m6 lNf3JYGvd/TP0NnXE/4eIL8XyzdWAkwdVZVqiujW/j6sRxQDsFOOXjtIzmctMAkQrsUP qeIpwVDTHRkWoyDot/PEb5PR7d0KHM29BAVCwJ1BRvuOXgq7cEFBOGk+H851ZDUVu+5l yL2l4J5sk01N3FeMTxCdBUA81+7PQJroJwzFVcL74SQtShVaW+e/oZdT8Rb4irfLi1oC IxMA== X-Gm-Message-State: ABy/qLby4akpR9+bXnw2EpnVHB7ARl8UkZ2FimyvUlfYFLV20h36hZwo gE9B6Y40P/U/kR1vN8ca8J4= X-Google-Smtp-Source: APBJJlHg+O+p8sad9sRSUZCKtzRPgzmOdoXVj+MU4BKD8Zr76cr6X4Pf8mLTbqeSC/zaoKAbZ5bKIA== X-Received: by 2002:a05:6a00:248f:b0:668:7292:b2c2 with SMTP id c15-20020a056a00248f00b006687292b2c2mr15585714pfv.2.1688586521656; Wed, 05 Jul 2023 12:48:41 -0700 (PDT) Received: from yoga ([2400:1f00:13:c628:31be:68ae:86f5:48b9]) by smtp.gmail.com with ESMTPSA id x16-20020a056a00271000b0067459e92801sm16197721pfv.64.2023.07.05.12.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:48:40 -0700 (PDT) Date: Thu, 6 Jul 2023 01:18:33 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/7] scripts: python: implement get or create frame function Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The get_or_create_frame function is responsible for retrieving or creating a frame based on the provided frameString. If the frame corresponding to the frameString is found in the frameMap, it is returned. Otherwise, a new frame is created by appending relevant information to the frameTable's 'data' array and adding the frameString to the stringTable. The index of the newly created frame is added to the frameMap. Signed-off-by: Anup Sharma --- .../scripts/python/firefox-gecko-converter.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index 6f69c083d3ff..d5b9fb16e520 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -77,6 +77,39 @@ def process_event(param_dict): stackMap[key] =3D stack return stack =20 + frameMap =3D dict() + def get_or_create_frame(frameString): + frame =3D frameMap.get(frameString) + if frame is None: + frame =3D len(frameTable['data']) + location =3D len(stringTable) + stringTable.append(frameString) + category =3D KERNEL_CATEGORY_INDEX if frameString.find('kallsyms') != =3D -1 \ + or frameString.find('/vmlinux') !=3D -1 \ + or frameString.endswith('.ko)') \ + else USER_CATEGORY_INDEX + implementation =3D None + optimizations =3D None + line =3D None + relevantForJS =3D False + subcategory =3D None + innerWindowID =3D 0 + column =3D None + + frameTable['data'].append([ + location, + relevantForJS, + innerWindowID, + implementation, + optimizations, + line, + column, + category, + subcategory, + ]) + frameMap[frameString] =3D frame + return frame + def _addThreadSample(pid, tid, threadName, time_stamp, stack): thread =3D thread_map.get(tid) if not thread: --=20 2.34.1 From nobody Tue Oct 21 00:47:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D857C0015E for ; Wed, 5 Jul 2023 19:49:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233952AbjGETt1 (ORCPT ); Wed, 5 Jul 2023 15:49:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233699AbjGETtX (ORCPT ); Wed, 5 Jul 2023 15:49:23 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23890E3; Wed, 5 Jul 2023 12:49:23 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1b895a06484so18482905ad.1; Wed, 05 Jul 2023 12:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688586562; x=1691178562; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Gwp8fA2qpy452CipUIAT5AcsUa4bLXq9Z9L1naFewyg=; b=AH2xCWzJyQrh3RwBnsTSDzNuG04w+HjuNr1vKGp1Q3oiaKhXGYhefX7K75Q/TkYe6B BFN6d+A9sDXrKTkD68wNZPLnuYkkfBfpqMPWDIA4qgDTgwx/qqdOnd+lZZR4OuEaUpeq zqFWjhES/f2nWWF97kyhFafsDHxW/r4Wks0FY3UxCa1kLnVdd4VnBQTWjk3WSRKIA7kK BjKzsLAuDRCrlA+IBXi6UHTtj3hKGeB86lnwVw9QdHvJiQAlaVDMsxeWOBlLSCclgucj /oMKLRzNSm2XeqkQ568W69PhOu2thyMN1Jufo8wR2nAcmdwpoXty3bDXA2iMBWQfyluh oj3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688586562; x=1691178562; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Gwp8fA2qpy452CipUIAT5AcsUa4bLXq9Z9L1naFewyg=; b=NWUznAubtEtvciU4RCtj8hlw0rHNhVaOWTj6eWSrQxTvIpeps44DWomlpNALwTKgha TGMoj8NfNn8IXhbQba50ET6m/HPhWW42MSdMyWfm+xIZCKuiAOHKm/OohsfSMdjuAuzj ARTAa6/0L3rRov4rFCTMg4uyb7/oxWv9fohaj0ALBMu49Rb/gJQdSV3lF9CwOKWtfwTX 6Fa1zxKQ0zrJ7ypHFtb8KuKBuFzTnaHlfLDS1//RNimN1qHOk+Nl2CsB5Up27vkVRgHa rpLUv76tU7FkgrzZ5zyDCn7eqz4uUPq9km3Nx1+TbMCA1AbOcutgMAjP9scRtQ5eAnCk SJJw== X-Gm-Message-State: ABy/qLYHu5w10TrFwO95hV3XE3dFC+Xh0EmQfzCNgDWMcQe9Amyr/AHL pzzCbajnJZzyhalo1UCtSwc= X-Google-Smtp-Source: APBJJlFPwzvYIzNEY+bAyj+fX3xFQcHUHiPP3qHW3xU7+OplVAcUuNMEJjLTCT58P9FDJEdfbDGkmA== X-Received: by 2002:a17:903:2281:b0:1b6:6b90:7c2f with SMTP id b1-20020a170903228100b001b66b907c2fmr16773053plh.55.1688586562475; Wed, 05 Jul 2023 12:49:22 -0700 (PDT) Received: from yoga ([2400:1f00:13:c628:31be:68ae:86f5:48b9]) by smtp.gmail.com with ESMTPSA id 4-20020a170902c24400b001b86f410341sm9812547plg.189.2023.07.05.12.49.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:49:22 -0700 (PDT) Date: Thu, 6 Jul 2023 01:19:13 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] scripts: python: implement add sample function and return finish Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The addSample function appends a new entry to the 'samples' data structure. It takes the thread name, stack array, and time as input parameters and if the thread name differs from the current name, it updates the name. The function utilizes the get_or_create_stack and get_or_create_frame methods to construct the stack structure. Finally, it adds the stack, time, and responsiveness values to the 'data' list within 'samples'. The finish function generates a dictionary containing various profile information such as 'tid', 'pid', 'name', 'markers', 'samples', 'frameTable', 'stackTable', 'stringTable', 'registerTime', 'unregisterTime', and 'processType'. Signed-off-by: Anup Sharma --- .../scripts/python/firefox-gecko-converter.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index d5b9fb16e520..910e598c743f 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -110,6 +110,35 @@ def process_event(param_dict): frameMap[frameString] =3D frame return frame =20 + def addSample(threadName, stackArray, time): + nonlocal name + if name !=3D threadName: + name =3D threadName + stack =3D reduce(lambda prefix, stackFrame: get_or_create_stack + (get_or_create_frame(stackFrame), prefix), stackArray, None) + responsiveness =3D 0 + samples['data'].append([stack, time, responsiveness]) + + def finish(): + return { + "tid": tid, + "pid": pid, + "name": name, + "markers": markers, + "samples": samples, + "frameTable": frameTable, + "stackTable": stackTable, + "stringTable": stringTable, + "registerTime": 0, + "unregisterTime": None, + "processType": 'default' + } + + return { + "addSample": addSample, + "finish": finish + } + def _addThreadSample(pid, tid, threadName, time_stamp, stack): thread =3D thread_map.get(tid) if not thread: --=20 2.34.1 From nobody Tue Oct 21 00:47:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3DACC0015E for ; Wed, 5 Jul 2023 19:50:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233995AbjGETuH (ORCPT ); Wed, 5 Jul 2023 15:50:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233637AbjGETuD (ORCPT ); Wed, 5 Jul 2023 15:50:03 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC119172B; Wed, 5 Jul 2023 12:50:02 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-53fa455cd94so3383720a12.2; Wed, 05 Jul 2023 12:50:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688586602; x=1691178602; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8tyoCCM37OnwHyJMTXYnRXAELsPqSydQwA/qPcmdHVo=; b=FVviDHXA0yGiBRWeFvNZ6ueAyefkaEwuzhg5cADlfy3G2sIIFHnJrjmzsiHQS2lyYT 0KqXT8Vb+xu6y95CHbTY6nKr3FsYAuzrPYr4BmCWwbmwNFE7NzI3F4WNNSazySAVmHv3 7HeFEDq5zqiiL8RqNI0CtepU3kCaQ9km/DMbVvgANAiVfs1GlvapnjwAXFmzqxvx/E2V HgudjYIwo4P/VQHRCs+UwEws4eRKtGEONVO7liz8qMbzXuhs1PzmKH/eVrHl66Iddefx EvbZI0137mSGCzUk2YQ+CZdgts2QMzDPaHcZbwEbycqelsikp7tHrKkiKNNPrBULyA/4 H/GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688586602; x=1691178602; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8tyoCCM37OnwHyJMTXYnRXAELsPqSydQwA/qPcmdHVo=; b=M4XIA8ywtR1qT6+FuNZaMnlgj0kVOPFim4/C7h8XsciTFxLIojRpzF+G8v9labAXwb h/GO0n6dXgd4vDwrsYu0OaHC68jBQP40TMy1lWF3QRzzQ8W2H0S1glNRLm4kIJ8DOe7Z 6Zw1ktwh0zjsifRpo8Emm4HK9PAGP1ZtmtIa8iEjguu6POcFmkQEGyc5JhjVqF6/u7ec w7usTA3k6dmiaJLzAIlNiIGsBUvHvCM4gtP7qEKllzmAOfDCe+PwOMepK/taqMHYVYPs OpqVlVmnts9dboiAShBF9YuXsrq9y8of9MKXTkSDj0vaSuM+H2+mEts+g39XmxDv7m2T eKsg== X-Gm-Message-State: ABy/qLbJW9Zi2AFJ/owGwoZ9mK4OVYQbS+ixJGKVbODWa5t0/OdVvfxL q93fjDkdYf4AoXV438T27d8= X-Google-Smtp-Source: APBJJlHeLo3E50/tqH2jihcjnkuXjQBe9KohXjXTPE+lSDxOcA1T+QQDhm5ScmIESeySqsUaB2K7Aw== X-Received: by 2002:a05:6a20:2583:b0:12e:4496:c063 with SMTP id k3-20020a056a20258300b0012e4496c063mr11786012pzd.2.1688586602055; Wed, 05 Jul 2023 12:50:02 -0700 (PDT) Received: from yoga ([2400:1f00:13:c628:31be:68ae:86f5:48b9]) by smtp.gmail.com with ESMTPSA id u15-20020a17090341cf00b001b8a85489a3sm3275110ple.262.2023.07.05.12.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 12:50:01 -0700 (PDT) Date: Thu, 6 Jul 2023 01:19:54 +0530 From: Anup Sharma To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Anup Sharma , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/7] scripts: python: Add trace end processing and JSON output Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Also added _addThreadSample call which was missing. Signed-off-by: Anup Sharma --- .../scripts/python/firefox-gecko-converter.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index 910e598c743f..6a2a4d816799 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -18,9 +18,47 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \ from perf_trace_context import * from Core import * =20 +USER_CATEGORY_INDEX =3D 0 +KERNEL_CATEGORY_INDEX =3D 1 thread_map =3D {} start_time =3D None =20 +CATEGORIES =3D [ + {'name': 'User', 'color': 'yellow', 'subcategories': ['Other']}, + {'name': 'Kernel', 'color': 'orange', 'subcategories': ['Other']} +] + +PRODUCT =3D os.popen('uname -op').read().strip() + +def trace_end(): + thread_array =3D list(map(lambda thread: thread['finish'](), thread_ma= p.values())) + for thread in thread_array: + key =3D thread['samples']['schema']['time'] + thread['samples']['data'].sort(key=3Dlambda data : float(data[key]= )) + + result =3D { + '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=3D2) + def process_event(param_dict): global start_time global thread_map @@ -159,6 +197,8 @@ def process_event(param_dict): stack.append(call['sym']['name'] + f' (in {call["dso"]})') if len(stack) !=3D 0: stack =3D stack[::-1] + _addThreadSample(pid, tid, thread_name, time_stamp, stack) else: mod =3D param_dict['symbol'] if 'symbol' in param_dict else '[unknown]' dso =3D param_dict['dso'] if 'dso' in param_dict else '[unknown]' + _addThreadSample(pid, tid, thread_name, time_stamp, [mod + f' (in {dso})= ']) --=20 2.34.1