Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4004603rdh; Tue, 28 Nov 2023 09:13:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSeScQKMUobgR3JJvtDl0Y7k0N1uckX3INiaeUV3h7njRmr5TQGRQ15wydsz0UZok37Z3Q X-Received: by 2002:a17:90a:191a:b0:285:6565:fd20 with SMTP id 26-20020a17090a191a00b002856565fd20mr13080885pjg.22.1701191607725; Tue, 28 Nov 2023 09:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701191607; cv=none; d=google.com; s=arc-20160816; b=bOP0uAGCs+N0gj0veJ4lw3Iw/Cb/NAch+7hZ/sOfPyO/mYroztheNlLd6sidijHgRp axnEpynNgMurXEz8p/jaRXvozPu6qcFOLeT9hji5CuhohYfoZlVp6UE5c1O9epDcwXKy ILFXzmhHL80b00uBCabOWuuSDCzL6/Dak0VWE0V9T7Cs99xPDgOjR2eQZlasPgc9LkA6 wbWQEhQ8ZpUpKwGv4p9eEYqYJXTtD9/iDRF0rnmDjP/JtEwrlUpq0/vEujGIhSnHtJR0 hJ3yO9hcq3pJdcIrNg84NV1toBeAu2Y6MDvnYOsTtI8ctl0yUN3P5m/80/fOg+aqAVY2 8x+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Iu2vtiWbBmtYlN1qlS9uatfpZo9be+0wU6twFhuZRYg=; fh=23l9C2BHPK6RPpCsNjO6OHBmz3RObSh62YCFfkHd52Q=; b=iEStPwONuJ1eTxLY6+FCYgHWF9FUmwlGCTjXmgqOpMTBId2QcvziK7DVrd/b9jS+tN pP5frwTQIW5ZQMfZDj9Y5tToP+FQ4Rh+rApgIRH9r9gVqAarNw4AjwGXAhl8567lUAkm R/ki51eM8wl4qCRX5SMYc0Q6wnsQxbYFsjBZ3kVNhV0QsP8h4pRjG8k75Ug+tql2nK5N 796+0pbqsQrRyFSDUCe2F8E/IwtHgAXvfCqRHMqZhtoe0W9jUAtWDcG1Hu9URwIh4sle L8wcZtfF2VL2d9nOl1SOg8AXHsorqVfOuDR8nNZ0h6tJHvadJfHCaPLSQawKcJIIhXXy AjlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="YgJ3R/fD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x19-20020a17090aca1300b002859a8aee84si9316937pjt.172.2023.11.28.09.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 09:13:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="YgJ3R/fD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DF2388056C40; Tue, 28 Nov 2023 09:13:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344566AbjK1RNJ (ORCPT + 99 others); Tue, 28 Nov 2023 12:13:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229928AbjK1RNH (ORCPT ); Tue, 28 Nov 2023 12:13:07 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E8D12C for ; Tue, 28 Nov 2023 09:13:13 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40b4fac45dbso34615e9.1 for ; Tue, 28 Nov 2023 09:13:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701191592; x=1701796392; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Iu2vtiWbBmtYlN1qlS9uatfpZo9be+0wU6twFhuZRYg=; b=YgJ3R/fD373W5NlIq7+374JDbN3vBwPvGVXFhSJ+D8fKnJpZ9hDmepjUWCLKHSyLXJ dEpxkPXjwl/nm+G8shunf2ht2TrkimUpq/TgK+0QM01A2inxKsf4ovPw/qZU2sQFApiI Cpg5CljT84hyP0f1a3dilEIkNs5rV/xzFe5C2reXm4vsxonPaBv4i93xlimksuQGOb8i stCQ2DoTRBlCak4ZLCg+ljUt5u2pPBhCGGbCFhb/iCZhuT9zm7NajG2skgf1U06EH64y tdXj3An5C+VG6kj00rAKX7i8zahILZTwJAcAORs4c3WtV9I8KfEzXn/02OQuRpTvK5cR /yfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701191592; x=1701796392; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Iu2vtiWbBmtYlN1qlS9uatfpZo9be+0wU6twFhuZRYg=; b=cqBT682l/QmnQgCk4XU9aN9Yuc3YRn3+ZlzaeM854JKGDgTXyJbHX/DDf5pYx0JmC2 BFD9u70HN882nUF14yvV/GivWVzvA3f0ptB1YAUePxiLj9d8N6S7JxOq3ovrJ/ru9xq1 FNDtmVvWekXC+PYPQRc2I+TKlwazhg4Xx2YDWIOYcJS0sKTHUbNUFY1M2tdgJIv6TXoi p64A+bt3MsQyX7ScWSX7B6HQeYsveAZoZc10ydOrI1gpjhH260lc0Seu++f6YwEngrfu U1m0x/CIeTrzTrMkONstgpyZEzVQc7uEjcVsCKAr0NY3FnIL8bhMlthZrw+tyFF49sQi Jo1g== X-Gm-Message-State: AOJu0Yw8JTr+MSOdhUSnNnZ4eHzxDnzzHPjvBLfORrqsPJpVfuAWLwiK 1qfP374Abd5vGayYG75MuF2AVe7A4LaerO9LzUH0ng== X-Received: by 2002:a05:600c:218f:b0:40b:43f4:df9e with SMTP id e15-20020a05600c218f00b0040b43f4df9emr346794wme.2.1701191592062; Tue, 28 Nov 2023 09:13:12 -0800 (PST) MIME-Version: 1.0 References: <20231122022154.12772-1-CruzZhao@linux.alibaba.com> <5ab76c0c-6333-4452-ae51-9193926c802c@linux.alibaba.com> In-Reply-To: <5ab76c0c-6333-4452-ae51-9193926c802c@linux.alibaba.com> From: Ian Rogers Date: Tue, 28 Nov 2023 09:12:57 -0800 Message-ID: Subject: Re: [PATCH] perf: ignore exited thread when synthesize thread map To: cruzzhao Cc: Namhyung Kim , mingo@redhat.com, peterz@infradead.org, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, adrian.hunter@intel.com, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Tue, 28 Nov 2023 09:13:25 -0800 (PST) On Mon, Nov 27, 2023 at 10:23=E2=80=AFPM cruzzhao wrote: > > > > =E5=9C=A8 2023/11/23 =E4=B8=8A=E5=8D=885:05, Namhyung Kim =E5=86=99=E9=81= =93: > > Hello, > > > > On Tue, Nov 21, 2023 at 6:22=E2=80=AFPM Cruz Zhao wrote: > >> > >> 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. > > > > Looks ok. But I guess you want to do the same for the leader > > thread below as well. > > > > Thanks, > > Namhyung > > > > With my testcase, no error is returned even if we don't do the same for > the leader thread blow. Well, I'll check whether the logic is still > correct if we do so. > > Many thanks for reviewing. Thanks for looking at this. Could you share the test? It looks like the thread be removed from the thread map to avoid potential future broken accesses like below: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tr= ee/tools/perf/util/synthetic-events.c?h=3Dperf-tools-next#n887 Some of the race will hopefully get narrowed by switching to a less memory intense readdir: https://lore.kernel.org/lkml/20231127220902.1315692-7-irogers@google.com/ Threads racing is an issue in this example: ``` $ sudo perf top --stdio -u `whoami` Error: The sys_perf_event_open() syscall returned with 3 (No such process) for event (cycles:P). /bin/dmesg | grep -i perf may provide additional information. ``` Generally the races are covered by the dummy event that gathers sideband data like thread creation and exits, which is created prior to synthesis. It would be nice to have a better threading abstraction to avoid these races. Thanks, Ian > Best, > Cruz Zhao