Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp721408lqt; Thu, 6 Jun 2024 17:17:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1jNdE9PK6G3+MKUbGzd/Zkf33AEt7GK3SOKfyiTGd0yooDNAHv6EMxSwsZRmUueZqg9v1h5ot5iapM6pWez5UCv1GZFvWKj+RcI7xfg== X-Google-Smtp-Source: AGHT+IFLoMDyNEZvALhOwqKb7hzMabqbdzxWWPPnZrDJRiS4SFWc1w2rKxyCjJHCbvxIVCrnAAcQ X-Received: by 2002:a50:9f21:0:b0:57a:2417:5ef4 with SMTP id 4fb4d7f45d1cf-57c508ef464mr455521a12.17.1717719443132; Thu, 06 Jun 2024 17:17:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717719443; cv=pass; d=google.com; s=arc-20160816; b=Rf4LpalNnGTrVZUSRLA4JyySZUt2j//4tnC6A5+KRjaxfvlx0Nauo3jgikcw3Xv49i I+6BW8UtutKxe8CIa+d8eBQCkMtPo+rGeYVZbprLS98swfR0Bx/FzydlyHm8MNzvqFoi 0XMCB/mln7gEWl2J3dyu8WhTKdOqDl5RJ1JPieJ1XjN3OKwWLrFPyUbC/e017bE0b95Z vm2Z4Y2ntb+sJAmRIfXQFlOJHjEwDG8teWhXkyQjT5tnRyLHfZfWOKegHIZKJs/ckCI+ +2zG1ZmoHxXGTOA3lbm9NxCndb065kk09+efgJHb3cxwOwOgeDTCcREHJvt/56ewPxgh VZ5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=D3Kxw2vR9feKYe5ZLvW8VlE1EaN+gNYZ5jf1pSQL51k=; fh=MnJwu7pvntGQZio7VTOoDhGs+0uY+jw9Wqrr1encHOY=; b=BdiuqyAnS3DUKFN46kpJ+pCySu9iv1Oub9xH38WYjU3nTFAieMkJ2wTjmCR6kfaYdC STES6F2wvoDmxFLiee5Su0Mol4XdXyjA0ytliMs7UuyHCqru97EDLQBoTEEZMxE2eufp UhV4YiKF6+ZBRHRqEemTdi/seFzpU5UWUEnWjIpfyIZg9IGU6e6rO0gWspIzYj4RAxdJ kG4qgO31UYXg1FCfH/A1bheeRzbbw08yoFDTZzt3vAHVVvruHVgveJ9PFuOPEInoIb8g B3HXC9f+K4CPb3UknzV/j3UWu9z1Nvic4TBkTJvWLARzH8DX80H1FTLwnUz3eYEJ/HPa rNOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L5v1hJaM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-205182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae0c6423si1210568a12.33.2024.06.06.17.17.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 17:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L5v1hJaM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-205182-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A3DDF1F24009 for ; Fri, 7 Jun 2024 00:17:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD81E3D6B; Fri, 7 Jun 2024 00:17:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L5v1hJaM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5705802; Fri, 7 Jun 2024 00:17:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717719432; cv=none; b=qS59/2zvDRMwj1k3b+DX/rxsFdtJhkSsD4TARkLYtE48hhz2xdPczwMlXg9kmk3JpRZnomuZnTbe3Z7n0F5VIzdnubYKdtfhe69OjTajY/heMpQne48xuFZwU1EapIpU7A4VsQUtsslm7eO3bHruG6zm81NUae5qGUAOXDkULwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717719432; c=relaxed/simple; bh=zQyKFE7i3cSnb1OcKCL8pH1n8i1hiqh2qkfclisckRQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hJI1M+p0opmEtxkzpmmWEmLWLmrXm2EdyhlkSWl/tQMDDg7w2pMXLwmhMQLJMQpyKzpFgkD8it9BJBxJ+OiI6bHnQi0mb3DISf/hnXmyK4uBcohpHwWlR5/09aoa6quDuUuYVHx1YcZjcxZ0S2bRRmYUIm51pjRQvg16Akxtnho= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L5v1hJaM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB558C32781; Fri, 7 Jun 2024 00:17:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717719431; bh=zQyKFE7i3cSnb1OcKCL8pH1n8i1hiqh2qkfclisckRQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=L5v1hJaMVcxxJxKaKAhyIdyWRWgcXppCMx72DrHAE3ph3cyX8WUj8TG5fi21RfNnV nqlcuOaYbrDA73MFi3+j+MgwgYVAmxT8wjhTfj4iyfuIfxcH0AaXkntfrW/Bew2GpS L94Rl9iBv4DdxuLC4WilcJNjAwZ+667u9PuHXW+OTKV+WnbR6sWu811PDE7vaJ/+aN e3ay6Cdd+Z9+zbYm9N8pAeIUW/t58m0xZk3Y/uEbND+AiWCXMAO4uZDv0/ZtGm2qZ1 pNYYY5DwNZyX+bO2M/yYpMJxYlU+8JiTtFFXVfBrB2lKUfZQM6I0w3UHk7CZg9qOH/ gWZAqvlRLTQXw== Date: Thu, 6 Jun 2024 17:17:09 -0700 From: Namhyung Kim To: Yicong Yang Cc: Ian Rogers , yangyicong@hisilicon.com, will@kernel.org, mark.rutland@arm.com, acme@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, james.clark@arm.com, dongli.zhang@oracle.com, jonathan.cameron@huawei.com, prime.zeng@hisilicon.com, linuxarm@huawei.com Subject: Re: [PATCH 2/3] perf: arm_pmu: Only show online CPUs in device's "cpus" attribute Message-ID: References: <20240603092812.46616-1-yangyicong@huawei.com> <20240603092812.46616-3-yangyicong@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Jun 04, 2024 at 03:43:35PM +0800, Yicong Yang wrote: > Hi Ian, > > On 2024/6/4 0:20, Ian Rogers wrote: > > On Mon, Jun 3, 2024 at 2:33 AM Yicong Yang wrote: > >> > >> From: Yicong Yang > >> > >> When there're CPUs offline after system booting, perf will failed: > >> [root@localhost ~]# /home/yang/perf stat -a -e armv8_pmuv3_0/cycles/ > >> 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. > > > > Thanks for debugging this Yicong! The fact cycles is falling back on > > cpu-clock I'm confused by, on ARM the PMU type generally isn't > > PERF_TYPE_HARDWARE and so this fallback shouldn't happen: > > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/util/evsel.c?h=perf-tools-next#n2900 > > I note your command line is for system wide event opening rather than > > for a process. It is more strange the fallback is giving "No such > > device". > > > >> This is due to PMU's "cpus" is not updated and still contains offline > >> CPUs and perf will try to open perf event on the offlined CPUs. > > > > The perf tool will try to only open online CPUs. Unfortunately the > > naming around this is confusing: > > > > - any - an event may follow a task and schedule on "any" CPU. We > > encode this with -1. > > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/lib/perf/include/perf/cpumap.h?h=perf-tools-next#n24 > > - online - the set of online CPU. > > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/lib/perf/include/perf/cpumap.h?h=perf-tools-next#n33 > > - all - I try to avoid this but it may still be in the code, "all" > > usually is another name for online. Hopefully when we use this name it > > is clearly defined: > > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/lib/perf/include/internal/evlist.h?h=perf-tools-next#n23 > > > >> Make "cpus" attribute only shows online CPUs and introduced a new > >> "supported_cpus" where users can get the range of the CPUs this > >> PMU supported monitoring. > > > > I don't think this should be necessary as by default the CPUs the perf > > tool will use will be the "online" CPUs: > > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/lib/perf/evlist.c?h=perf-tools-next#n40 > > > > Could you create a reproduction of the problem you are encountering? > > My expectation is for a core PMU to advertise the online and offline > > CPUs it is valid for, and for perf to intersect: > > https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/lib/perf/include/perf/cpumap.h?h=perf-tools-next#n44 > > those CPUs with the online CPUs so the perf_event_open doesn't fail. > > > > Thanks for the comments and detailed illustration! > > Actually it can be reproduced easily using the armv8_pmuv3's events. Tested on 6.10-rc1 with > perf version 6.10.rc1.g1613e604df0c: > # offline any CPU > [root@localhost tmp]# echo 0 > /sys//devices/system/cpu/cpu1/online > # try any event of armv8_pmuv3, with -a or without > [root@localhost tmp]# ./perf stat -e armv8_pmuv3_0/ll_cache/ -vvv > Control descriptor is not initialized > Opening: armv8_pmuv3_0/ll_cache/ > ------------------------------------------------------------ > perf_event_attr: > type 10 (armv8_pmuv3_0) > size 136 > config 0x32 (ll_cache) > sample_type IDENTIFIER > read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING > disabled 1 > inherit 1 > exclude_guest 1 > ------------------------------------------------------------ > sys_perf_event_open: pid -1 cpu 0 group_fd -1 flags 0x8 = 3 > Opening: armv8_pmuv3_0/ll_cache/ > ------------------------------------------------------------ > perf_event_attr: > type 10 (armv8_pmuv3_0) > size 136 > config 0x32 (ll_cache) > sample_type IDENTIFIER > read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING > disabled 1 > inherit 1 > exclude_guest 1 > ------------------------------------------------------------ > sys_perf_event_open: pid -1 cpu 1 group_fd -1 flags 0x8 > sys_perf_event_open failed, error -19 > Error: > The sys_perf_event_open() syscall returned with 19 (No such device) for event (armv8_pmuv3_0/ll_cache/). > /bin/dmesg | grep -i perf may provide additional information. > > As you can see, we're trying to open event on CPU 0 first (succeed) and then CPU 1 but > failed on CPU1. Actually we don't enter any branch which handle the evsel->cpus in > __perf_evlist__propagate_maps() so the evsel->cpus keeps as is which should be initialized > from the pmu->cpumask. You referenced to [1] but in this case perf_evsel->system_wide == false > as I checked. perf_evsel->system_wide will set to true in perf_evlist__go_system_wide() and it > maybe only set for dummy events. Please correct me if I misread here. Yes, this is confusing. IIRC evsel->system_wide is for tracking (dummy) events to collect side band events (like for Intel-PT) regardless of command line options (like -a or -C). Thanks, Namhyung > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/lib/perf/evlist.c?h=perf-tools-next#n40 > > Thanks. >