Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4037542imm; Mon, 18 Jun 2018 08:10:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJanzTZsMbZ6UrQ71ectNaUSkTH7uwD2y8ofqMWhOyHzyGMs0dmCRk2HJhIVV9uRVqRSdT9 X-Received: by 2002:a65:46cb:: with SMTP id n11-v6mr11159475pgr.193.1529334603371; Mon, 18 Jun 2018 08:10:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529334603; cv=none; d=google.com; s=arc-20160816; b=CAl171IwpowFrJ64FwV03RIC9BUc69zt/D4eTikBw64dN5Fyoca97iPlmD/icZvg1U Uhl/ntnJFSNiU2ELKegQ588kfAZ1mdaHq3dCEXeixDeqi20EdYvknhsTKh/sJiZ4u9lj OxtsJaHqmvXflFgKNiYh0H6t02GCxMmxk74g+pk0PT/igBjq+NWY3UK8TEIYsIS0sX3n uUrP7Ls+Q6ujIMS03qj/lFfClmVO7lPmhTo+sncbnQjIv3K0W+egW8ne7c8KvIFO1/mK PHYSblRsiLkZnWe7iEjGICLSgeBGzRkkAwIN2cBHRYxHnNa4aE3mcso/+lKCdmakc4zH DXEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=JuvxweFTcRzmxkzWcSbXPEqCe+2P0+NqBKtnGp9jj+k=; b=RQnMcKa6HkqJx2ULTXVLxnztXsZkxDVsrkRampNPgWjL67LUcjhwI/CDCH62AKvG/z f055CGyf4QwWBvjEUKbMgCpreRwOpVaFlZINTfoyxdlPL4gyv8taSAom2lJ7IDr3SmPb gm9d3P2Wxqoot3J7KR4G39L+TjyB1f8L5kh7orNyj3gTyIXljp5Hy2b/G+5rtu5SiTBQ fkkNP6G88YPnJaqRSV4JXzAz/5jla2dg83P416kWHctOn7wKtB98u4Ieq6p4Tt0vL4jj 29JPvjFByVZUkafa7k5YE9s3jRRQpAPAj9oAx2mg24KPmDBz5asXesjiAtjTmvFN8Pxq QLVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=ejh2by3C; 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 i6-v6si11863564pgv.328.2018.06.18.08.09.49; Mon, 18 Jun 2018 08:10:03 -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=ejh2by3C; 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 S964788AbeFRPI6 (ORCPT + 99 others); Mon, 18 Jun 2018 11:08:58 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43772 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935277AbeFRPIz (ORCPT ); Mon, 18 Jun 2018 11:08:55 -0400 Received: by mail-pl0-f66.google.com with SMTP id c41-v6so9188658plj.10 for ; Mon, 18 Jun 2018 08:08:55 -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; bh=JuvxweFTcRzmxkzWcSbXPEqCe+2P0+NqBKtnGp9jj+k=; b=ejh2by3C3GoZQfZUQBH8SjS9wHcIQ0brv8ziSas15/DMUO9ahLj6G139MMTFsTNukM amo70KnSKvNCR40rG8V04Znbuuxy5tWMkbvZP5k1JW4yDubFPv7N7HK9oe62L3Wr3B5Y kYgvd0SxszOhRhPkF3VMJRE/JSlTvSA/LxJYH+sfSZFrKxyO0+RpvkXHz4Lcyj4rF4IW NNZZ9zUzHD6E9Z78uPFUF/oe+18mBEkgd7V+dJw42HkaQR1onLsF82X168PX9tSd22HV wlaNsg+WaM/CIti1KZNjkFkZ5H67/WDppgI6BCQURLqpexOk+QnuT8cqECrO7dwOvXk4 57Hg== 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; bh=JuvxweFTcRzmxkzWcSbXPEqCe+2P0+NqBKtnGp9jj+k=; b=uZyBKYZ6+cPQSusUBL9YJ4Rm4uIBJHzTQ2zxGCEEPMN4gGs380aHP6Tg0VivCtTnuY 4PIONMhpB9dV+4nM4x7XYupxXgzNF39lmUb241YUXF+7dkIGR1MMyOyFVvnJIQSVHb5q sdq8Yw689C2w5tH/g3MhIbEKFnisRJzCJ/MRHvch5Z/RzZdY5L5ldQN3W2MvaF5S8mI9 zpCcH1ZnJ/C5uBA5gYSGenWh5yuLkd6X8pgyFFn1aXs0142pKzIkYW5b82QqPOqZTD3q 4OCaWQfOoYo67N3m9mACcTg6N8AZandPfCEFUL+m9DkJ5rvNmvnq2v/WwuDoZeJVncgY xrPA== X-Gm-Message-State: APt69E1CM6ciD6sYBsUs9y0/19wolDxMLgaTn5+u3sTewGpgmo3SzR6O QM7QZ4GHosZMo5oPLAh0LJYq+IhGPXY= X-Received: by 2002:a17:902:ba8a:: with SMTP id k10-v6mr14493245pls.338.1529334534977; Mon, 18 Jun 2018 08:08:54 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:0:1000:1611:6077:8eec:bc7e:d0f4]) by smtp.gmail.com with ESMTPSA id i7-v6sm54830660pfa.34.2018.06.18.08.08.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 08:08:54 -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 , Jinbum Park , "Paul E. McKenney" , Ingo Molnar Subject: RESEND [PATCH] lib: vdso: add support for time Date: Mon, 18 Jun 2018 08:05:59 -0700 Message-Id: <20180618150613.10322-14-salyzyn@android.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180618150613.10322-1-salyzyn@android.com> References: <20180618150613.10322-1-salyzyn@android.com> 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 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 --- 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.18.0.rc1.244.gcf134e6275-goog