From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) (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 E2D6727979A for ; Mon, 14 Jul 2025 22:59:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752533974; cv=none; b=qrdav6QrYdmbRJquBM1qzHqidf+76A25mHie9JH+aTScIuZu/4JF9cZlCWaFeVb0H/bueufYRnHkR052l/266jU/JOHuMD2jLmrE14Pja64L66t+6SIuLfh6PGrXcZ0nHSJtuxymlcs78OeRJETIWq0odmpwIyzw+8DYJ3WnLSU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752533974; c=relaxed/simple; bh=hOTRa511jzbS7yKwTFBz9jTYvhLCpapYcm6zER8h/+U=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KlaL8V1O8TY4nLNR1v41N4P5B16gk85+Qg+9/VqWovlKEIXaX4AVasCCL5fyw7j4QAQpNo6R7bFnWI9WzhxUj+9wvT4LLXuxheWef31y/0QitnY0fQZtmuM5kujo97vMaw61bWO+FAVQiafbjmFfgjQdwtPzGjOa5CRJfGe+31k= 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=iHZl26jY; arc=none smtp.client-ip=209.85.166.74 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="iHZl26jY" Received: by mail-io1-f74.google.com with SMTP id ca18e2360f4ac-86f4f032308so872346539f.1 for ; Mon, 14 Jul 2025 15:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1752533972; x=1753138772; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RsXzykyZ0LoYkkSjRYm7JEpztKOUc4MUEbwC3RjOmME=; b=iHZl26jYMNhO2gsfpOKJW/n1WdIU0e0wQSgoNQ2mhUnVi0vPcyEai6owZwg625mh4v U66uFXAtNNryyU7Skkd5qHigus6CUM68LkVil9+RMLs8OZqDIUrjXgvd+8HLEngv42X4 zFqG9ZPxsEqp/h0hOVKvfYN2J+bGIf4U6pAayGg7FMHsAjxG7nL/ExlZBaJbaCCPLPLB 97d3+/wH4hlBzp71WoXjzI8zUkHf+5ZKzDqtcCRQAshdc0wNckwj+MOtPtHfhMkbinjJ 7MgJQDHTVUExPLD7BofT2e1a/zM5GKDxudRPrB3JfyD9mpN8JwlMEFGzgRU+n2E4s1ts I47g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752533972; x=1753138772; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RsXzykyZ0LoYkkSjRYm7JEpztKOUc4MUEbwC3RjOmME=; b=GZdzTmQvp7PomZIKNCqjvr0NzdT2+CY40Im46EgY0Xphbp9Pj9eHG06bTmCd0/aEIj y4GC/K3Fu3/6Ds0FXzjnxxQhJCGuSzpJozgN1rt8BF/rJjhjIu3h2FYMh0cR+f3KVmKU JjsMZ7L0CJkL54vehz7cSFwbd9dZpCG6yYSJFZIdSIFhKyeYc6xws153bPfv2CmnGh2h FDjXnUKEfIyN0HqMvf1pE9iKuVw1qqenN03L3SNOFdIcoiEKoK/6E+irGelvQuvvxyg8 EIWd+7sl/L7ebD30sNUjH9qAVOZiDmoETO0Twe/WyF5GLKfflMGleI1tyTXUpYigyYHt oqvQ== X-Forwarded-Encrypted: i=1; AJvYcCUvktyV8/wOEs+eE+/Yb+9i+owSGba4LnjYrvm3cS3Z2yudopBix2MwR/8JYfOu0o0uwGZGfnQkJ0Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzCIa1FmTCeMM3wjgiOkAisM/axjyNeo6BMQafdigaeWwI0yTJL 4fY7Tmul8ITCesfKQastgYf56SFI/685u+o91OEDQSex3aBuHqrr38gE4M6l+QJWHbQ19QYBgCr hny3QuqeXsl4FMgf+iVdSOIS41w== X-Google-Smtp-Source: AGHT+IEpddQm39eOue1RsOnjPQc1DAuSYoVtcPcyMtHmEBXoJpp94iomugG2xoJBhD4Zximcypfn3q/M/U33LBaYPw== X-Received: from iosu5.prod.google.com ([2002:a05:6602:29a5:b0:86c:f382:ca9f]) (user=coltonlewis job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6602:6c0e:b0:876:8790:6ac8 with SMTP id ca18e2360f4ac-879b0a8db9emr69267639f.1.1752533972180; Mon, 14 Jul 2025 15:59:32 -0700 (PDT) Date: Mon, 14 Jul 2025 22:58:56 +0000 In-Reply-To: <20250714225917.1396543-1-coltonlewis@google.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250714225917.1396543-1-coltonlewis@google.com> X-Mailer: git-send-email 2.50.0.727.gbf7dc18ff4-goog Message-ID: <20250714225917.1396543-3-coltonlewis@google.com> Subject: [PATCH v4 02/23] KVM: arm64: Reorganize PMU includes From: Colton Lewis To: kvm@vger.kernel.org Cc: Paolo Bonzini , Jonathan Corbet , Russell King , Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Mingwei Zhang , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Mark Rutland , Shuah Khan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-perf-users@vger.kernel.org, linux-kselftest@vger.kernel.org, Colton Lewis Content-Type: text/plain; charset="UTF-8" From: Marc Zyngier Including *all* of asm/kvm_host.h in asm/arm_pmuv3.h is a bad idea because that is much more than arm_pmuv3.h logically needs and creates a circular dependency that makes it easy to introduce compiler errors when editing this code. asm/kvm_host.h includes asm/kvm_pmu.h includes perf/arm_pmuv3.h includes asm/arm_pmuv3.h includes asm/kvm_host.h Reorganize the PMU includes to be more sane. In particular: * Remove the circular dependency by removing the kvm_host.h include since it isn't needed in that header. * Conditionally on ARM64, include the more targeted kvm_pmu.h directly in the arm_pmuv3.c driver, where some functions defining the KVM/PMU interface are needed. * Move the last bit of KVM/PMU interface from kvm_host.h into kvm_pmu.h Signed-off-by: Marc Zyngier Signed-off-by: Colton Lewis --- arch/arm64/include/asm/arm_pmuv3.h | 2 -- arch/arm64/include/asm/kvm_host.h | 14 -------------- arch/arm64/include/asm/kvm_pmu.h | 15 +++++++++++++++ drivers/perf/arm_pmuv3.c | 5 +++++ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/arch/arm64/include/asm/arm_pmuv3.h b/arch/arm64/include/asm/arm_pmuv3.h index 8a777dec8d88..cf2b2212e00a 100644 --- a/arch/arm64/include/asm/arm_pmuv3.h +++ b/arch/arm64/include/asm/arm_pmuv3.h @@ -6,8 +6,6 @@ #ifndef __ASM_PMUV3_H #define __ASM_PMUV3_H -#include - #include #include diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 27ed26bd4381..92d672429233 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -1487,25 +1487,11 @@ void kvm_arch_vcpu_ctxflush_fp(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu); void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu); -static inline bool kvm_pmu_counter_deferred(struct perf_event_attr *attr) -{ - return (!has_vhe() && attr->exclude_host); -} - #ifdef CONFIG_KVM -void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr); -void kvm_clr_pmu_events(u64 clr); -bool kvm_set_pmuserenr(u64 val); void kvm_enable_trbe(void); void kvm_disable_trbe(void); void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest); #else -static inline void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr) {} -static inline void kvm_clr_pmu_events(u64 clr) {} -static inline bool kvm_set_pmuserenr(u64 val) -{ - return false; -} static inline void kvm_enable_trbe(void) {} static inline void kvm_disable_trbe(void) {} static inline void kvm_tracing_set_el1_configuration(u64 trfcr_while_in_guest) {} diff --git a/arch/arm64/include/asm/kvm_pmu.h b/arch/arm64/include/asm/kvm_pmu.h index baf028d19dfc..ad3247b46838 100644 --- a/arch/arm64/include/asm/kvm_pmu.h +++ b/arch/arm64/include/asm/kvm_pmu.h @@ -11,9 +11,15 @@ #include #include #include +#include #define KVM_ARMV8_PMU_MAX_COUNTERS 32 +#define kvm_pmu_counter_deferred(attr) \ + ({ \ + !has_vhe() && (attr)->exclude_host; \ + }) + #if IS_ENABLED(CONFIG_HW_PERF_EVENTS) && IS_ENABLED(CONFIG_KVM) struct kvm_pmc { u8 idx; /* index into the pmu->pmc array */ @@ -68,6 +74,9 @@ int kvm_arm_pmu_v3_has_attr(struct kvm_vcpu *vcpu, int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu); struct kvm_pmu_events *kvm_get_pmu_events(void); +void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr); +void kvm_clr_pmu_events(u64 clr); +bool kvm_set_pmuserenr(u64 val); void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu); void kvm_vcpu_pmu_restore_host(struct kvm_vcpu *vcpu); void kvm_vcpu_pmu_resync_el0(void); @@ -161,6 +170,12 @@ static inline u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1) #define kvm_vcpu_has_pmu(vcpu) ({ false; }) static inline void kvm_pmu_update_vcpu_events(struct kvm_vcpu *vcpu) {} +static inline void kvm_set_pmu_events(u64 set, struct perf_event_attr *attr) {} +static inline void kvm_clr_pmu_events(u64 clr) {} +static inline bool kvm_set_pmuserenr(u64 val) +{ + return false; +} static inline void kvm_vcpu_pmu_restore_guest(struct kvm_vcpu *vcpu) {} static inline void kvm_vcpu_pmu_restore_host(struct kvm_vcpu *vcpu) {} static inline void kvm_vcpu_reload_pmu(struct kvm_vcpu *vcpu) {} diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c index 3db9f4ed17e8..c2e3672e1228 100644 --- a/drivers/perf/arm_pmuv3.c +++ b/drivers/perf/arm_pmuv3.c @@ -9,6 +9,11 @@ */ #include + +#if defined(CONFIG_ARM64) +#include +#endif + #include #include -- 2.50.0.727.gbf7dc18ff4-goog