From nobody Wed Feb 11 05:41:44 2026 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 DF4ACEB64D8 for ; Wed, 21 Jun 2023 19:45:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230121AbjFUTpY (ORCPT ); Wed, 21 Jun 2023 15:45:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjFUTpV (ORCPT ); Wed, 21 Jun 2023 15:45:21 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7FFB1989; Wed, 21 Jun 2023 12:45:16 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-668704a5b5bso3832656b3a.0; Wed, 21 Jun 2023 12:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687376716; x=1689968716; 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=4I/DeYAvJKL2tY/fK091H/iltwlg6WcLtPnIUo8ZacE=; b=jzMG6b2UkbNfHd1BFVwT6bgFtKIc/iOLTIjeja+SpT4LBEe2uFmQNUWTrj42yzIS7R GiF9uck2YJblOcusZCslOsmL2GXCJiTynCGfcjDiiA35bqCbI1XDJPPFGDtwqmtw2tiV GPyo3gtxdcXjWf4l2Rz3cDskyUIF0SPta4ZzvvSR01Go0w3v+ERlFsc1SaBQ0AohtUmS iCGfNC1PCqDsUIFRKi9gAqTqDJjsYdLHIBXehvAFPHjioC5wQ/uP/2o0Alg1wsrT28GF EKcvshBuQorbPymsTO5+eBHCN0NVktV/s5O6D9QA4g3OwnQ8P6oTwUngwt/dYfbnyvLf ve+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687376716; x=1689968716; 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=4I/DeYAvJKL2tY/fK091H/iltwlg6WcLtPnIUo8ZacE=; b=R9eHDaKiXFoMPeaK23L3d1NKAnqJJpdcIOE5qbOQs6gp7eK2xbFyKghCYgqEGe6GzE 5M3IpT7YnDRU1KiMfubGMEofwl+uGWexxzubtOWijjCp+bgbHAe6PI3bMRZqi4obwpmH cv6Wiy1SvNOaWFM19mDuIiN3Lmds24EAs6piGzUv8rv9EqKcZ6JNDTHFdGvH0JsHAzxc TMX//3JxJlcWtLle+21FwNGZjJBFRNJeViMxFssdclvMyBeG41MykU1MzrXSc1Awgk+2 2HzBA5HsSNlJNke6ez0hWsnPR4Ld09CisimQdFTB1UnVCyhj4Cg2bSiAkkXJpReMcX3P 2tMw== X-Gm-Message-State: AC+VfDysCsIGIo1gnGPmSEqJaqrabs89eLM9wYb77VgqXsVaaP5aS/8n e54k4iUVXDAKFCJxypVvCdY= X-Google-Smtp-Source: ACHHUZ5sLnOHTFrJfTOIFLkZtDxkM6DjmZPAKEOG41d2PxbrePFhaphUFbN1NOgmLdKR48CmAo0l3Q== X-Received: by 2002:a05:6a00:14c1:b0:668:8493:2552 with SMTP id w1-20020a056a0014c100b0066884932552mr10230277pfu.18.1687376716226; Wed, 21 Jun 2023 12:45:16 -0700 (PDT) Received: from yoga ([2400:1f00:13:6258:556c:aad7:2240:7612]) by smtp.gmail.com with ESMTPSA id a3-20020aa78643000000b006666699be98sm3267970pfo.34.2023.06.21.12.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 12:45:15 -0700 (PDT) Date: Thu, 22 Jun 2023 01:15:09 +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 7/9] scripts: python: implement get or create frame function Message-ID: <4d0ac80521ebd44322a360ac331ce2443a1f0f26.1687375189.git.anupnewsmail@gmail.com> 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 CATEGORIES list and the USER_CATEGORY_INDEX and KERNEL_CATEGORY_INDEX constants has been introduced. 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 | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index 30fc542cfdeb..866751e5d1ce 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -15,6 +15,13 @@ def isPerfScriptFormat(profile): firstLine =3D profile[:profile.index('\n')] return bool(re.match(r'^\S.*?\s+(?:\d+/)?\d+\s+(?:\d+\d+\s+)?[\d.]+:',= firstLine)) =20 +CATEGORIES =3D [ +{'name': 'User', 'color': 'yellow', 'subcategories': ['Other']}, +{'name': 'Kernel', 'color': 'orange', 'subcategories': ['Other']} +] +USER_CATEGORY_INDEX =3D 0 +KERNEL_CATEGORY_INDEX =3D 1 + def convertPerfScriptProfile(profile): def _createtread(name, pid, tid): markers =3D { @@ -70,6 +77,37 @@ def convertPerfScriptProfile(profile): 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) + =20 + category =3D KERNEL_CATEGORY_INDEX if frameString.find('ka= llsyms') !=3D -1 or frameString.find('/vmlinux') !=3D -1 or frameString.end= swith('.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 addSample(threadName, stackArray, time): nonlocal name if name !=3D threadName: --=20 2.34.1