Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp799642rwd; Sat, 27 May 2023 06:42:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nKyJSDwz381aBZOLrHKPqOkSCaBblzUF/Gel+FB/kKfZsm821PnIlmV744h1wjMEI5MLt X-Received: by 2002:a05:6a20:1610:b0:10e:6af7:3cda with SMTP id l16-20020a056a20161000b0010e6af73cdamr2937890pzj.11.1685194930630; Sat, 27 May 2023 06:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685194930; cv=none; d=google.com; s=arc-20160816; b=TM3JPbUW8W3Cm9WrcX9qUvGpwcZ5pMZ3aJzXAKUXE5xNZXHlEuWqcxokpOHJ9/DmHA 0KM0zyJWWuuXHcNrkGccGCMU+x0lQjQgc7VAuT/DeJSp3KJKsiBkr7Hsc+fhLcxl9Qki rijGWgmGKObiyDimQqRC0ls1+h3wRlRZINeZnCZruuSRZH2QL673ZcyoTjFdf4ZdVB07 rwtxEN9gdf6ge5LFJIe4hE+NOAq3kU3nzQMGNaL0g39CeHb+t0MDfzfCK6LofkVktFGM jlXeEkXFeqtuLBxqT5GV38VuwGsn2MNzGnYGZwJWQe9S08apu6tTIv6g/WzXnoLmziE1 Zt8A== 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 :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=edHpUEnHQQLfQ9JyXulhKTUOJpcS3Wd189yVheSf4t8=; b=xvuvOHzAMoVt1x6IxnZZNoEEyLw+/mRIBGM+ypkWyAoMqceYd2JBfHtQIh1rA/5C5s 1uKNRd7jSYHr6f/sPI3J92fLyRwY0flqoKHrn59lQsq6B03HRouhVyvDvuBJqHwqTT4S f80XJvy5SHzaPgh2+BUVUhLxFIVHuoTH7RFT+ATdeZRVEi6pZZKMIUNaRV140svRFA4w 5tLIXclta6wUIA80d59Raal0prWVAveQ7+ey4EL9kI+rI33GoSyaUaxAVOUqpQcaaILk WGIK2MHGcRB+BKPIyZpAIOwFOnIn3xpllECZSfCXRgquH0b4FvQQkg5GPoUVJdfpi0hD 85wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qbzt+Nhs; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q62-20020a632a41000000b0050bcb8e3a8csi5978538pgq.828.2023.05.27.06.41.58; Sat, 27 May 2023 06:42:10 -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=@kernel.org header.s=k20201202 header.b=qbzt+Nhs; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232239AbjE0Nc6 (ORCPT + 99 others); Sat, 27 May 2023 09:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231186AbjE0Nc5 (ORCPT ); Sat, 27 May 2023 09:32:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5A20C3; Sat, 27 May 2023 06:32:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 50F7861472; Sat, 27 May 2023 13:32:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7AD8C4339C; Sat, 27 May 2023 13:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685194374; bh=2TNQEbJxCXNtnSuWUh8ETIiBTaEmLYOWvno0ZcYi0QU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qbzt+NhsrBrEBI2Er2jDNqD8FG0knKYp6WP7OFfJ1+iITD54Vvz7g6MNG4/4Ig5fl qE3X+pVnzPgsBctUKz2quZ3pOoGr+qrS5R3EFZ5jydxqB2g3ES/hfmoJbeM2eYbzWr fmipr3mjLbjWr0J3nB/yBeohPM+35YWkrN0zNo0y3znFpRsH1nDBTzzEsPwnKN2rvR PuarY+iX1O6y+VzZDm6YrS+dIOFCj72wwmp6o+MX2JTgzIiXFgj5Y5FFBnP9+LmnTE ZcujOrKgsDZC22UM6Awr0g5rAgBzoFeDsC8eCl/TpZRjkZPLDoFzEfAqN7QjbfV2w1 tqKh/el+41XQA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q2u2O-000l67-1p; Sat, 27 May 2023 14:32:52 +0100 Date: Sat, 27 May 2023 14:32:51 +0100 Message-ID: <86jzwtdhmk.wl-maz@kernel.org> From: Marc Zyngier To: Ian Rogers Cc: Oliver Upton , Peter Zijlstra , Ravi Bangoria , Nathan Chancellor , namhyung@kernel.org, eranian@google.com, acme@kernel.org, mark.rutland@arm.com, jolsa@kernel.org, bp@alien8.de, kan.liang@linux.intel.com, adrian.hunter@intel.com, maddy@linux.ibm.com, x86@kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, sandipan.das@amd.com, ananth.narayan@amd.com, santosh.shukla@amd.com, kvmarm@lists.linux.dev Subject: Re: [PATCH v4 3/4] perf/core: Remove pmu linear searching code In-Reply-To: References: <20230504110003.2548-1-ravi.bangoria@amd.com> <20230504110003.2548-4-ravi.bangoria@amd.com> <20230524214133.GA2359762@dev-arch.thelio-3990X> <20230525142031.GU83892@hirez.programming.kicks-ass.net> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: irogers@google.com, oliver.upton@linux.dev, peterz@infradead.org, ravi.bangoria@amd.com, nathan@kernel.org, namhyung@kernel.org, eranian@google.com, acme@kernel.org, mark.rutland@arm.com, jolsa@kernel.org, bp@alien8.de, kan.liang@linux.intel.com, adrian.hunter@intel.com, maddy@linux.ibm.com, x86@kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, sandipan.das@amd.com, ananth.narayan@amd.com, santosh.shukla@amd.com, kvmarm@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 On Sat, 27 May 2023 00:00:47 +0100, Ian Rogers wrote: >=20 > On Thu, May 25, 2023 at 8:56=E2=80=AFAM Oliver Upton wrote: > > > > On Thu, May 25, 2023 at 04:20:31PM +0200, Peter Zijlstra wrote: > > > On Thu, May 25, 2023 at 07:11:41AM +0000, Oliver Upton wrote: > > > > > > > The PMUv3 driver does pass a name, but it relies on getting back an > > > > allocated pmu id as @type is -1 in the call to perf_pmu_register(). > > > > > > > > What actually broke is how KVM probes for a default core PMU to use= for > > > > a guest. kvm_pmu_probe_armpmu() creates a counter w/ PERF_TYPE_RAW = and > > > > reads the pmu from the returned perf_event. The linear search had t= he > > > > effect of eventually stumbling on the correct core PMU and succeedi= ng. > > > > > > > > Perf folks: is this WAI for heterogenous systems? > > > > > > TBH, I'm not sure. hetero and virt don't mix very well AFAIK and I'm = not > > > sure what ARM64 does here. > > > > > > IIRC the only way is to hard affine things; that is, force vCPU of > > > 'type' to the pCPU mask of 'type' CPUs. > > > > We provide absolutely no illusion of consistency across implementations. > > Userspace can select the PMU type, and then it is a userspace problem > > affining vCPUs to the right pCPUs. > > > > And if they get that wrong, we just bail and refuse to run the vCPU. > > > > > If you don't do that; or let userspace 'override' that, things go > > > sideways *real* fast. > > > > Oh yeah, and I wish PMUs were the only problem with these hetero > > systems... >=20 > Just to add some context from what I understand. There are inbuilt > type numbers for PMUs: > https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/tree/inclu= de/uapi/linux/perf_event.h?h=3Dperf-tools-next#n34 > so the PMU generally called /sys/devices/cpu should have type 4 (ARM > give it another name). For heterogeneous ARM there is a single PMU and > the same events are programmed regardless of whether it is a big or a > little core - the cpumask lists all CPUs. I think you misunderstood the way heterogeneous arm64 systems are described . Each CPU type gets its own PMU type, and its own event list. Case in point: $ grep . /sys/devices/*pmu/{type,cpus} /sys/devices/apple_avalanche_pmu/type:9 /sys/devices/apple_blizzard_pmu/type:8 /sys/devices/apple_avalanche_pmu/cpus:4-9 /sys/devices/apple_blizzard_pmu/cpus:0-3 Type 4 (aka PERF_EVENT_RAW) is AFAICT just a way to encode the raw event number, nothing else. Thanks, M. --=20 Without deviation from the norm, progress is not possible.