Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp458108rdb; Tue, 5 Dec 2023 09:55:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHod8CN1GFyOFWmZx5qbwWEH37K2RtN3qfFu2neCTfCBjrvb2TQlT/gIYO25p+qD8/u6Czr X-Received: by 2002:a05:6358:3a24:b0:170:17eb:7c54 with SMTP id g36-20020a0563583a2400b0017017eb7c54mr6598278rwe.39.1701798917422; Tue, 05 Dec 2023 09:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701798917; cv=none; d=google.com; s=arc-20160816; b=hVdvXm7CmdPuEpNqVQbwFZGTgeZsYo/qmr/iFyFe+L1WplxyYSXnCMsNmNR9NuNAEg cUDD2db1XhY4jgPmPzyG88phdd46iF5GZILj2kB0sX6wh8pN53bLSqbX+JPxUdbDCCPg 5tLjuPaDAnDDKfDwUEkHZRolgLtCsb25aoV3v9ypUt1NhiZ1DyXHToQ/U7kWtshsPMRJ T3/X/A2lCXpL7ti/KezDWdNZyoCGORT5F9vVijZ6sxBUxrBVWQDmo9bGCYHNBflMjLLL /HOeoQVkzaVMVjvPpsRdTd2c3rBBAqHczj2Jdvf/uwDoahY90R5+S598LKbb0M2O2wH6 i7UQ== 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=OmOpp/HChzOl55OcoRdBhcOCGVB40VIIdOg91siiF/E=; fh=23l9C2BHPK6RPpCsNjO6OHBmz3RObSh62YCFfkHd52Q=; b=yBXZwfc9wIwZ/1TyO/24LdFcc5x8NVmIWKmQeitE8oCAhCXtWmbYFGp3837wYFqQig 4IRszZz/tYrzRBGWOvI2lzQUNsHWsttzKk8+vE+y84x13dmzOZqZQ6XaFC7rnNvji6Mr IdgcP4gjvd0eVohBDPqMLHly5laxXqf/eG95mWKYimdfN8aWffp/UDfxXwbubpW3lkuc RPIl+hTajTukTOYb19dtELIObowcpgijWSTK5y+9fqN6NbUmaR7MVz2MKKBm1uZdUIQx kLJhRCr/dYPkzXsfvp98+Q7QmtZ7+gOrdqj3e0AfirwtaL6IC95vxMq4Yuw/L1O+JamR WsEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yVB3bDT+; 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 v14-20020a63480e000000b005be01a390b5si3642214pga.472.2023.12.05.09.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 09:55:17 -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=yVB3bDT+; 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 ABB5980A0E15; Tue, 5 Dec 2023 09:55:14 -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 S232117AbjLERzA (ORCPT + 99 others); Tue, 5 Dec 2023 12:55:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbjLERy7 (ORCPT ); Tue, 5 Dec 2023 12:54:59 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F5EE135 for ; Tue, 5 Dec 2023 09:55:05 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-50bed6c1716so93e87.0 for ; Tue, 05 Dec 2023 09:55:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701798903; x=1702403703; 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=OmOpp/HChzOl55OcoRdBhcOCGVB40VIIdOg91siiF/E=; b=yVB3bDT+TRHHdZEeDwK/qzT0VXvJRuZQ7JIognxmdVhKQCz1IUnZH+wUWYc0lFfA10 LbRBpQ2hkai70hPS6feWk3kECLJpSj/MIPca5/hd2vl8kzYPkhQX512D5UZyw9VrbKaa 6FcLU+IprOJcXrVstoWJuvp0W8pwVspVUCioHFuzWJF1SLOKgCvTCMRN97WJlaRufn8e q+vd8D7FWghRQuYJzeajuQZoTDEyS1mqJ5UUxQWY+Cr3YdfzYNTCDQTkbsRwtpeZgai6 wLuWquEctN/ywUn28HjSsMggwlmLcsoGjSSBelgSeZRmpULgQs+j9wqkYiXnkcHxtjYF aAqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701798903; x=1702403703; 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=OmOpp/HChzOl55OcoRdBhcOCGVB40VIIdOg91siiF/E=; b=gYrxqGJAz9cdFAjtmkLKhJahOZpFpV7TlB+J1z2vhkfFdJfpgZboFWSCsuv8dHk4Pm fFxes+XD0R8Larcgs1bxnItuHv9tvJTypkksWCKapiK+lo0Qubwp/quhPRCUpsjdyJ2u fo2DLRXFuk/jkaFdb9knNQVzKwywhNfxhAJvF+TXonnCydsitItUKQ4O9XBbCzm5vLCs 8UwjSdYrNBBiCiYuaBQifdTTvQ6QEKdVU4NgBZ7oIN3yBgdVfQVHUKp02duAoS9Xxo1L n1uB+tuVGe5baLPkJMIJYsV8tB6YoWgCjseJgIt7plRhO/diAPwKMD1TUw9Jnnw7S5Ln ZxWQ== X-Gm-Message-State: AOJu0Yxp8JOhJrv5hA16/iyddzFnq7u/oaf89XiCOVySjpdxB1ZVjau+ G19L1xxHgOyQiyMlRuLtfWAaFepxFK4lodSlrCzmLw== X-Received: by 2002:a05:6512:41a:b0:50b:ea5c:2823 with SMTP id u26-20020a056512041a00b0050bea5c2823mr151458lfk.2.1701798903337; Tue, 05 Dec 2023 09:55:03 -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: From: Ian Rogers Date: Tue, 5 Dec 2023 09:54:50 -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, 05 Dec 2023 09:55:14 -0800 (PST) On Tue, Nov 28, 2023 at 9:12=E2=80=AFAM Ian Rogers wro= te: > > 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/= tree/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 Fwiw, we hit more of these issues when running the test suite in parallel. I posted changes to do that along with a similar fix: https://lore.kernel.org/lkml/20231201235031.475293-1-irogers@google.com/ Thanks, Ian > > Best, > > Cruz Zhao