From: Andrew Murray <andrew.murray@arm.com>
To: Christoffer Dall <christoffer.dall@arm.com>,
Marc Zyngier <marc.zyngier@arm.com>
Cc: kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com
Subject: [PATCH 1/4] KVM: arm/arm64: extract duplicated code to own function
Date: Tue, 22 Jan 2019 10:49:54 +0000 [thread overview]
Message-ID: <1548154197-5470-2-git-send-email-andrew.murray@arm.com> (raw)
In-Reply-To: <1548154197-5470-1-git-send-email-andrew.murray@arm.com>
Let's reduce code duplication by extracting common code to its own
function.
Signed-off-by: Andrew Murray <andrew.murray@arm.com>
---
virt/kvm/arm/pmu.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
index 1c5b76c..531d27f 100644
--- a/virt/kvm/arm/pmu.c
+++ b/virt/kvm/arm/pmu.c
@@ -65,6 +65,19 @@ void kvm_pmu_set_counter_value(struct kvm_vcpu *vcpu, u64 select_idx, u64 val)
}
/**
+ * kvm_pmu_release_perf_event - remove the perf event
+ * @pmc: The PMU counter pointer
+ */
+static void kvm_pmu_release_perf_event(struct kvm_pmc *pmc)
+{
+ if (pmc->perf_event) {
+ perf_event_disable(pmc->perf_event);
+ perf_event_release_kernel(pmc->perf_event);
+ pmc->perf_event = NULL;
+ }
+}
+
+/**
* kvm_pmu_stop_counter - stop PMU counter
* @pmc: The PMU counter pointer
*
@@ -79,9 +92,7 @@ static void kvm_pmu_stop_counter(struct kvm_vcpu *vcpu, struct kvm_pmc *pmc)
reg = (pmc->idx == ARMV8_PMU_CYCLE_IDX)
? PMCCNTR_EL0 : PMEVCNTR0_EL0 + pmc->idx;
__vcpu_sys_reg(vcpu, reg) = counter;
- perf_event_disable(pmc->perf_event);
- perf_event_release_kernel(pmc->perf_event);
- pmc->perf_event = NULL;
+ kvm_pmu_release_perf_event(pmc);
}
}
@@ -114,12 +125,7 @@ void kvm_pmu_vcpu_destroy(struct kvm_vcpu *vcpu)
for (i = 0; i < ARMV8_PMU_MAX_COUNTERS; i++) {
struct kvm_pmc *pmc = &pmu->pmc[i];
-
- if (pmc->perf_event) {
- perf_event_disable(pmc->perf_event);
- perf_event_release_kernel(pmc->perf_event);
- pmc->perf_event = NULL;
- }
+ kvm_pmu_release_perf_event(pmc);
}
}
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-01-22 10:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-22 10:49 [PATCH 0/4] KVM: arm/arm64: add support for chained counters Andrew Murray
2019-01-22 10:49 ` Andrew Murray [this message]
2019-01-22 14:20 ` [PATCH 1/4] KVM: arm/arm64: extract duplicated code to own function Suzuki K Poulose
2019-01-22 10:49 ` [PATCH 2/4] KVM: arm/arm64: re-create event when setting counter value Andrew Murray
2019-01-22 12:12 ` Julien Thierry
2019-01-22 12:42 ` Andrew Murray
2019-01-22 14:18 ` Suzuki K Poulose
2019-01-28 11:47 ` Andrew Murray
2019-01-29 10:56 ` Suzuki K Poulose
2019-01-22 10:49 ` [PATCH 3/4] KVM: arm/arm64: lazily create perf events on enable Andrew Murray
2019-01-22 13:41 ` Julien Thierry
2019-01-28 17:02 ` Andrew Murray
2019-01-22 22:12 ` Suzuki K Poulose
2019-01-28 14:28 ` Andrew Murray
2019-01-29 11:11 ` Suzuki K Poulose
2019-01-22 10:49 ` [PATCH 4/4] KVM: arm/arm64: support chained PMU counters Andrew Murray
2019-01-22 14:59 ` Julien Thierry
2019-01-28 17:13 ` Andrew Murray
2019-01-29 9:07 ` Julien Thierry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1548154197-5470-2-git-send-email-andrew.murray@arm.com \
--to=andrew.murray@arm.com \
--cc=christoffer.dall@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=marc.zyngier@arm.com \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).