From patchwork Sat Dec 10 20:47:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 87586 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp950544qgi; Sat, 10 Dec 2016 12:49:28 -0800 (PST) X-Received: by 10.84.128.195 with SMTP id a61mr170545765pla.55.1481402968107; Sat, 10 Dec 2016 12:49:28 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id 73si38557362pfw.55.2016.12.10.12.49.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 10 Dec 2016 12:49:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cFoYb-00024B-Nr; Sat, 10 Dec 2016 20:47:45 +0000 Received: from mail-lf0-x231.google.com ([2a00:1450:4010:c07::231]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cFoYK-0001tX-Rx for linux-arm-kernel@lists.infradead.org; Sat, 10 Dec 2016 20:47:30 +0000 Received: by mail-lf0-x231.google.com with SMTP id y21so21796810lfa.1 for ; Sat, 10 Dec 2016 12:47:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5OqKqg2r3AZdjr3oadZIEnKl9hUkNcmyyEs5WnO21Q0=; b=cGGIl3X0m4tZBeMHaChYWnrBv8T7GJWAEmbX2Le0T7r4ThRCXnZ0PHcTB4KmK1zRcu lqjyz1ZwSVJdgy/m/cBrUilpUCdbaeLNbiCuvAkfYiCHlPJALOF8nPk0JxuokYsAX3E1 2qMa2kBnhysZuQsO2NbFkmbfw5XW03/ryEaTI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5OqKqg2r3AZdjr3oadZIEnKl9hUkNcmyyEs5WnO21Q0=; b=Cy9PtW5d28WYN5PrqziOVKqhNpJJp93Tb0eTYbWWdYTx1izwS+XNWjZqCMoAj/IT2Y w2Oy582t1Ha+rXqONO5jvCRRT/1eVV7lp68E3nO/qg6xm0FYGkuWzLK4WzkNEi4aOWKZ t1YGo4+mnPCZH5cn31nzpf4JofcieW4O2WvXmo/XM2AUV4AZzZ6qHOnlvpOxUlVszZUf sBgL3lbSRtJ04buYRV3n4tl7ESzHIj5N+fH2TyjSBeLap8dHqbLDOeglUhMbux3gpTmt RvQ18roslzywGasDQFScp4tQEe7eSOjp/L+CXi06KRvGFQU4Nuv04QK+IB3VrNfqgdZH 05Lg== X-Gm-Message-State: AKaTC00Dfx1uFP33ZV843TrD2mQlW6y42s9GVoAfQyMktHFaKqur8HwwZSTqGMvbDW7j6n7X X-Received: by 10.46.78.26 with SMTP id c26mr37613518ljb.46.1481402826623; Sat, 10 Dec 2016 12:47:06 -0800 (PST) Received: from localhost.localdomain (x1-6-50-6a-03-de-ec-c2.cpe.webspeed.dk. [2.108.209.202]) by smtp.gmail.com with ESMTPSA id 29sm7578325lft.43.2016.12.10.12.47.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Dec 2016 12:47:06 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Subject: [RFC PATCH 1/7] arm64: Use physical counter for in-kernel reads Date: Sat, 10 Dec 2016 21:47:06 +0100 Message-Id: <20161210204712.21830-2-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161210204712.21830-1-christoffer.dall@linaro.org> References: <20161210204712.21830-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161210_124729_133976_17F65C2E X-CRM114-Status: GOOD ( 12.69 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:4010:c07:0:0:0:231 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Using the physical counter allows KVM to retain the offset between the virtual and physical counter as long as it is actively running a VCPU. As soon as a VCPU is released, another thread is scheduled or we start running userspace applications, we reset the offset to 0, so that VDSO operations can still read the virtual counter and get the same view of time as the kernel. This opens up potential improvements for KVM performance. VHE kernels or kernels using the virtual timer are unaffected by this. Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/arch_timer.h | 6 ++++-- drivers/clocksource/arm_arch_timer.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) -- 2.9.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index eaa5bbe..cec2549 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h @@ -139,11 +139,13 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl) static inline u64 arch_counter_get_cntpct(void) { + u64 cval; /* * AArch64 kernel and user space mandate the use of CNTVCT. */ - BUG(); - return 0; + isb(); + asm volatile("mrs %0, cntpct_el0" : "=r" (cval)); + return cval; } static inline u64 arch_counter_get_cntvct(void) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 73c487d..a5b0789 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -597,7 +597,7 @@ static void __init arch_counter_register(unsigned type) /* Register the CP15 based counter if we have one */ if (type & ARCH_CP15_TIMER) { - if (IS_ENABLED(CONFIG_ARM64) || arch_timer_uses_ppi == VIRT_PPI) + if (arch_timer_uses_ppi == VIRT_PPI || is_kernel_in_hyp_mode()) arch_timer_read_counter = arch_counter_get_cntvct; else arch_timer_read_counter = arch_counter_get_cntpct;