From patchwork Thu Jan 18 16:55:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 13523040 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 994C7C47DAF for ; Thu, 18 Jan 2024 16:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=x7kJNlCFG0SGgRX3qqi1afxTY6BDGjK5/fk2dUXMrjE=; b=qMRkcpMPQDtJIH iqpTyb6XbBTJiL0I8/5feWUpdp6DR71G3KjU/3xURa4/I6gpR5mqx6S+3fNtFsrabAEKMtcbPCmQb Vz3WizVB4IfYow8PBqU+Vxak+l3z1OC6aGp/ksfRi9WwD6Y/EOYersQaIwEw5Oe6JaVmZsiKtdD/2 zTIlsBl5sryXgwV1hiTefrLoNWfitELZh8irGH0imn/ocy/jL7Z1UBnyKVZv+LR8nI2rPmyX/8Cjd 3mlgsJ09BvawOYZUH4fHc8HxBAl9bsjmTmUnepiOITLG74eFCrF3vI4dFKs/o/X6dEmz7pWIhXpUg wdBFGDQXncMJv1gG+WTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQVgR-003K4N-1U; Thu, 18 Jan 2024 16:56:03 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQVgN-003K3X-2i for linux-arm-kernel@lists.infradead.org; Thu, 18 Jan 2024 16:56:01 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rQVgE-0004xK-0X; Thu, 18 Jan 2024 17:55:50 +0100 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1rQVgD-000jWU-Cr; Thu, 18 Jan 2024 17:55:49 +0100 From: Lucas Stach To: Russell King Cc: Ard Biesheuvel , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, patchwork-lst@pengutronix.de Subject: [PATCH RFC] ARM: VDSO: don't drop clock_gettime when architected timer isn't available Date: Thu, 18 Jan 2024 17:55:49 +0100 Message-Id: <20240118165549.1935000-1-l.stach@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240118_085559_916865_829DFCCA X-CRM114-Status: GOOD ( 16.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Dropping the clock_gettime entry points when the architected timer is not available is done to gain some efficiency, as it allows libc to fall back to the syscall without dispatching through the vDSO. The difference on a i.MX6 system using the vdso test utility [1] looks like this: $ vdsotest clock-gettime-monotonic bench -d 10 w/o vDSO entrypoint with vDSO entrypoint syscall: 987 nsec/call 974 nsec/call libc: 1095 nsec/call 1148 nsec/call vdso: not available not available Going through libc adds a ~100ns penalty compared to calling the syscall directly. Dispatching through the vDSO adds another ~50ns, which isn't negligible, but also not huge. The downside of dropping the entry points is that now also the COARSE versions of the clocks have to go through the syscall, while they can be accelerated through the vDSO even without the architected timer when the entry points are kept. $ vdsotest clock-gettime-monotonic-coarse bench -d 10 w/o vDSO entrypoint with vDSO entrypoint syscall: 659 nsec/call 662 nsec/call libc: 772 nsec/call 137 nsec/call vdso: not available 63 nsec/call This is quite a nice speedup, but arguably coarse clocks are also not as widely used as the high-res versions. Still, this patch proposes to to take the hit on his-res clocks by dispatching through the vDSO to gain the ability to accelerate coarse clocks. [1] https://github.com/nlynch-mentor/vdsotest Signed-off-by: Lucas Stach --- arch/arm/kernel/vdso.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c index f297d66a8a76..947f3d8144fc 100644 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -172,11 +172,8 @@ static void __init patch_vdso(void *ehdr) * want programs to incur the slight additional overhead of * dispatching through the VDSO only to fall back to syscalls. */ - if (!cntvct_ok) { + if (!cntvct_ok) vdso_nullpatch_one(&einfo, "__vdso_gettimeofday"); - vdso_nullpatch_one(&einfo, "__vdso_clock_gettime"); - vdso_nullpatch_one(&einfo, "__vdso_clock_gettime64"); - } } static int __init vdso_init(void)