Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9887349rwd; Wed, 21 Jun 2023 13:13:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jU6vtx01M/XHfaVmyx4vd4q5g/am0pkAFBk6sHo6M9Bhfi1fn1JmAn80k6T/HZ7aWD/W1 X-Received: by 2002:a05:6a20:7f84:b0:112:1e0d:14ae with SMTP id d4-20020a056a207f8400b001121e0d14aemr20929920pzj.7.1687378399196; Wed, 21 Jun 2023 13:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687378399; cv=none; d=google.com; s=arc-20160816; b=xSliMaXSmiW2DohxXCDSKPgq3xpRoloLrB9tAxh4UB2iCT83soEIVvd6FwkaLWLee7 202zbTyFW7RVAMWi1pROO+kSeKzkuutzH3fD7imwlsFO75Nv6VRU2boamC3YOjEh7i0p jtD3+x56gn8BZo1QqohD/w+olOgJaAy8PbuFyUn4llIlqeHLFAFHq1v4g3auL0KbwLia e62/XWknBSd7anKUgaRjOGSoENZocxoMER7Efhh5JezsT7fSciyEVqD5SETCbabay3F+ YQhsEmwB1t4mZvX0zSpWSDHF1Yc6xoWcJPFtczYQ5591ESvMuywqpqPC8Kp6fQVQ+S5B bo2g== 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-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=4I/DeYAvJKL2tY/fK091H/iltwlg6WcLtPnIUo8ZacE=; b=M4f+eAr3+kmog24z1zYseovqIhW7JOt5R4O+iw0M2USa6bISEv+xUSipX2kZQyiuq4 4FAVjL7MeWiP19EsIaz5Lj/Sc9/JWLNY1NU+aPuGlKlEWndHmasA52+Nuppibc5ZswpS a9FQ9hPGFrQBSYg2pnqvmCAzrlBsUt0PQOMfQHB5Guzwl+N8+ze7iFRGpnx5C1KLkSKs GIjSNy40cowMtP4GmUzAC0NyLkooW2iqx9k1iyjTQodwYp60kU26FRZS1CmIRfMFhHio dCH9y5p5JeRvcmqtq51vlZXvo5kxjtrKpk8voYSkcN4uTdlT5Ct8Q0I6Pg2DTCB3H9eO UQFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=jzMG6b2U; 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 x16-20020aa79a50000000b0066844d4ec59si4598028pfj.168.2023.06.21.13.13.07; Wed, 21 Jun 2023 13:13:19 -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=jzMG6b2U; 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 S230252AbjFUTpX (ORCPT + 99 others); Wed, 21 Jun 2023 15:45:23 -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-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-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 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/perf/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 = profile[:profile.index('\n')] return bool(re.match(r'^\S.*?\s+(?:\d+/)?\d+\s+(?:\d+\d+\s+)?[\d.]+:', firstLine)) +CATEGORIES = [ +{'name': 'User', 'color': 'yellow', 'subcategories': ['Other']}, +{'name': 'Kernel', 'color': 'orange', 'subcategories': ['Other']} +] +USER_CATEGORY_INDEX = 0 +KERNEL_CATEGORY_INDEX = 1 + def convertPerfScriptProfile(profile): def _createtread(name, pid, tid): markers = { @@ -70,6 +77,37 @@ def convertPerfScriptProfile(profile): stackMap[key] = stack return stack + frameMap = dict() + def get_or_create_frame(frameString): + frame = frameMap.get(frameString) + if frame is None: + frame = len(frameTable['data']) + location = len(stringTable) + stringTable.append(frameString) + + category = KERNEL_CATEGORY_INDEX if frameString.find('kallsyms') != -1 or frameString.find('/vmlinux') != -1 or frameString.endswith('.ko)') else USER_CATEGORY_INDEX + implementation = None + optimizations = None + line = None + relevantForJS = False + subcategory = None + innerWindowID = 0 + column = None + + frameTable['data'].append([ + location, + relevantForJS, + innerWindowID, + implementation, + optimizations, + line, + column, + category, + subcategory, + ]) + frameMap[frameString] = frame + return frame + def addSample(threadName, stackArray, time): nonlocal name if name != threadName: -- 2.34.1