From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f73.google.com (mail-oa1-f73.google.com [209.85.160.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA56A1A01B0 for ; Mon, 27 Jan 2025 22:20:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738016453; cv=none; b=FklLmhHW14fwssnBKCEpCpfB+yw4Gym7WO/PtD+p59c3RdC3RZk0JRs6W93SIkPNSx6K2lpNtCGUFmCJro9o3HFYR0wrjRrI4wK8rW0vjRu5F20vdnxfTQmR7YLJlevfJBJ+83ICyMXz6xVZj63Nnmf7Gn/tNuQE0tMV73yCJ44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738016453; c=relaxed/simple; bh=YR+PMK0VyLwKWhT0xbtwEKZ7//CuT8dMl7x5cZfrnYo=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=miWonoiSpYGZ/Vikn4gEqcFUrCz/YlwhLt/8jJYkwPRBYHd+SyIKEe4ckRNe8/wq/Ie0QZMSI5/O8LY3+8BfprJir5Edv5ohMkX6xB3qxjQxk0OAJsAIGUsZV0ZOIbOEaNF78nM/kPn3FRj4BqYip3EIL0l2NKH4xBOIlVtLQGg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=kOLmEr/I; arc=none smtp.client-ip=209.85.160.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--coltonlewis.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kOLmEr/I" Received: by mail-oa1-f73.google.com with SMTP id 586e51a60fabf-2a7d6283167so1565703fac.0 for ; Mon, 27 Jan 2025 14:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738016451; x=1738621251; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=VGVx2inDcPb4kyuc5g9Cp41GlSlePFgSKTBuQPtRjD4=; b=kOLmEr/I2Z7b+qq6+hyriOttQstMPZOWEPNMk6gAp59FyaoEAo9IauQisSA+g6Gqxk 8G6tzvxDoHGr1HeY4O/0Ee5eE0wdbzeH6o9kxbgPwXyBmar4jcfbx89IbWVLWpZNMRlo Qdusesw7ECaWP3asFScycj9kC/uS8AKKLfMTlinPl+td8/BGK4qx6rWPvv0SzTazxPIN IvnaBJ/GLJWgv0ea2lelHayDGdOQ+fSDeqGzIBHizdqSNjzsVr5yjvbVEtp6PKufwQW3 fTgOcmlIC4hMndIE2f4hQOuDgJ3DnEwU7it3COVo489dcwCCPwQDb3jdMjYtrQLvNlDa aoxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738016451; x=1738621251; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=VGVx2inDcPb4kyuc5g9Cp41GlSlePFgSKTBuQPtRjD4=; b=JLaPEc9C5uiW4AvnlCbwJPH+S+kOBmoiBYU4oytflgbUQ5LJDokpCvTn/vXad0cqxJ s+vlZoB2cKaTgeRvNgHQMutETbh67idc6WZ7rzb5nKUWQWRrfGG6XcJhv8unBtmXrYDa orrcaCC10/K5fKVsIQ7+dD4yTTMSFUeCzg1Bi31p5OJvldWawgLtZ+pifyvGGxoF28jx bClUTtEnCclj3IKV1tzrXsnJ6mRQeBmqAm8I5ed3UMCwWFhi36AwXhaeFrv7pFFDBFS7 2hSZdXerJ/B5VthBYyt3XusuTpGSqechI0tCfUPLkD+3KHkaaaYDP3wLlZV0UTcv7F6H 5Jyw== X-Forwarded-Encrypted: i=1; AJvYcCUAZCb1Pm9jJiS5eOuRnSIpKtA1QV4OraneCoWN1Nt5eBUyLvCLjhsoNsYDcm0+l0LiXwvP8lldYszN3ZE=@vger.kernel.org X-Gm-Message-State: AOJu0YwHRdvShtYxmNEdxdyO1rQJ9lc+S4GTGtLdUrULrnr7Mcs1USZC GZw7Suu828NnWVaRzwu6Gh6wCogznVBJ7XLLfZ3TRbmxetXCtCL5CQliTW2pPd4nxwVJwFw5sOm my396feDSFJty94CR5ywNDw== X-Google-Smtp-Source: AGHT+IEyp+zn4K8xvMBme9w+olqOdC2WoYBUbvWUqnKRlZMr1gAx+eFOYXOnePYqDL8MpO28ip3SYaynWBZeMCj6Qg== X-Received: from oabnw13.prod.google.com ([2002:a05:6870:bb0d:b0:2b2:2b44:5abb]) (user=coltonlewis job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6871:3a88:b0:29e:2422:49f9 with SMTP id 586e51a60fabf-2b1c0aee5efmr22900341fac.25.1738016450898; Mon, 27 Jan 2025 14:20:50 -0800 (PST) Date: Mon, 27 Jan 2025 22:20:26 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog Message-ID: <20250127222031.3078945-1-coltonlewis@google.com> Subject: [RFC PATCH 0/4] PMU partitioning driver support From: Colton Lewis To: kvm@vger.kernel.org Cc: Russell King , Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Mark Rutland , Paolo Bonzini , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org, Colton Lewis Content-Type: text/plain; charset="UTF-8" This series introduces support in the ARM PMUv3 driver for partitioning PMU counters into two separate ranges by taking advantage of the MDCR_EL2.HPMN register field. The advantage of a partitioned PMU would be to allow KVM guests direct access to a subset of PMU functionality, greatly reducing the overhead of performance monitoring in guests. While this series could be accepted on its own merits, practically there is a lot more to be done before it will be fully useful, so I'm sending as an RFC for now. This patch is based on v6.13-rc7. It needs a small additional change after Oliver's Debug cleanups series going into 6.14, specifically this patch [1], because it changes kvm_arm_setup_mdcr_el2() to initialize HPMN from a cached value read early in the boot process instead of reading from the register. The only sensible way I can see to deal with this is returning to reading the register. [1] https://lore.kernel.org/kvmarm/20241219224116.3941496-3-oliver.upton@linux.dev/ Colton Lewis (4): perf: arm_pmuv3: Introduce module param to partition the PMU KVM: arm64: Make guests see only counters they can access perf: arm_pmuv3: Generalize counter bitmasks perf: arm_pmuv3: Keep out of guest counter partition arch/arm/include/asm/arm_pmuv3.h | 10 ++ arch/arm64/include/asm/arm_pmuv3.h | 10 ++ arch/arm64/kvm/pmu-emul.c | 8 +- drivers/perf/arm_pmuv3.c | 113 ++++++++++++++++-- include/linux/perf/arm_pmu.h | 2 + include/linux/perf/arm_pmuv3.h | 34 +++++- .../kvm/aarch64/vpmu_counter_access.c | 2 +- 7 files changed, 160 insertions(+), 19 deletions(-) base-commit: 5bc55a333a2f7316b58edc7573e8e893f7acb532 -- 2.48.1.262.g85cc9f2d1e-goog