From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D621C30653 for ; Mon, 1 Jul 2024 14:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yYit20SIJNg6jE7rNMxR4Y2aRMv/5nRvsbKIs6Ddx9E=; b=2BSp49xd4Jic98H8W/hnUS7p/Q zpLZkSKHzfCSuMMJxCY81lI5+qhDyN0+N1QL3JLy4iKz8dc33QUq5PO/mKxnTN2lBxXQl/OtmyCcE ibbfgFmI/UHHfYDLcazQ4+hwqNsuGuFhdJkKGEi6+705ExNyyfGiY87S1InaJqiL6iW6n0PHrvCsb g94HWaET0jJ9A4RtQRlGa084/Pws2gQnf62A8o8LEJTIpTsZB60TEBBNnGaL6TbJt/yA4CndQGqjN 7gWfI61eQBisKa0GmFOEBRcwpxyLuPkEIGw3I64i/OmG7rurS5VF1+yM3Vv1PAXqv6PGZdz7Rk+sX de4I6aaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOHvZ-00000003i69-3Hrl; Mon, 01 Jul 2024 14:22:45 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOHvL-00000003i2T-0963 for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2024 14:22:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 05FBD6144F; Mon, 1 Jul 2024 14:22:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98439C116B1; Mon, 1 Jul 2024 14:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719843749; bh=eROdfnaAt0I1lw6qi3i+9FPGXr4ZyqLymMFA3Dp2S20=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T2Np0kiwPfQiwXvzGNJlmcPmZ1/GHOcJHhjnfEQwhABH1VrapDa37MJTxJM8e6zP6 mgv/rRiqb8R/HNcrKP7vcORZ530T/XVQXwszxMidBYQnLeWncWBzs3ihlcxGcZr4Sh CA+iKRl+w2PfNEhm39u2cwDsK6Vor9QByI79LkhKGkumGjKV0Xjbo5QN6lq5n1SeyO VcE0yh1cw0Ma3jONw6DRIqpWoEOgQ4BfxBbT0mUH30VKDn0Du9b/KbjulG8AGbZFte QqhZKlP/IvihTgXq7wCFqujgnq1XK01b/carQluHLITjZS9MgTmDUrJdI/gJm4cO9i xNYfqUFKqoVrQ== Date: Mon, 1 Jul 2024 15:22:23 +0100 From: Will Deacon To: Yicong Yang Cc: mark.rutland@arm.com, acme@kernel.org, namhyung@kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, james.clark@arm.com, dongli.zhang@oracle.com, jonathan.cameron@huawei.com, prime.zeng@hisilicon.com, linuxarm@huawei.com, yangyicong@hisilicon.com Subject: Re: [PATCH 0/3] Perf avoid opening events on offline CPUs Message-ID: <20240701142222.GA2691@willie-the-truck> References: <20240603092812.46616-1-yangyicong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240603092812.46616-1-yangyicong@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_072231_197947_0763603D X-CRM114-Status: GOOD ( 12.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 03, 2024 at 05:28:09PM +0800, Yicong Yang wrote: > From: Yicong Yang > > If user doesn't specify the CPUs, perf will try to open events on CPUs > of the PMU which is initialized from the PMU's "cpumask" or "cpus" sysfs > attributes if provided. But we doesn't check whether the CPUs provided > by the PMU are all online. So we may open events on offline CPUs if PMU > driver provide offline CPUs and then we'll be rejected by the kernel: > > [root@localhost yang]# echo 0 > /sys/devices/system/cpu/cpu0/online > [root@localhost yang]# ./perf_static stat -e armv8_pmuv3_0/cycles/ --timeout 100 > Error: > The sys_perf_event_open() syscall returned with 19 (No such device) for event (cpu-clock). > /bin/dmesg | grep -i perf may provide additional information. I still don't see the value in this. CPUs can come and go asynchronously, so this is all horribly racy. Furthermore, there are other (racy) ways to find out which CPUs are online and whatever we do in the kernel now isn't going to help userspace running on older kernels. Will