Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp360301imm; Mon, 1 Oct 2018 11:03:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV60/EDCvrLP/0MLJ0xKKzcChwcJdeWk9aKUUFXSVBktmprAk2PO/3H5v6LkxigBdJOwpst0D X-Received: by 2002:a63:d0e:: with SMTP id c14-v6mr11104079pgl.281.1538417034479; Mon, 01 Oct 2018 11:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538417034; cv=none; d=google.com; s=arc-20160816; b=VB8finGTbgiXwA3caxNuGNxqSkGONYvC5AlWFcNnvNWYq8oDNwV+wUuhXBFNtslSyV YpHK+F4rUMxsaTFyY71WNPqCdxm090j8VpseV7wvdgL+vam/3MxAxZJf/V3GLi1F92Od VhxFq5l6CVWJIrWxMWa7P2hV6hJJn3uWh/zK9F4qk1wQJCsHuHuVOwHXECE2CftFOeip FjXJsVjhJkb5Z43Mxwel/Ncsr15x2GKI6y9glIjFXMFsoEieYeCia7cLg6rEbnMHns+A GVphYZnlA2pvFah+UKO/qwPW5uBKqJNgLwiUXrcmiSgRWxlllT+O+/FSZ4rOYWNWJK/D nuyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sAg4sPW371XoUS8BgWwdN7mYJ3LZ3I5Z3B6wtVLhU0I=; b=vURNDI+LLLlwIOaAMyOOJEWQSGQZ9O6HcIMg+i9pEkO0gQkicbD8uzjD9d96QpNMRW AqToU3BB7JEmq/TkW6RePTKW28ap1kDO2mLbF9F7vskJdkFiXBadlLI1EaPaFjdUeqJX PgdM0jyXM2c77xXArxmbaBtCWP0dGXMd1dE5FuQDKwru7qaB2knsUAcMceTk6yVIIYBu b40NuSWJsKx2REaw7nVGQQ9mJK7Fd/WuvQ1OCF4rn0KMWtmhEL+3GAIbLEcRLExkq07g X7FJpGLPd8mIZblAUdGfCh5q8MeX/nZRbBTpV3sh25yqYNiKOD0K8iysjlB6jx7ov1Eb /Qcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=PPzPkDoc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w124-v6si7477685pfw.145.2018.10.01.11.03.36; Mon, 01 Oct 2018 11:03:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=PPzPkDoc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726543AbeJBAmH (ORCPT + 99 others); Mon, 1 Oct 2018 20:42:07 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:37058 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbeJBAmH (ORCPT ); Mon, 1 Oct 2018 20:42:07 -0400 Received: by mail-pf1-f193.google.com with SMTP id j23-v6so453309pfi.4 for ; Mon, 01 Oct 2018 11:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sAg4sPW371XoUS8BgWwdN7mYJ3LZ3I5Z3B6wtVLhU0I=; b=PPzPkDoc3wQh3ufJMNTfIXs8cVit+nBkS+IzKbwnkmDl+OhvrA1FMBmJHh9cGfJ5Ff f1p4D9505pRZr6PMSy3mZ2BJxCyvVO1Uu2mbyE4t/MP+w/WidvXCkwIechtXmqDZfD7N hx0amM6kso1wakct4Gh+aNZ0I+nOt5Omg49IgHp+3EjXP8Vbvy624UNTYzAuliFtzEcT YAlWxdQROUaUuJ5QPWhwOXvxKBxaf7Hw5Ll3EvOhuhaWCdeV3vhGyxXY9jMS8VIyD5Iw smb3C9jsqlAB7vlKURwUPfEuu6OQovxuMLJw6owQ156tzsnbZuGJmZZseJ28B1BVkXgM Z8Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sAg4sPW371XoUS8BgWwdN7mYJ3LZ3I5Z3B6wtVLhU0I=; b=W9+Phot4thshfvYwmcq4EfTcv9pUOc9NwqYRzRUq1ik1c6aYqAVcmYQtkl0Q4JqLrk QUFXJBOGc/QzLuZ4eCYcgpU2zYPL1gycP88sSiy8dK1lHCPz5gn5eX1GyBiUBAokcSVR 0HTECo9AKTlb44GSOeYwwp//0LF0dKwWa3FLFcyI7xrjMlezVOSf9I4UA/RcNUcs65HZ H/D16CxtZJp6fJXWbOrWNnzmDzDYOZFjClLDE+2g9IatI91w4fZg4RatNH+20dVzU+GX zNiFopQE6aDKVr8FsSURUET5uUdj99AQTt1W9fnB/G7ixvnbM7a1oYMUvOXMQU0W4wfr /UEw== X-Gm-Message-State: ABuFfog0tcYiglhskwlKvdPwDe4qpKFCgJmjfwtl8LJkU2oCUgKZeBVZ 0tUwtS8c3V2GDV+sKTXqLHRilXpFgUA= X-Received: by 2002:a62:f909:: with SMTP id o9-v6mr12724905pfh.160.1538416988212; Mon, 01 Oct 2018 11:03:08 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:0:1000:1612:b4fb:6752:f21f:3502]) by smtp.gmail.com with ESMTPSA id d186-v6sm24469261pfg.173.2018.10.01.11.03.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 11:03:07 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: Mark Salyzyn , Mark Salyzyn , James Morse , Russell King , Catalin Marinas , Will Deacon , Andy Lutomirski , Dmitry Safonov , John Stultz , Mark Rutland , Laura Abbott , Kees Cook , Ard Biesheuvel , Andy Gross , Kevin Brodsky , Andrew Pinski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Jeremy Linton , android-kernel@android.com, Jinbum Park , Ingo Molnar , "Paul E. McKenney" Subject: RESEND [PATCH] lib: vdso: add support for time Date: Mon, 1 Oct 2018 10:58:33 -0700 Message-Id: <20181001175845.168430-14-salyzyn@android.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181001175845.168430-1-salyzyn@android.com> References: <20181001175845.168430-1-salyzyn@android.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Salyzyn Add time() vdso support to match up with existing support in the x86's vdso. Currently benefitting arm and arm64 which uses the common vgettimeofday.c implementation. On arm provides about a ~14 fold improvement in speed over the straight syscall, and about a ~5 fold improvement in speed over an alternate library implementation that relies on the vdso call to gettimeofday to fulfill the request. We can provide __vdso_time even if we can not provide a speed enhanced __vdso_gettimeofday. (arm, virtual counters). Signed-off-by: Mark Salyzyn Tested-by: Mark Salyzyn Cc: James Morse Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Lutomirski Cc: Dmitry Safonov Cc: John Stultz Cc: Mark Rutland Cc: Laura Abbott Cc: Kees Cook Cc: Ard Biesheuvel Cc: Andy Gross Cc: Kevin Brodsky Cc: Andrew Pinski Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: Jeremy Linton Cc: android-kernel@android.com --- arch/arm/kernel/vdso.c | 1 + arch/arm/vdso/vdso.lds.S | 1 + arch/arm64/kernel/vdso/compiler.h | 1 + arch/arm64/kernel/vdso/vdso.lds.S | 1 + lib/vdso/vgettimeofday.c | 10 ++++++++++ 5 files changed, 14 insertions(+) diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c index 51d8dcbd9952..6721854c5ae6 100644 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -192,6 +192,7 @@ static void __init patch_vdso(void *ehdr) vdso_nullpatch_one(&einfo, "__vdso_gettimeofday"); vdso_nullpatch_one(&einfo, "__vdso_clock_gettime"); vdso_nullpatch_one(&einfo, "__vdso_clock_getres"); + /* do not zero out __vdso_time, no cntvct_ok dependency */ } } diff --git a/arch/arm/vdso/vdso.lds.S b/arch/arm/vdso/vdso.lds.S index 1d81e8c3acf6..1eb577091d1f 100644 --- a/arch/arm/vdso/vdso.lds.S +++ b/arch/arm/vdso/vdso.lds.S @@ -83,6 +83,7 @@ VERSION __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; + __vdso_time; local: *; }; } diff --git a/arch/arm64/kernel/vdso/compiler.h b/arch/arm64/kernel/vdso/compiler.h index 921a7191b497..fb27545640f2 100644 --- a/arch/arm64/kernel/vdso/compiler.h +++ b/arch/arm64/kernel/vdso/compiler.h @@ -65,5 +65,6 @@ static __always_inline notrace u64 arch_vdso_read_counter(void) #define __vdso_clock_gettime __kernel_clock_gettime #define __vdso_gettimeofday __kernel_gettimeofday #define __vdso_clock_getres __kernel_clock_getres +#define __vdso_time __kernel_time #endif /* __VDSO_COMPILER_H */ diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index beca249bc2f3..9de0ffc369c5 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -88,6 +88,7 @@ VERSION __kernel_gettimeofday; __kernel_clock_gettime; __kernel_clock_getres; + __kernel_time; local: *; }; } diff --git a/lib/vdso/vgettimeofday.c b/lib/vdso/vgettimeofday.c index 54e519c99c4b..dfced9608cd3 100644 --- a/lib/vdso/vgettimeofday.c +++ b/lib/vdso/vgettimeofday.c @@ -386,3 +386,13 @@ int __vdso_clock_getres(clockid_t clock, struct timespec *res) return 0; } + +notrace time_t __vdso_time(time_t *t) +{ + const struct vdso_data *vd = __get_datapage(); + time_t result = READ_ONCE(vd->xtime_coarse_sec); + + if (t) + *t = result; + return result; +} -- 2.19.0.605.g01d371f741-goog