From patchwork Sun Feb 24 09:36:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Xuerui X-Patchwork-Id: 10827813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 128EA1399 for ; Sun, 24 Feb 2019 10:05:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00C7B2B6DC for ; Sun, 24 Feb 2019 10:05:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8F702B824; Sun, 24 Feb 2019 10:05:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72B352B6DC for ; Sun, 24 Feb 2019 10:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728096AbfBXKFl (ORCPT ); Sun, 24 Feb 2019 05:05:41 -0500 Received: from [115.28.160.31] ([115.28.160.31]:45318 "EHLO mailbox.box.xen0n.name" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1728120AbfBXKFl (ORCPT ); Sun, 24 Feb 2019 05:05:41 -0500 Received: from localhost.localdomain (unknown [116.236.177.50]) by mailbox.box.xen0n.name (Postfix) with ESMTPA id D86C3601C8; Sun, 24 Feb 2019 17:37:02 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=xen0n.name; s=mail; t=1551001023; bh=J7iATcxVrVbgSMYpAyIOEoUkNVWUfAtyvY/ElhHuLgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ayJKR4g+kWUtCj+zA5zNLBk29oROmIXYvg05Kh+uUuMcQglnmaikmc8O9dvYPtKTw v17V5byanql0CtU/FH2UejIxM776Eb01hQMJ+tY4XAiNU3UFR0NJY/D9bQA0W8/QnT J+nV1UGj8V/KrEiUeUZhM7Db6tAQ02T/53NPV5Q4= From: kernel@xen0n.name To: linux-mips@vger.kernel.org Cc: Wang Xuerui , Huacai Chen , Jiaxun Yang , James Hogan , Paul Burton , Ralf Baechle , linux-mips@linux-mips.org Subject: [RFC PATCH 2/2] MIPS: VDSO: support extcc-based timekeeping Date: Sun, 24 Feb 2019 17:36:35 +0800 Message-Id: <20190224093635.1242-3-kernel@xen0n.name> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190224093635.1242-1-kernel@xen0n.name> References: <20190224093635.1242-1-kernel@xen0n.name> MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Xuerui The clocksource bits are ready, just wire things up in VDSO for a significant user-space timekeeping performance gain. There are several ABI problems uncovered by vdsotest though, but daily usage of the test system didn't expose any of them. These inconsistencies will be fixed in a later commit (presently TODO). According to vdsotest (formatting is manually added, only the affected figures are shown): category before after -------- ------ ----- clock-gettime-monotonic: syscall: 409 401 nsec/call clock-gettime-monotonic: libc: 476 141 nsec/call clock-gettime-monotonic: vdso: 462 123 nsec/call clock-gettime-realtime: syscall: 405 407 nsec/call clock-gettime-realtime: libc: 474 142 nsec/call clock-gettime-realtime: vdso: 457 125 nsec/call gettimeofday: syscall: 406 407 nsec/call gettimeofday: libc: 455 121 nsec/call gettimeofday: vdso: 440 102 nsec/call The benchmark was run on a single-socket 3A3000 @ 1.4GHz. There is still plenty of headroom for improvements of course, but let's take care of the micro-optimizations later. Signed-off-by: Wang Xuerui Tested-by: Wang Xuerui Cc: Huacai Chen Cc: Jiaxun Yang Cc: James Hogan Cc: Paul Burton Cc: Ralf Baechle Cc: linux-mips@linux-mips.org --- arch/mips/include/asm/clocksource.h | 1 + arch/mips/loongson64/common/extcc.c | 3 +-- arch/mips/vdso/gettimeofday.c | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/asm/clocksource.h b/arch/mips/include/asm/clocksource.h index 3deb1d0c1a94..6a126a475892 100644 --- a/arch/mips/include/asm/clocksource.h +++ b/arch/mips/include/asm/clocksource.h @@ -17,6 +17,7 @@ #define VDSO_CLOCK_NONE 0 /* No suitable clocksource. */ #define VDSO_CLOCK_R4K 1 /* Use the coprocessor 0 count. */ #define VDSO_CLOCK_GIC 2 /* Use the GIC. */ +#define VDSO_CLOCK_EXTCC 3 /* Use the Loongson ExtCC. */ /** * struct arch_clocksource_data - Architecture-specific clocksource information. diff --git a/arch/mips/loongson64/common/extcc.c b/arch/mips/loongson64/common/extcc.c index 702cb389856a..0f6775099411 100644 --- a/arch/mips/loongson64/common/extcc.c +++ b/arch/mips/loongson64/common/extcc.c @@ -23,8 +23,7 @@ static struct clocksource extcc_clocksource = { .read = extcc_read, .mask = CLOCKSOURCE_MASK(64), .flags = CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_VALID_FOR_HRES, - /* TODO later */ - .archdata = { .vdso_clock_mode = VDSO_CLOCK_NONE }, + .archdata = { .vdso_clock_mode = VDSO_CLOCK_EXTCC }, }; void __init extcc_clocksource_init(void) diff --git a/arch/mips/vdso/gettimeofday.c b/arch/mips/vdso/gettimeofday.c index e22b422f282c..92eef8de36a4 100644 --- a/arch/mips/vdso/gettimeofday.c +++ b/arch/mips/vdso/gettimeofday.c @@ -17,6 +17,9 @@ #include #include #include +#ifdef CONFIG_LOONGSON_EXTCC_CLKSRC +#include +#endif #ifdef CONFIG_MIPS_CLOCK_VSYSCALL @@ -148,6 +151,11 @@ static __always_inline u64 get_ns(const union mips_vdso_data *data) case VDSO_CLOCK_GIC: cycle_now = read_gic_count(data); break; +#endif +#ifdef CONFIG_LOONGSON_EXTCC_CLKSRC + case VDSO_CLOCK_EXTCC: + cycle_now = __extcc_read_ordered(); + break; #endif default: return 0;