Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2717049rwb; Mon, 19 Sep 2022 08:59:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40PWbi+4vjGVwsi+6kH/U0bvCOyUEKGulo1zItV4554mcaCg2uhIl+MgjJ7Fs18s9eG/ar X-Received: by 2002:a05:6a00:158f:b0:546:b777:af17 with SMTP id u15-20020a056a00158f00b00546b777af17mr18905844pfk.51.1663603182830; Mon, 19 Sep 2022 08:59:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663603182; cv=none; d=google.com; s=arc-20160816; b=ZYRi+oM7JIJnJJKIIFt94qex84LcswrDi8m/gEb0rMuvO6uUe/PVpJ9w2rCuj6QEjH GFksAYJ7+2+iBstZLlHsPN4xMwNbzWPAQ7/Vy9zv7BUVPVHNrJm8ErYFkAtq+NGbIH7a Hp9TucPtLmBjJFDZkciWox00qPTEraJsSUsphsSwFLfOaargxN/d4lX9M4H1hW104vcz hrUWwewHGQ7L2nlgIXDu7wQ4xj95eGiLZyuGyzXOroRMx23TrcNYwV+fkP5K85XKBfoS vXfoCd4PfZxsZoTL+GFGoA70ac+6gawgAQfGMHOjFiASf+2zzusStfbpgvCY6Gqmcpv7 1EIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id; bh=jpR1tCwKp8AVnrsDASuJbOUhTGUiujU9gC/euQig1GM=; b=EkM+ad6pesg0LCvFblZTCguRh1HPobMGCyVa/pszGJfDjbla1FxqGLboSU+alUIEu/ Fn3SYzxNeusDp5mgXBxKAo2AmLuv+LpFMm4KyUu3wxDUKAw2yxH9bDKSCv5KQwQ1pmsd W3T9ed07B1eoihoedsoqp8HrI+9MNEqcUvOmbYCCh1M56mTWE83tCDVdO9bDU8XYS/eM tALzKq3lVGq5tgDbpyRXEyzBfbvdulbrrUdyd2BV67J9j1nGRuQ3S53bEYtdcr+M3EMD qEdabx5fA/LJmB8N/ja56sJvvuzSRXVFgZtxQF4FHPQjpj/DimUKQ1UqaTz7Yl6EuxfY dlxA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a17090274cc00b00176806795b7si29306685plt.351.2022.09.19.08.59.29; Mon, 19 Sep 2022 08:59:42 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229998AbiISPUl (ORCPT + 99 others); Mon, 19 Sep 2022 11:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbiISPUP (ORCPT ); Mon, 19 Sep 2022 11:20:15 -0400 Received: from wp530.webpack.hosteurope.de (wp530.webpack.hosteurope.de [IPv6:2a01:488:42:1000:50ed:8234::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 403AF5FBE; Mon, 19 Sep 2022 08:18:53 -0700 (PDT) Received: from [2a02:8108:963f:de38:eca4:7d19:f9a2:22c5]; authenticated by wp530.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1oaIXr-0000KX-7S; Mon, 19 Sep 2022 17:18:51 +0200 Message-ID: Date: Mon, 19 Sep 2022 17:18:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: perf top -p broken for multithreaded processes since 5.19 #forregzbot Content-Language: en-US, de-DE From: Thorsten Leemhuis To: "regressions@lists.linux.dev" Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org References: <10137382.nUPlyArG6x@mintaka.ncbr.muni.cz> <5eca514c-2f05-2714-b496-233e8a39fe29@leemhuis.info> In-Reply-To: <5eca514c-2f05-2714-b496-233e8a39fe29@leemhuis.info> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-bounce-key: webpack.hosteurope.de;regressions@leemhuis.info;1663600734;7005e1be; X-HE-SMSGID: 1oaIXr-0000KX-7S X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS 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 04.09.22 12:15, Thorsten Leemhuis wrote: > TWIMC: this mail is primarily send for documentation purposes and for > regzbot, my Linux kernel regression tracking bot. These mails usually > contain '#forregzbot' in the subject, to make them easy to spot and filter. > > [...] > On 02.09.22 16:46, Tomáš Trnka wrote: >> >> A bug in perf v5.19 and newer completely breaks monitoring multithreaded >> processes using "perf top -p". The tool fails to start with "Failed to mmap >> with 22 (Invalid argument)". It still seems to work fine on single-threaded >> processes. "perf record" is also unaffected. >> >> I have bisected the issue to the following commit: >> >> commit ae4f8ae16a07896403c90305d4b9be27f657c1fc >> Author: Adrian Hunter >> Date: Tue May 24 10:54:31 2022 +0300 >> >> libperf evlist: Allow mixing per-thread and per-cpu mmaps >> >> mmap_per_evsel() will skip events that do not match the CPU, so all CPUs >> can be iterated in any case. >> >> The issue can be easily reproduced using the following test: >> >> $ python - <> import time >> import threading >> th = threading.Thread(target=time.sleep, args=(3600,)) >> th.start() >> th.join() >> EOF >> >> stracing "perf top -p $(pgrep python)" yields this: >> >> 145184 perf_event_open({type=PERF_TYPE_HARDWARE, size=PERF_ATTR_SIZE_VER7, config=PERF_COUNT_HW_CPU_CYCLES, sample_freq=4000, sample_type=PERF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_PERIOD, read_format=PERF_FORMAT_ID, disabled=1, exclude_kernel=1, mmap=1, comm=1, freq=1, task=1, precise_ip=0 /* arbitrary skid */, sample_id_all=1, mmap2=1, comm_exec=1, ksymbol=1, ...}, 92061, -1, -1, PERF_FLAG_FD_CLOEXEC) = 3 >> > tools/perf/perf(evsel__open_cpu+0x287) [0x4c8ad7] >> > tools/perf/perf(cmd_top+0x1996) [0x439b26] >> > tools/perf/perf(run_builtin+0x68) [0x4a91f8] >> > tools/perf/perf(main+0x645) [0x40cad5] >> 145184 perf_event_open({type=PERF_TYPE_HARDWARE, size=PERF_ATTR_SIZE_VER7, config=PERF_COUNT_HW_CPU_CYCLES, sample_freq=4000, sample_type=PERF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_PERIOD, read_format=PERF_FORMAT_ID, disabled=1, exclude_kernel=1, mmap=1, comm=1, freq=1, task=1, precise_ip=0 /* arbitrary skid */, sample_id_all=1, mmap2=1, comm_exec=1, ksymbol=1, ...}, 104619, -1, -1, PERF_FLAG_FD_CLOEXEC) = 5 >> > tools/perf/perf(evsel__open_cpu+0x287) [0x4c8ad7] >> > tools/perf/perf(cmd_top+0x1996) [0x439b26] >> > tools/perf/perf(run_builtin+0x68) [0x4a91f8] >> > tools/perf/perf(main+0x645) [0x40cad5] >> …(snip)… >> 145184 ioctl(5, PERF_EVENT_IOC_SET_OUTPUT, 3) = -1 EINVAL (Invalid argument) >> > tools/perf/perf(perf_evlist__mmap_ops+0x2cf) [0x5d497f] >> > tools/perf/perf(evlist__mmap+0xa7) [0x4c09b7] >> > perf/perf(cmd_top+0x1ccd) [0x439e5d] >> > tools/perf/perf(run_builtin+0x68) [0x4a91f8] >> > tools/perf/perf(main+0x645) [0x40cad5] >> >> Best regards, >> >> Tomáš >> -- >> Tomáš Trnka >> Software for Chemistry & Materials B.V. > > Thanks for the report. To be sure below issue doesn't fall through the > cracks unnoticed, I'm adding it to regzbot, my Linux kernel regression > tracking bot: > > #regzbot introduced ae4f8ae16a07896 ^ > https://bugzilla.kernel.org/show_bug.cgi?id=216441 > #regzbot title perf: perf top -p broken for multithreaded processes > since 5.19 > #regzbot ignore-activity #regzbot fixed-by: 7864d8f7c088aad988c44c631f1ceed9179cf2cf