From patchwork Wed Nov 22 02:21:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cruzzhao X-Patchwork-Id: 168064 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1050899vqb; Tue, 21 Nov 2023 18:22:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5exVc8EWeyXXuTn8jEf48wRFHKRMP5SR9QK29egN7KxSniDfxm8dAoXtzUcCUfkQmZyXu X-Received: by 2002:a05:6830:154b:b0:6d3:1e5a:d928 with SMTP id l11-20020a056830154b00b006d31e5ad928mr1327713otp.9.1700619728840; Tue, 21 Nov 2023 18:22:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700619728; cv=none; d=google.com; s=arc-20160816; b=uICmCegZCLb27sYS5ksgjBy1SAiL6C6qFbLKlZ7Xpi/vfGtojsLr27//5c+DfX3Sh4 ii2VrJ9SAJyZskDRg9D8EtPeptqtySFVVldC5d/YnKaAC7Uf/W8AB+wt1ePgqi8rV64I tlh+gIBMFnwR6cLpXpHhXcsqyiZzCE0Kmuw4LlaxDxgCw3pWJxTCh10XJm0PvYGxdnVq Vutp5PI329kekKTPt/eu5D+jfhCFfNP3x0ZOjxtPuwo9YNFJoNpHjwi0aJjMxHJDS/05 YqAkkUdGfvvT9C0NMKL/J7HOdZukH6dHYLkOww6uut9Rs5BtYG9QbogWLz/3eJ4H1ZCL gaHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=qgisKt73fQumAx11GTZyQM/d5lcW2vbNFz8RC4Qej0c=; fh=e14CFnRZCKQqEEYpuba2MA9vUEvyg8O1JALRrWxbDeY=; b=Brys4Mjvg7UgtgmDRQ1AOkQZCBUIfqfQgS6d2C1ILQOGTL/QJvdpwQjCieRYajkTbN VoKpDl2+DEi5eEkjKgIBUJ8EoNf6We26Gmf6m84rVZYWbrsiaGXnQHDfduaroVY1jP4A OQBj99/FOLqT4Hx8ne/8gdE1YELkE7aVKdeqsLh5kQ9YBr6AZms2a56UThBSwBkHCKWr JJhnopaKIhxoDBILj+hgoyP1A178MwCtawwhmfLKsdbsYCn3EDeqHMKD3asV6KTluGgC 9ew9yB1+Y7L90bTfS+e3L4OZ2MQhkGPiX1ymMvzWu3mNjflUUiV6Gmt5MznHL8aeWFjI tWuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a21-20020a631a55000000b005c16f07b3e6si11485775pgm.164.2023.11.21.18.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 18:22:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BC0BA818ABDF; Tue, 21 Nov 2023 18:22:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235024AbjKVCWJ (ORCPT + 99 others); Tue, 21 Nov 2023 21:22:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjKVCWH (ORCPT ); Tue, 21 Nov 2023 21:22:07 -0500 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA171E7 for ; Tue, 21 Nov 2023 18:22:03 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R771e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=cruzzhao@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VwuMgws_1700619714; Received: from localhost.localdomain(mailfrom:CruzZhao@linux.alibaba.com fp:SMTPD_---0VwuMgws_1700619714) by smtp.aliyun-inc.com; Wed, 22 Nov 2023 10:22:01 +0800 From: Cruz Zhao To: mingo@redhat.com, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com, kprateek.nayak@amd.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH] perf: ignore exited thread when synthesize thread map Date: Wed, 22 Nov 2023 10:21:54 +0800 Message-Id: <20231122022154.12772-1-CruzZhao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 21 Nov 2023 18:22:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783229032577065879 X-GMAIL-MSGID: 1783229032577065879 When synthesize thread map, some threads in thread map may have already exited, so that __event__synthesize_thread() returns -1 and the synthesis breaks. However, It will not have any effect if we just ignore the exited thread. So just ignore it and continue. Signed-off-by: Cruz Zhao --- tools/perf/util/synthetic-events.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c index a0579c7d7b9e..43ad2298a933 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -866,14 +866,16 @@ int perf_event__synthesize_thread_map(struct perf_tool *tool, err = 0; for (thread = 0; thread < threads->nr; ++thread) { + /* + * We may race with exiting thread, so don't stop just because + * one thread couldn't be synthesized. + */ if (__event__synthesize_thread(comm_event, mmap_event, fork_event, namespaces_event, perf_thread_map__pid(threads, thread), 0, process, tool, machine, - needs_mmap, mmap_data)) { - err = -1; - break; - } + needs_mmap, mmap_data)) + continue; /* * comm.pid is set to thread group id by