Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35983193rwd; Mon, 10 Jul 2023 16:04:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlG4YHG9tbXjWjT2Hf0n9KzseTYGUDvPXjSCsQLR51r1Siwaml207WxbfrYJ1bHsSJYgXolm X-Received: by 2002:a17:907:d30d:b0:965:6075:d100 with SMTP id vg13-20020a170907d30d00b009656075d100mr15361289ejc.39.1689030297587; Mon, 10 Jul 2023 16:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689030297; cv=none; d=google.com; s=arc-20160816; b=Y8lBDMfJpvxTWRGPO96OWd2MAtPG6YzV1qvcssr3YxbNtiwuB21s0Cnm367/dIcikg zozCiY8sTWdFjg3CkGkpUxUNnJA7P/9MA9oISgvuggfraxTn7IckfNudnfO4vDdTxOWQ vC6q+HhSwvpMwldt6Exuse/CxiopIDilrsEeAIIYzWOVGOOy3E8GVqhjAVX5sucMF4vf vvuHiv+Iu/gGy41qN4NnTrAYtjPevKYfSYEGb3CMP3Bcw5OdUJUzCpNCKmJTIDaHqh5m LXxGYtk1hb1JTBUBPgSlaeDA87k815RBDDf/YC/VsNFohk1OOdSqUzCl2X5hziltAWJ/ O8MQ== 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=9S6N5y4xR1Mwz7JsLB8Y+2L4nPmqA79cUA7WUOzNa4A=; fh=ySq3lQcDqZDk4DVIg5WDWmDtxewj8RCaiNhSFwRH11M=; b=dKB3i0oAnngxiEl+oCGFtiAImWYFm2xy0gdNZ+N0ENkAzFPozKGDSLqxYLIYs4buYX RvAGTBkb1DkDuKEI9yslh91PoYSAMMO/lan/JQaQwen6g6ysgjNHhmpQFRcGeeJJ1HMg C5bRxq/Gm7T97LZxjQoQr8+o7yIGvMJpRi4vwENB68MN6cK5KFZJ1ZPJU1D7/8U7ihl5 R0kKR1z3sbxK/vV2GmKJn/mI45vE3w9nwltnzmzqyGsqMl0LLlfno+ExA10r/2mJ9YjR Gqfwy/oNTuVLWgHTEplZgq9z8BEF1hOoJtn8tc5HLGYd2YfuzkHmief8rPrlZnW+VAob woKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=PR9IUNeC; 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 u21-20020a17090657d500b00992f1a3b9cfsi726805ejr.363.2023.07.10.16.04.33; Mon, 10 Jul 2023 16:04:57 -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=PR9IUNeC; 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 S229848AbjGJVva (ORCPT + 99 others); Mon, 10 Jul 2023 17:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbjGJVv2 (ORCPT ); Mon, 10 Jul 2023 17:51:28 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FDBF11B; Mon, 10 Jul 2023 14:51:28 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1b9ecf0cb4cso2492565ad.2; Mon, 10 Jul 2023 14:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689025887; x=1691617887; 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=9S6N5y4xR1Mwz7JsLB8Y+2L4nPmqA79cUA7WUOzNa4A=; b=PR9IUNeCLww0G3YNvD38T3sg67j0v9zzxifS9kVOFgcChWBplUH/jI/nxFV3v2fU42 JQhdL4Vmm/VmjLGsBmkBo5Zu1IIbanZwPmjy3kr4UuuHN2umgVp7q3zBxI3NOlvBEUm+ PB2YVIrj9NuWsWjN2uCD1eVuC6X9lVvKdQOKJaQSw30iA31YUxsQ1cp1hFSa5QFiht0N RZ3sLRVfezdor+8WuJrKkPdV7taSJi5nmHE3u/IOW7BqCmgQGeKWjiG3nlt/8kd95UQn KWMuqD39xrSx4kPrHzHpBkbKVUNp4aAOStVXGudEq2aD7W56+T8GAjR+XUF5ZkE1YlZz KAOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689025887; x=1691617887; 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=9S6N5y4xR1Mwz7JsLB8Y+2L4nPmqA79cUA7WUOzNa4A=; b=llWnb3HHPQAQLaFkcOKdjQiOs6UAQAAhQS5YvFKyjbOrZc1yWNsYliuK6foy9T193V xuj6K007gTuXWllmrtpe4jO093GGtYMTfZvIvIYzPxM4pkBfR1ulZBNDcaVrosQvHgZ9 aSK+w27ES3kM3y83+7/EI8Oj3904sO4+aYV0nrLVWDQAKKr72MsOunpZ7jAv+gW5Jvfj 990mtXfLlBZvrAjIQDaH+YkNkSv/QqIubBLpZZlzkzn5UgQw5LSk2UidB9sIM0L9skaD mt6F1ubJTsXyFxwbGmtIy8SOt0gwO3fwif18rAWF6fZ0hH3rFfoYR7DDVJSTZEX6KVQJ adJw== X-Gm-Message-State: ABy/qLaq54bnnJMo1x35drdDbY4JntNWtl5gHVI7KQnDI4167UKIQ7Xj 4VDbWQ0popzn1SAor2mDWW8= X-Received: by 2002:a17:903:2305:b0:1b8:9b17:f63d with SMTP id d5-20020a170903230500b001b89b17f63dmr13872377plh.23.1689025887292; Mon, 10 Jul 2023 14:51:27 -0700 (PDT) Received: from yoga ([2400:1f00:13:76f2:d743:45e6:d02:e038]) by smtp.gmail.com with ESMTPSA id c23-20020a170902cb1700b001b9bebbc621sm358380ply.136.2023.07.10.14.51.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 14:51:26 -0700 (PDT) From: Anup Sharma X-Google-Original-From: Anup Sharma Date: Tue, 11 Jul 2023 03:21:19 +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 2/7] scripts: python: Introduce thread sample processing to create thread 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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:42:47PM -0700, Namhyung Kim wrote: > On Wed, Jul 5, 2023 at 12:44 PM Anup Sharma wrote: > > > > The _addThreadSample function is responsible for adding a sample to a specific > > 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 thread, > > 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/perf/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 * > > > > +thread_map = {} > > +start_time = None > > + > > def process_event(param_dict): > > + global start_time > > + global thread_map > > + > > + def _addThreadSample(pid, tid, threadName, time_stamp, stack): > > + thread = thread_map.get(tid) > > + if not thread: > > + thread = _createtread(threadName, pid, tid) > > Shouldn't it be '_createThread'? Yes, it should be '_createThread'. I will fix it in the next version. > > + thread_map[tid] = thread > > + thread['addSample'](threadName, stack, time_stamp) > > Why is it like this? What do you intend with the thread['addSample'] > method? Can it be simpler like a direct function call? The purpose of the addSample function is to append stack frames to the samples['data'] collection. While it could be implemented as a standalone function, doing so would increase complexity due to shared properties among threads such as pid, tid, and threadName. Although a decorator could potentially address this, it would likely result in code that is functionally and structurally similar. Alternatively, if addSample were implemented as a separate function, the shared elements would need to be repeatedly passed to the function. > And more importantly, you'd better make each patch work properly. > AFAICS it won't do the job because both _createtread() and > thread['addSample'] are not implemented yet. > > You can either move those definitions to this commit or have the > commit implementing them before this one. Thanks, Preparing commit in series is new to me. I will try to fix it in the next version. > Thanks, > Namhyung > > > > + > > time_stamp = (param_dict['sample']['time'] // 1000) / 1000 > > pid = param_dict['sample']['pid'] > > tid = param_dict['sample']['tid'] > > -- > > 2.34.1 > >