From patchwork Sun Nov 10 02:56:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1192530 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106868-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="sPlgcy2w"; dkim=pass (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="Pgq3ruBe"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 479f271pLXz9sTg for ; Sun, 10 Nov 2019 14:02:37 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=V+m Z+x3q2e78xfZVJNgZRxLOyoZsMeib9X7KMA9D5Sn+htVsRoWJSRCz7eoxeKjHW1w cZRStGa5V3r01FkJRA6GbLmsLf/9nlyYnbnpZFGZLm6EP5RFYmmER3db9WZwcg2a d4eZEwOD1dIDf8+8hfSUpVdwaGjPiq41Cxi/VXxQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=HHr9C2SEH lRRDVPrA9+lPVYqqls=; b=sPlgcy2w3TgjWan3rszo9Z4/G8jBVvGqdF0MFBpZV 0M0FiePgLyb1WoJXOvj4HRHtusZbeJ3qvV4e3EIBLQzaq1/Royp5gmKQQlm4EOKt /7yi6wRyMUjLESGYT+/Oxj/AWyzF7C9zMYQJh4cKFEzKT3dePlf/+e8EUot353lu oI= Received: (qmail 92994 invoked by alias); 10 Nov 2019 03:02:27 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 92960 invoked by uid 89); 10 Nov 2019 03:02:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=5.1, HContent-Transfer-Encoding:8bit X-HELO: esa3.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1573354942; x=1604890942; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=t6yiXLD7ionGNfbEb3/5GBf/JS1x7bVZ8EnMG81a1qY=; b=Pgq3ruBeXbStfsEoHGOelPtNuwlmX7XWKXm9LPCnpg0EmPgCDLgYfm/l ChrNNMGNx8qXL/MHZBn1FjOZoJWuz762pNCROOYyLmoa7M0u9KqQbAblb Flp9rhAi8ed9B5dPwW7LD8/j/MksYW1pARLvNMmUEY9hAY9GtldhgLCvQ 6JQ2ycdknQskuP2aByX4CRa2x966POvfZGS49DiFu6t3VTKFmCCyFO5WV IwE/nzwhBaQSEQ+sULz/qib3MqR9Ms62nsWWp7fHgMi3NeLOW7Eu5rMuN b2aUic4wvu+xwyou041R+DKGrQo3Z6Wcv2J3VUcFojTDv6dXhUk2051NS Q==; IronPort-SDR: troff2zG040W7IiPeTh1qCKpf4hcNEInuhMFDkC+P1wlHoNG1Mj/Cm4FigDR6CcFXvTLpzHT7F RUI2slOK6rCNisWh6WM/es2reFG+jx3rqZgkHpP8dfsqYkoc9M8ZlF/aOSsCTirLL/I4OJTleV GJ204T7plqp69bCbOA2V7TtGM1BVsRFmRVML9xOvytlTwrvnljtrLX4AGfhB3RK8sPEDcSuLAg Rwg5Rq4ioLA8SurNhwhrFfGHAi3t23UePaVQ/LM6WCs4tSF5OVJG1199WTUWWUFnBxNV0XmmAP Fr0= IronPort-SDR: cc635yjyjw7pk4vC5maa2pyFeg6m8HtDDP11OTIrQWw1HRgYYi1FKQrhkRg6xw0YEOiCi4PUyT VGBg6g0R3UUyBQCpjzsIjQ/lV4nLAxK3z8DX4ABMu2c9TIfz3prtdRVQhnp2jQVzU2e93FLOno 2YPlzAs5l8y/9EMzrrr2zyDey71sGG97c/OH/dx7q12rZ/xWexuMXVCPx5BycR5DDZlx3DDMUF HkjCIZTg2+IW6yG2W8oReGb5cdVwpPryDTCL5gOFjoqJXqvu+ICSVbce1odt4BJl7SOmqZnssk CWSDndCr9a/2V6N3H1p2tO4d IronPort-SDR: gHBLBtGzs/CYVm1O0nY49DkcG4dkyNUsstUoWSRdmZybPVhHHrAyvcNpgCwfw8FfOxbOkYXryU Ia+Ypmz/fNuvRBMKG0O4+7W/1OZTP58nWHqduCqvyWs4CxAkgN1Hdc8uKUkhv3EWSFny6N7Lni VAu5MjkQYmg5F9EBe+eYmwFkUy/a5up1sGVd8K+M14bUIWrvwP6uq4oghcSfuctAFXes+Fk+yO J9wBORKE2YNcgBSUup6/LUk3p1xyVJseSGl2SdZssnvE7BjFckZJXhjsRIwA6GQiQo+5BtkmYj yH4= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v2 1/2] sysdeps: Add clock_gettime64 vDSO Date: Sat, 9 Nov 2019 18:56:57 -0800 Message-Id: <20191110025658.3149-1-alistair.francis@wdc.com> MIME-Version: 1.0 Add support for the clock_gettim64 vDSO calls. These are protected by the HAVE_CLOCK_GETTIME64_VSYSCALL define. HAVE_CLOCK_GETTIME64_VSYSCALL should be defined for 32-bit platforms (WORDSIZE == 32) that only run on the 5.1 kernel or later. WORDSIZE == 64 platforms can use #define __vdso_clock_gettime64 __vdso_clock_gettime and use the __vdso_clock_gettime syscall as they don't have a __vdso_clock_gettime64 call. * sysdeps/unix/sysv/linux/init-first.c: Add clock_gettime64 vDSO. * sysdeps/unix/sysv/linux/libc-vdso.h: Likewise. Reviewed-by: Adhemerval Zanella --- sysdeps/unix/sysv/linux/init-first.c | 10 ++++++++++ sysdeps/unix/sysv/linux/libc-vdso.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c index d90ca820be0..d005d133220 100644 --- a/sysdeps/unix/sysv/linux/init-first.c +++ b/sysdeps/unix/sysv/linux/init-first.c @@ -24,6 +24,11 @@ int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *) attribute_hidden; #endif +/* vDSO symbol used on clock_gettime64 implementation. */ +#ifdef HAVE_CLOCK_GETTIME64_VSYSCALL +int (*VDSO_SYMBOL(clock_gettime64)) (clockid_t, struct __timespec64 *) + attribute_hidden; +#endif /* vDSO symbol used on clock_getres implementation. */ #ifdef HAVE_CLOCK_GETRES_VSYSCALL int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *) @@ -52,6 +57,11 @@ __libc_vdso_platform_setup (void) = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME_VSYSCALL); #endif +#ifdef HAVE_CLOCK_GETTIME64_VSYSCALL + VDSO_SYMBOL(clock_gettime64) + = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME64_VSYSCALL); +#endif + #ifdef HAVE_CLOCK_GETRES_VSYSCALL VDSO_SYMBOL(clock_getres) = get_vdso_mangle_symbol (HAVE_CLOCK_GETRES_VSYSCALL); diff --git a/sysdeps/unix/sysv/linux/libc-vdso.h b/sysdeps/unix/sysv/linux/libc-vdso.h index 792ac39d85a..c6d505bab39 100644 --- a/sysdeps/unix/sysv/linux/libc-vdso.h +++ b/sysdeps/unix/sysv/linux/libc-vdso.h @@ -32,6 +32,10 @@ extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *) attribute_hidden; #endif +#ifdef HAVE_CLOCK_GETTIME64_VSYSCALL +extern int (*VDSO_SYMBOL(clock_gettime64)) (clockid_t, struct __timespec64 *) + attribute_hidden; +#endif #ifdef HAVE_CLOCK_GETRES_VSYSCALL extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *) attribute_hidden; From patchwork Sun Nov 10 02:56:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1192531 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106869-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="T2VfPeaI"; dkim=pass (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="Y5fxv65K"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 479f2G5WGqz9sSL for ; Sun, 10 Nov 2019 14:02:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=IO7Jm2hwbYCPlnj2tXPgqcKNtp+aBwR/vtES2hqQC0PtZ4cMZActM cGQNDqNx+T+juvE4A8xhCa0LnloU0oSe1fMhJLPX7mQgtTgBDcUtQpJi1fTNs+G+ s1SzwR9VkLQ9nRx8n4RtUKGQBfDUcNUwuVNlstYAj9Taz/m+6xizdE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=yXvl5xEpTe4zwyHXsHdHcll5op8=; b=T2VfPeaIpB9zCsijSFM8FupPOP2J Pg170EFlJLALpGh5Qg3XkjS4WmIWQiFqMTUNLhGTcnul2zxax5Ebgej/Kg94NYuj 6hnIQnCVuN9/dZurp8hejn7romRDcVohzegUIUlMDgzh8KGebaZapO5nJlY2CA67 lT6KTUFWI+48tHM= Received: (qmail 93017 invoked by alias); 10 Nov 2019 03:02:30 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 92962 invoked by uid 89); 10 Nov 2019 03:02:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy=H*MI:sk:2019111, 5.1, 21114, HContent-Transfer-Encoding:8bit X-HELO: esa3.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1573354944; x=1604890944; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rLFKw4eAGd14Gy/dAbTJoHM8pXvbhr1gujGdFxK9eDk=; b=Y5fxv65KNp6WMco9ejorr84JqkR/qeV6Lgzh9yK1+5Ltulk+5+ssdmuE ywh160GGKIeadLmpLuXkNI1oQ3wqv9+Fn0aFGYrio6gosj3rCX22bjr/p hIlTw1FJ5205PK3MAIaiJBSYrsyC3EFnvP8koBXBc8QWRc1OVfji3MTmO +q7sLdaUu0pmwFM8PA2rB1EHUiHLvXOkOS4OwW3pCqnHLRt2BAKLwc3PR NwZceyAMBIJVB7voOACeG6c94W8CVeC6vsIY+tfDW6kN0GKmVqNexTTRS hW2K92rEw0TkPL0UsaRK5m4sCze4JgLSKkBBU0fCTuQVCX9c/IO3WUoJ0 Q==; IronPort-SDR: R0k2x5RoV0RvxPtgWlkOK0JwK1z3YVIbouucOdKBE8TrP2avgoxBiKQKQetPSVONYxHzP1WIAq KagZYuTdhcLcjyrjBGQyVKVoPT2gT1WjhEhPyM8TQXQ5SSSSW3p8GJwLdBtiM4KWmAGV1OKb7j 7CT5LiIDReBFvpuRvCRBZt3LDwP5jWCJrywxCV32a5NV8ZpBPxhxtZGv1TgXru/JQaHAeijHle uivXMpqn19jjnBIcQndLO23qQ2wCEJgSyyvAZmowiFYeR5uS0sxviYvVByCW5OcZrWTvAQn8rn WQg= IronPort-SDR: jFvzTSjTrGIfwzs6fDHhYZhkHebtUi5mSwZVc1iLUfJXKrImUDqTdX6m8QN9QWgCCB8NZF7YJ9 k4fpn7TyXr0Ud41E0oaUjaMTpOuYQrWuQFPunfxvHsrBhvrMaGvmh8VLQaMtsjlCXNnIU/eqyc diMU+37E8vlwTgf6x90zCU9J27m3uCL78rvUUr5j2BzybZuLWfBE7XMsP+Ard8IawBaLL9vVtf vlD3xK/nRO79R3BPtrcDd8G+tX8tYXZKPyhmGJwveSOIBwfqDcUuCKGZp9RxVhBWSmBchq2EPA KJu5kCgWFO4RP4VH4o9TZ+Lo IronPort-SDR: SiEYdwtEba/p3WkTtR4Fr47md/NwOBmFrn0M9GKCKR/Y7PYmb1nnV1KJU5ZM12Vz+hM/Shz31c 0sjWXPlDQ75HkkD6OWnqhvvyx+YSibzF4afb567Xceqj4Su+ZA1awj88hU7xMXB+YRgJrA/bjU QRkwxDjn62iPnVPWslSTllwW1oNzcb3gs75vVH83zzPoCpKuuKexd6pPMq0ZuGQVycngUVdoDQ OX/XbjRqufj6wx4uSqVb2bueDUo9BaULjjmFoTdVkDOUWfQKFFmV4Sk/QlFNIEO2FjBPlLFEIv C5k= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v2 2/2] sysdeps/clock_gettime: Use clock_gettime64 if avaliable Date: Sat, 9 Nov 2019 18:56:58 -0800 Message-Id: <20191110025658.3149-2-alistair.francis@wdc.com> In-Reply-To: <20191110025658.3149-1-alistair.francis@wdc.com> References: <20191110025658.3149-1-alistair.francis@wdc.com> MIME-Version: 1.0 With the clock_gettime64 call we prefer to use vDSO. There is no call to clock_gettime64 on glibc with older headers and kernel 5.1+ if it doesn't support vDSO. --- This was patch was runtime tested with RV32 and RV64 It was build tested using the ./scripts/build-many-glibcs.py script. I also ran: $ make ; make install ; make check tests on native ARM (32-bit) with the following three confiugrations: - 4.19 Kernel and 4.19 Headers - 5.2 Kernel and 4.19 Headers - 5.2 Kernel and 5.2 Headers and didn't see any regressions v2: - Add commit message - Change ret_64 to int include/time.h | 3 ++ sysdeps/unix/sysv/linux/clock_gettime.c | 50 ++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/time.h b/include/time.h index d7800eb30f8..c19c73ae09f 100644 --- a/include/time.h +++ b/include/time.h @@ -211,11 +211,14 @@ extern double __difftime (time_t time1, time_t time0); #if __TIMESIZE == 64 # define __clock_nanosleep_time64 __clock_nanosleep +# define __clock_gettime64 __clock_gettime #else extern int __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec64 *req, struct __timespec64 *rem); libc_hidden_proto (__clock_nanosleep_time64) +extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp); +libc_hidden_proto (__clock_gettime64) #endif /* Use in the clock_* functions. Size of the field representing the diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index ca40983f6ca..e7af9902f3e 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include #include "kernel-posix-cpu-timers.h" @@ -30,10 +31,57 @@ /* Get current value of CLOCK and store it in TP. */ int +__clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) +{ +#ifdef __ASSUME_TIME64_SYSCALLS +# ifndef __NR_clock_gettime64 +# define __NR_clock_gettime64 __NR_clock_gettime +# define __vdso_clock_gettime64 __vdso_clock_gettime +# endif + return INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); +#else +# if defined __NR_clock_gettime64 && defined HAVE_CLOCK_GETTIME64_VSYSCALL + int ret_64; + ret_64 = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); + + if (ret_64 == 0 || errno != ENOSYS) + return ret_64; +# endif /* __NR_clock_gettime64 && HAVE_CLOCK_GETTIME64_VSYSCALL */ + int ret; + struct timespec tp32; + + ret = INLINE_VSYSCALL (clock_gettime, 2, clock_id, &tp32); + + if (ret == 0) + *tp = valid_timespec_to_timespec64 (tp32); + + return ret; +#endif /* __ASSUME_TIME64_SYSCALLS */ +} + +#if __TIMESIZE != 64 +int __clock_gettime (clockid_t clock_id, struct timespec *tp) { - return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); + int ret; + struct __timespec64 tp64; + + ret = __clock_gettime64 (clock_id, &tp64); + + if (ret == 0) + { + if (! in_time_t_range (tp64.tv_sec)) + { + __set_errno (EOVERFLOW); + return -1; + } + + *tp = valid_timespec64_to_timespec (tp64); + } + + return ret; } +#endif libc_hidden_def (__clock_gettime) versioned_symbol (libc, __clock_gettime, clock_gettime, GLIBC_2_17);