Received: by 10.223.164.202 with SMTP id h10csp542518wrb; Fri, 10 Nov 2017 10:26:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMZOhueEdMEIIrL/5GtqnCJVdIurfQaW49BNSyJ7Ghm87lPC37Mqhx5d/zSGSgmynXnpS7bk X-Received: by 10.99.160.100 with SMTP id u36mr1209367pgn.22.1510338418355; Fri, 10 Nov 2017 10:26:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510338418; cv=none; d=google.com; s=arc-20160816; b=QLK77Tnw3dNJARrYUu/UYHHeILBirnVAi2uu+1ru8UGfBIV+u+0Q0S2VXnQeskbG9u pwE0DgW42IwVvbyEqfidB14/qAdPAuKe+xLZWg9de084gG7KH7MVR+shbT0zDUi/iC+f eBQUm4AMJvq8ZDxON7bhJ8SmmPSsNWC8r/pE+DItmlTb/9jGEV8MZ45k3HpRCdsmzekW f//Yic7Z7wtsRPdKrh63R1tgOzQPhO2qdLBLxjW7XaPJWXBqtVEf9kIoEbVvA/ktMpIB ZPoxo5ckQBox1Avg6njkJucoN909UacPhopm10W6Qm9xrjYkj5KAxpp0k809NZZ6Pbe+ elQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=NItn86r5im2TqZ36VrOKxkdDvHhfc519PH3wchGo5Sw=; b=ajKMjGomDAZddLhs37ZpLoW7EzFemfh2/XAN0MKJ7Wagv6A0C2wYJKhxzwgU5V3iLV 1c5cYvp326xOCkgWQ7ipMxcQb22DRabVv5fYWBPKy9EbGvmVDBTLhxupHAyw/7lvJQnh foHDCKYSwf9ysI+ySE+4syNwNgND2OsR6fEoE4iXWBPzmEPtrVSbvxdaKE39Z5kIGc8R Z8IsYeO/T+oIFmANOhOso0IV1E5qbVwnPTGG+sPiNGoY9st52WILXWdrykwuR/IgJoDY PJJ0Ta6wPNNaHqibwJ1DbtEsWxLdHKi0WL+tp6UaSK5fRaZHVMV+cgiQEaQH9EziLH5o H8xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=pkDXyrkG; 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 l62si5209930pgd.777.2017.11.10.10.26.46; Fri, 10 Nov 2017 10:26:58 -0800 (PST) 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=pkDXyrkG; 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 S1753674AbdKJSZf (ORCPT + 82 others); Fri, 10 Nov 2017 13:25:35 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:54338 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751142AbdKJSZd (ORCPT ); Fri, 10 Nov 2017 13:25:33 -0500 Received: by mail-io0-f196.google.com with SMTP id e89so14494329ioi.11 for ; Fri, 10 Nov 2017 10:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=NItn86r5im2TqZ36VrOKxkdDvHhfc519PH3wchGo5Sw=; b=pkDXyrkGOkOf4umunkOhYaa6dvwaViPKeMR6CI91TD0EerpzCXVg1tg782lqUd8URM awQy6Lplw1lsOfX5MgAMCwxCH5f6nNbhURQ/0rcS9xXBnEaBnUvPMqdePaqKk/1dXpDj 4eDEnWs/noBa6cScd/7CBrrW/nklfKmlaEWXvmx9xpvQs9ink4V36MlcXXebeK/fyM2a Ud5hGIV7EyMTmGhnXoSglgovtkALm2YrqZaztanfVv2oJZvLggVlcEFWOLAMSB373XQK AOC4WcT8bdu30f/sN9wQz2DpMwv3xTriwN4lVlbYqirxqWQ7rUMh7nbk+p2vpkxLzWIQ MCUw== 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; bh=NItn86r5im2TqZ36VrOKxkdDvHhfc519PH3wchGo5Sw=; b=JoQxxDZ71tHoaIlBObor0r3c/fXRjjsgvNtQzjawlIc4X1Hv/qpd/i8Sivbp0ty/1B 7xC2FL5yOIB9/qxTFeQKZVqnC6uOlYp/Sdsw1JEfEk9Y7/NurG54xfX6wKYAKXOB9pFZ 40IPtmOChsJqU+ZyELFbkCOqO0kbD0PtMcvIZn7Dd/1QtqUcZqkl0iVvTRuPscr9nN7w oWpDAXO2sNeXxzapGvfEjRtCzD4AN0uucMy5HSqrPPTTZLO+hVhhuon6gW5LNlApSdVT whh4JTdxrnP+g19+ohkGxzUmn2Q4KW68LRG1MqdsSFa48DnBlBK1VZKKlE7wTZZHth8+ JMHg== X-Gm-Message-State: AJaThX4HQZ3TNRh7xwHwxi7dcNja3TDYBJl2GSUyZz4DkfPo/P+xN3r5 g1l/0irWw0XIwnLeeN+dwEFOaTJ/slI= X-Received: by 10.107.46.216 with SMTP id u85mr1474738iou.2.1510338332468; Fri, 10 Nov 2017 10:25:32 -0800 (PST) Received: from nebulus.mtv.corp.google.com ([100.98.120.17]) by smtp.gmail.com with ESMTPSA id b133sm4925182ioe.73.2017.11.10.10.25.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Nov 2017 10:25:32 -0800 (PST) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: 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, Mark Salyzyn Subject: [PATCH] lib: vdso: add support for time Date: Fri, 10 Nov 2017 10:24:53 -0800 Message-Id: <20171110182513.44671-1-salyzyn@android.com> X-Mailer: git-send-email 2.15.0.448.gf294e3d99a-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 NB: to be applied _after_ [PATCH v5 10/12] arm64: vdso: replace gettimeofday.S with global vgettimeofday.C --- 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 da52aade40a3..b8ae87b4d526 100644 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -190,6 +190,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 079955162be8..d8d675d46749 100644 --- a/lib/vdso/vgettimeofday.c +++ b/lib/vdso/vgettimeofday.c @@ -385,3 +385,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.15.0.448.gf294e3d99a-goog From 1584733443191533364@xxx Wed Nov 22 02:59:43 +0000 2017 X-GM-THRID: 1584731493109200601 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread