Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2127450rwe; Fri, 2 Sep 2022 08:55:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR4MLKCReTkiblADIjvVOBOVOUFTMyHcwAzVK/gbCWKFdXyBciqHkWLyXawpds/0S9fjTUmC X-Received: by 2002:a17:907:391:b0:73d:c7d5:bb51 with SMTP id ss17-20020a170907039100b0073dc7d5bb51mr27508802ejb.177.1662134129345; Fri, 02 Sep 2022 08:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662134129; cv=none; d=google.com; s=arc-20160816; b=EPoArDW8DKIv/edMrb6FsQMO//j6/CVS6eGTXWbb8WKtA+dWPORWyFiFf/QSYI+O+q qDmjXX/6sK9oZHsc6ATztLO4XXbp4kQV5b4YYYLE1pAnzCM56X6atvKZOUBQRp8szUqD nB8cvWL/51TBuj1uKFt8MKfdDUYLpParMgvg45oS7inANVHieVIT7rGvVepkzb06ZE/A A67D+P1obztpKqgB3kGTZhhlsyOoPLUjzyC1UNIjy6qCmVlMCMqvlGKAHY21hAZUkbeG vtNJ8EwNkFjuSdEbomE0RDxUL26i0wYwJ0qbdNO0wJy+/3r4T1kZ7KefcKPRux2H+bTp Pd7g== 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:dkim-signature; bh=L4JWBuMZM4V5MxL6gZECtvyeba9fHU+/Tt9D+MssGSg=; b=Zff2eV/CIJ3GAfHCma/SM/MzRQhjiFqWtMCiy86bx0UwMffMpS5Wpo6oT6eV7B1tLF 4Zs+5eFYsdC5bX3GWmMhImWKy0oh4oXdLJr+a3Hmq/9o2BitiZcziCV4ZzcygQ7ZM3oF Jk1fBR2m8XAH+ja8+cPQn//A+ZdveZVLEWxmeGieKFTsVfXYzFteoYpcJ1tmHWVy3lh5 xLxmRI2B3bN/E/RrH59XxThL6xK62DjSE+Yl2suhVL68QqmkzbZqsJZvs3qpse3z0Xh3 6qPP6TnR62t//nFHJfqxFRKkeCpEbidDC0dWzNF/wEvm2FWChuwqJxPL27RQ//CqYaF8 vHvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@scm.com header.s=dkim20220819 header.b=AfN0yqr9; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=scm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a056402194100b00446f6e9c6cesi2167467edz.351.2022.09.02.08.55.03; Fri, 02 Sep 2022 08:55:29 -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=@scm.com header.s=dkim20220819 header.b=AfN0yqr9; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=scm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236221AbiIBP3J (ORCPT + 99 others); Fri, 2 Sep 2022 11:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237073AbiIBP2f (ORCPT ); Fri, 2 Sep 2022 11:28:35 -0400 X-Greylist: delayed 598 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 02 Sep 2022 08:04:48 PDT Received: from ext6.scm.com (ext6.scm.com [5.9.60.231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E09F5F60; Fri, 2 Sep 2022 08:04:48 -0700 (PDT) Received: from mintaka.ncbr.muni.cz (mintaka.ncbr.muni.cz [147.251.90.119]) by ext6.scm.com (Postfix) with ESMTPSA id 8E07E7E803ED; Fri, 2 Sep 2022 16:46:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=scm.com; s=dkim20220819; t=1662130007; bh=QipHUAFLlQN8U0AxHQTuwbsAVXcDR9FKYRB7FW1CTBE=; h=From:To:Cc:Subject:Date:From; b=AfN0yqr9om7o+c6a7MhakZ4jromiLK15f5sJbWN7DQA4RyZ2XOttED2bN0E3my+be nHIPjP6PqX8PXXsB5TJ3BcUr2vhHKR5RKXAxpU9guMzDPG8R8ZPFg+QtAYAAvoPUjS kpwegXHb/+DcEBQDVhNspRiMVqSu3C7R8jafQj9ZnR+J8SuI0RO7/kZycDbUUSEqsF XqOQewDqkXvefRyzntnvFQusutDT+fjVL18/mooXF/BdPvikrRR0Pd6uZdWd9rceTx Sv2Td07oph8vEvSQOYBtxS/YG55kbrtWUslb7gpNySf+J0gD5H6Ka+fAz/YCysLM0K 7UzCyVyjyvfcQ== From: =?utf-8?B?VG9tw6HFoQ==?= Trnka To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Adrian Hunter Subject: perf top -p broken for multithreaded processes since 5.19 Date: Fri, 02 Sep 2022 16:46:45 +0200 Message-ID: <10137382.nUPlyArG6x@mintaka.ncbr.muni.cz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Hello, 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 =20 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 - < 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=3DPERF_TYPE_HARDWARE, size=3DPERF_ATTR_SIZE_VE= R7, config=3DPERF_COUNT_HW_CPU_CYCLES, sample_freq=3D4000, sample_type=3DPE= RF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_PERIOD, read_form= at=3DPERF_FORMAT_ID, disabled=3D1, exclude_kernel=3D1, mmap=3D1, comm=3D1, = freq=3D1, task=3D1, precise_ip=3D0 /* arbitrary skid */, sample_id_all=3D1,= mmap2=3D1, comm_exec=3D1, ksymbol=3D1, ...}, 104619, -1, -1, PERF_FLAG_FD_= CLOEXEC) =3D 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] =E2=80=A6(snip)=E2=80=A6 145184 ioctl(5, PERF_EVENT_IOC_SET_OUTPUT, 3) =3D -1 EINVAL (Invalid argume= nt) > 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=C3=A1=C5=A1 =2D- Tom=C3=A1=C5=A1 Trnka Software for Chemistry & Materials B.V.