From nobody Wed Feb 11 05:41:43 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 D774AEB64DC for ; Wed, 21 Jun 2023 19:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230250AbjFUTqY (ORCPT ); Wed, 21 Jun 2023 15:46:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjFUTqV (ORCPT ); Wed, 21 Jun 2023 15:46:21 -0400 Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECB511988; Wed, 21 Jun 2023 12:46:20 -0700 (PDT) Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-3421fb63796so26442785ab.2; Wed, 21 Jun 2023 12:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687376780; x=1689968780; 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=Thtk9tiUtPYtTI2fLQD5UkCvaUPoQ9DRCNShUGEYMp0=; b=gSahabEwy5Hh3zXDXTEzS+tGvVUnr9R7Ck3AEIoX5cIb+dCnn2IE0KYinP06Fb/EMV X57O5oZJ+yzFcrOK8I3VrVNVa9taGvOSLWMdfglKt6ETHMuB21BhsCIGVvZdlVGRXjPO hJhT7zjipvI7zxZOiG8/Z1OxdOBXKZSNJa12rl5G8mKuMZ+5N/csQ1t6/0ulm+LVXpJu Gkj6JXBfPNnzshxD1dsOqFRr/meTu9Ozuow1SrZHLKSnaxqzxOxL2HyZMTGDR16oal03 /q+Wfvqu3DYGNZa9+RSvycw6akXac6RH8ZF+SSr9s7g6yOtZTi6yS7/Ysq9rygMcIDfm qS3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687376780; x=1689968780; 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=Thtk9tiUtPYtTI2fLQD5UkCvaUPoQ9DRCNShUGEYMp0=; b=Dl6i+0y8DtUCshvLUvHvU21F0r/kAsN/jxf9TZZcHHmlr+X4f9bMFdnqOLNHz4w9Kv wC4dW7jIgCVEjdOO/eoj9KitaSkpCeLeDsR3f63V16ysQcPJWCfG35Tl+75BK/T1OmsT y0gW26i7lTTE+sScbENG0TvZz4zknhfs/BZEGSkxKbhjetEbc4jrAl1IDh0LaNK9IyIX U0zxObK+LqfgtD9Y8uvjfB3psNwvSdkFMDvumqjCK6DD48n9l/GVBffchgJaxCVw55Re cSzrg0Z2kFMeogU5POExGRiDjMvD/bMJMxvfiUS05OeasDk0cTxUoijYemROfGGdV1d+ A7Ng== X-Gm-Message-State: AC+VfDwiJfowQlfzswWK0ml1VeR9C8MzkzTvn6HX/rhA3BrA7YHOccSd 2XYTsnuGH+pJgxpUTuxCJryK53OwzAti1TD1 X-Google-Smtp-Source: ACHHUZ4DzJZ6oW4X5y8F1eGwtxME5iVHvNu3wvNaBGlV6HUy10Uv4T7ZSIpvlQVtyMX9TWDa9YO8YQ== X-Received: by 2002:a92:c10e:0:b0:33f:e84c:8dfd with SMTP id p14-20020a92c10e000000b0033fe84c8dfdmr14113138ile.13.1687376780236; Wed, 21 Jun 2023 12:46:20 -0700 (PDT) Received: from yoga ([2400:1f00:13:6258:556c:aad7:2240:7612]) by smtp.gmail.com with ESMTPSA id t12-20020a17090ad50c00b0025e2b703adesm3512336pju.41.2023.06.21.12.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 12:46:19 -0700 (PDT) Date: Thu, 22 Jun 2023 01:16:12 +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 8/9] scripts: python: Finalize convertPerfScriptProfile and return profile data 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" If the stack is not empty, it is reversed and then passed to the _addThreadSample function along with other relevant information. This adds the final sample to the thread. The thread_array is generated by mapping the 'finish' method on each thread in the threadMap and collecting the results. The samples within each thread are sorted in ascending order based on the 'time' field to ensure they are in the correct order. This implementation finalizes the processing of the profile data in convertPerfScriptProfile and returns a structured profile representation I still need to get the product from the device, having little confusion on this so will implement it on next version. Signed-off-by: Anup Sharma --- .../scripts/python/firefox-gecko-converter.py | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tools/perf/scripts/python/firefox-gecko-converter.py b/tools/p= erf/scripts/python/firefox-gecko-converter.py index 866751e5d1ce..385a8b77a70a 100644 --- a/tools/perf/scripts/python/firefox-gecko-converter.py +++ b/tools/perf/scripts/python/firefox-gecko-converter.py @@ -64,7 +64,7 @@ def convertPerfScriptProfile(profile): }, 'data': [], } - =20 + stringTable =3D [] =20 stackMap =3D dict() @@ -84,7 +84,7 @@ def convertPerfScriptProfile(profile): 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 @@ -203,3 +203,36 @@ def convertPerfScriptProfile(profile): =20 stack.append(rawFunc) =20 + if len(stack) !=3D 0: + stack.reverse() + _addThreadSample(pid, tid, threadName, time_stamp, stack) + + thread_array =3D list(map(lambda thread: thread['finish'](), threadMap= .values())) + + for thread in thread_array: + # The samples are not guaranteed to be in order, sort them so that= they are. + key =3D thread['samples']['schema']['time'] + thread['samples']['data'].sort(key=3Dlambda data : float(data[key]= )) + + return { + 'meta': { + 'interval': 1, + 'processType': 0, + 'product': 'Linux perf', # TODO: get this from the system + 'stackwalk': 1, + 'debug': 0, + 'gcpoison': 0, + 'asyncstack': 1, + 'startTime': startTime, + 'shutdownTime': None, + 'version': 24, + 'presymbolicated': True, + 'categories': CATEGORIES, + 'markerSchema': [] + }, + 'libs': [], + 'threads': thread_array, + 'processes': [], + 'pausedRanges': [] + } + --=20 2.34.1