From patchwork Fri Jan 25 16:15:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1031174 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99559-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="kLjWLlc3"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="GYNerD5q"; 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 43mPKL2Yq3z9s4s for ; Sat, 26 Jan 2019 03:16:22 +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 :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=k8X9GJed1R7GW9j9wj+JYXzrx1SGztkCyNFqA23CaoPkmUSLsJdL6 /b8cdPwnsEHxETnu37gt6IcgcHvADzOGXnBp+hjNd12UO7agyo61ZQ0jMHNYO0nu 56/sqhfHqyEHpWMP9tMsYflZGBzLeymirO8knzKZ+eEukV7cBiXSEQ= 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 :content-type:content-transfer-encoding:mime-version; s=default; bh=3wvvWYsAnpbnpacUNxm12i9mLUA=; b=kLjWLlc3a3cnBbz+P4ql2dYxbkdT z8l36U7wTpNANvAftU+TYZZi7yQ/Fwcw8VRq9+yoN784tq+/UOdMXIjW2gYHmNwG qZj37y2OEwmtKoyQOq43eXScqWzFwS0YPQuUmyw+LyeSFtgS26gg3C8tW1yXNMQY ZbCj+OkTWsO8nFo= Received: (qmail 28647 invoked by alias); 25 Jan 2019 16:16:00 -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 28569 invoked by uid 89); 25 Jan 2019 16:15:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1000000000, unnecessarily, playing, clock X-HELO: EUR03-VE1-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qffXOeAdY794EOUeL0DSQ/jWhi+Gwsg8rymnVr2HI1k=; b=GYNerD5qxmTsayB50LVN3fdZlZdh3t/Fy0qqkg8eqGRAGpLrfnhGbTQvMsGv0sTMwJkB7TXLHs5E6rFPh2w2UvEwnj1xuszu3V1ni0VptMajRvDj0turMZi0m3B4/TS/BNfb/iskZ2dEEl5ZtXFktbsadSHLPm14HGqyVhHB1ec= From: Wilco Dijkstra To: 'GNU C Library' CC: nd Subject: [PATCHv2 1/4] Cleanup clock_*time includes Date: Fri, 25 Jan 2019 16:15:50 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 (resend patch as part of hp-timing cleanup) Clock_gettime, settime and getres implementations are unnecessarily complex due to using many defines and C file inclusion. Simplify the code by replacing the redundant defines and removing the inclusion, making it much easier to understand. No functional changes. OK for commit (for 2.30)? ChangeLog: 2019-01-14 Wilco Dijkstra * sysdeps/posix/clock_getres.c (__clock_getres): Cleanup. * sysdeps/unix/clock_gettime.c (__clock_gettime): Cleanup. * sysdeps/unix/clock_settime.c (__clock_settime): Cleanup. * sysdeps/unix/sysv/linux/clock_getres.c (__clock_getres): Cleanup. * sysdeps/unix/sysv/linux/clock_gettime.c (__clock_gettime): Cleanup. * sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime): Cleanup. diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c index f47715ed6b48a54248fb375fbbeb55008b995104..dac4761fcc2c86cb0d53425cab4e88d587696540 100644 --- a/sysdeps/posix/clock_getres.c +++ b/sysdeps/posix/clock_getres.c @@ -82,20 +82,11 @@ __clock_getres (clockid_t clock_id, struct timespec *res) switch (clock_id) { -#ifdef SYSDEP_GETRES - SYSDEP_GETRES; -#endif - -#ifndef HANDLED_REALTIME case CLOCK_REALTIME: retval = realtime_getres (res); break; -#endif /* handled REALTIME */ default: -#ifdef SYSDEP_GETRES_CPU - SYSDEP_GETRES_CPU; -#endif #if HP_TIMING_AVAIL if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1)) == CLOCK_THREAD_CPUTIME_ID) @@ -105,7 +96,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res) __set_errno (EINVAL); break; -#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME +#if HP_TIMING_AVAIL case CLOCK_PROCESS_CPUTIME_ID: case CLOCK_THREAD_CPUTIME_ID: retval = hp_timing_getres (res); diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c index 138991d1bc081cea004e94defe361580dfb022dc..33a1f3335c269eec2b4f01fb927e3836a191b5eb 100644 --- a/sysdeps/unix/clock_gettime.c +++ b/sysdeps/unix/clock_gettime.c @@ -95,11 +95,6 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp) switch (clock_id) { -#ifdef SYSDEP_GETTIME - SYSDEP_GETTIME; -#endif - -#ifndef HANDLED_REALTIME case CLOCK_REALTIME: { struct timeval tv; @@ -108,12 +103,8 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp) TIMEVAL_TO_TIMESPEC (&tv, tp); } break; -#endif default: -#ifdef SYSDEP_GETTIME_CPU - SYSDEP_GETTIME_CPU (clock_id, tp); -#endif #if HP_TIMING_AVAIL if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1)) == CLOCK_THREAD_CPUTIME_ID) @@ -123,7 +114,7 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp) __set_errno (EINVAL); break; -#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME +#if HP_TIMING_AVAIL case CLOCK_PROCESS_CPUTIME_ID: retval = hp_timing_gettime (clock_id, tp); break; diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c index b589e875cf2dfb5fc083550e01e774a6f4d0cae6..24d73b048c1b891906dacdf0c199544b85d924d2 100644 --- a/sysdeps/unix/clock_settime.c +++ b/sysdeps/unix/clock_settime.c @@ -21,7 +21,7 @@ #include -#if HP_TIMING_AVAIL && !defined HANDLED_CPUTIME +#if HP_TIMING_AVAIL /* Clock frequency of the processor. We make it a 64-bit variable because some jokers are already playing with processors with more than 4GHz. */ @@ -84,29 +84,15 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp) switch (clock_id) { -#define HANDLE_REALTIME \ - do { \ - struct timeval tv; \ - TIMESPEC_TO_TIMEVAL (&tv, tp); \ - \ - retval = __settimeofday (&tv, NULL); \ - } while (0) - -#ifdef SYSDEP_SETTIME - SYSDEP_SETTIME; -#endif - -#ifndef HANDLED_REALTIME case CLOCK_REALTIME: - HANDLE_REALTIME; + do { + struct timeval tv; + TIMESPEC_TO_TIMEVAL (&tv, tp); + retval = __settimeofday (&tv, NULL); + } while (0); break; -#endif default: -#ifdef SYSDEP_SETTIME_CPU - SYSDEP_SETTIME_CPU; -#endif -#ifndef HANDLED_CPUTIME # if HP_TIMING_AVAIL if (CPUCLOCK_WHICH (clock_id) == CLOCK_PROCESS_CPUTIME_ID || CPUCLOCK_WHICH (clock_id) == CLOCK_THREAD_CPUTIME_ID) @@ -117,7 +103,6 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp) __set_errno (EINVAL); retval = -1; } -#endif break; } diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c index a24532888fd3f3e256f34fb5a7636cee8b0b7904..bb2ee109bd66f916cc790899fbc205c8890098ae 100644 --- a/sysdeps/unix/sysv/linux/clock_getres.c +++ b/sysdeps/unix/sysv/linux/clock_getres.c @@ -26,26 +26,11 @@ #endif #include -#define SYSCALL_GETRES \ - retval = INLINE_VSYSCALL (clock_getres, 2, clock_id, res); \ - break +/* Get resolution of clock. */ +int +__clock_getres (clockid_t clock_id, struct timespec *res) +{ + return INLINE_VSYSCALL (clock_getres, 2, clock_id, res); +} +weak_alias (__clock_getres, clock_getres) -/* The REALTIME and MONOTONIC clock are definitely supported in the - kernel. */ -#define SYSDEP_GETRES \ - SYSDEP_GETRES_CPUTIME \ - case CLOCK_REALTIME: \ - case CLOCK_MONOTONIC: \ - case CLOCK_MONOTONIC_RAW: \ - case CLOCK_REALTIME_COARSE: \ - case CLOCK_MONOTONIC_COARSE: \ - SYSCALL_GETRES - -/* We handled the REALTIME clock here. */ -#define HANDLED_REALTIME 1 -#define HANDLED_CPUTIME 1 - -#define SYSDEP_GETRES_CPU SYSCALL_GETRES -#define SYSDEP_GETRES_CPUTIME /* Default catches them too. */ - -#include diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index 9af806f76ef34ad711a9f94de77599d6e17fe421..2ad7846a4d811635c40daab62bc0eae9d7d3b7ac 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -26,22 +26,12 @@ #endif #include -/* The REALTIME and MONOTONIC clock are definitely supported in the - kernel. */ -#define SYSDEP_GETTIME \ - SYSDEP_GETTIME_CPUTIME; \ - case CLOCK_REALTIME: \ - case CLOCK_MONOTONIC: \ - retval = INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); \ - break +/* Get current value of CLOCK and store it in TP. */ +int +__clock_gettime (clockid_t clock_id, struct timespec *tp) +{ + return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); +} +weak_alias (__clock_gettime, clock_gettime) +libc_hidden_def (__clock_gettime) -/* We handled the REALTIME clock here. */ -#define HANDLED_REALTIME 1 -#define HANDLED_CPUTIME 1 - -#define SYSDEP_GETTIME_CPU(clock_id, tp) \ - retval = INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); \ - break -#define SYSDEP_GETTIME_CPUTIME /* Default catches them too. */ - -#include diff --git a/sysdeps/unix/sysv/linux/clock_settime.c b/sysdeps/unix/sysv/linux/clock_settime.c index 7e2432b244a40ac620c39010a7e0a556f73a9c79..c5668012e0819059f9bfdd684616e0c9add2b115 100644 --- a/sysdeps/unix/sysv/linux/clock_settime.c +++ b/sysdeps/unix/sysv/linux/clock_settime.c @@ -21,18 +21,18 @@ #include "kernel-posix-cpu-timers.h" +/* Set CLOCK to value TP. */ +int +__clock_settime (clockid_t clock_id, const struct timespec *tp) +{ + /* Make sure the time cvalue is OK. */ + if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000) + { + __set_errno (EINVAL); + return -1; + } + + return INLINE_SYSCALL (clock_settime, 2, clock_id, tp); +} +weak_alias (__clock_settime, clock_settime) -/* The REALTIME clock is definitely supported in the kernel. */ -#define SYSDEP_SETTIME \ - case CLOCK_REALTIME: \ - retval = INLINE_SYSCALL (clock_settime, 2, clock_id, tp); \ - break - -/* We handled the REALTIME clock here. */ -#define HANDLED_REALTIME 1 - -#define HANDLED_CPUTIME 1 -#define SYSDEP_SETTIME_CPU \ - retval = INLINE_SYSCALL (clock_settime, 2, clock_id, tp) - -#include From patchwork Fri Jan 25 16:18:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1031177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99560-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="lUkULbOv"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="Y7kWFdGm"; 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 43mPN14Rryz9s4s for ; Sat, 26 Jan 2019 03:18:41 +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 :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=JJw/eYDxrrklVZG6bTAhViuAEyEqOkd/drbSFdITRRfo9Mbo5BqrO AyodixUu2A5r7ZrZPYyR2sGnnmgEi/J2PadPj25UfnuzpWWBgZQ0KmVRTszQU2Nn qQzEOK3qtQRjAP4iYon5Mo+ZaZ/Cqjp79nt3z0pJM+uEzpg6RHFF7s= 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 :content-type:content-transfer-encoding:mime-version; s=default; bh=6ezVZgWUvw12O1u7XBLKTkHsmXE=; b=lUkULbOvoeTEhFIp+Lnfp8svljuQ 6RP01Q2jqSACeN1hVq+LBePRj5Zeh2Kzy1qBHYrmYO1kCv1r7LPypG2L0mKTcrXr MzV6jDOe9nIe4KVaV9KdKJ3nJZwJdtMjsp3qgWKhonAbuL/WLQUI5j/22vH6tWS5 7sU7KGBCVXxv67s= Received: (qmail 32914 invoked by alias); 25 Jan 2019 16:18:35 -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 32906 invoked by uid 89); 25 Jan 2019 16:18:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=frequently X-HELO: EUR04-HE1-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qafNn47fRDjlEz872bnYL94eeSNNQztRzuX7abaYeW8=; b=Y7kWFdGmC7bh8gZzgqL9CFDgIgDja0bAKotu8lcj3dodrFQweD18xQZ0hp3zJNefZZv3GxNbd+27A+W2CXm86UUIuHqugPUWk2k1GE0wXTGLWI7/G30WapyOO9RtZOe3qv3GHc7Vu+Zk1cqS+MbB926zYYUccTGsG7opp1DKN6A= From: Wilco Dijkstra To: 'GNU C Library' CC: nd Subject: [PATCHv2 2/4] Cleanup hp-timing defines Date: Fri, 25 Jan 2019 16:18:27 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 v2: removes HP_TIMING_SMALL from elf/rtld.c Cleanup the defines in the hp-timing header: Replace HP_TIMING_AVAIL with HP_TIMING_INLINE since these are equivalent. Remove conflicting uses of HP_SMALL_TIMING_AVAIL and HP_TIMING_NONAVAIL. Reserve HP_TIMING_NONAVAIL only for rtld internal timing. No functional changes (apart from not using rtld timing on alpha). OK for commit? ChangeLog: 2019-01-25 Wilco Dijkstra * elf/dl-support.c: Use HP_TIMING_INLINE. * elf/rtld.c (HP_TIMING_NONAVAIL): Define. (_dl_start_final): Cleanup timing. (_dl_start): Add HP_TIMING_NONAVAIL around timing code. * nptl/allocatestack.c: Use HP_TIMING_INLINE. * nptl/descr.h: Likewise. * nptl/nptl-init.c: Likewise. * nptl/pthread_clock_gettime.c: Likewise. * nptl/pthread_clock_settime.c: Likewise. * nptl/pthread_create.c: Likewise. * sysdeps/generic/ldsodefs.h: Likewise. * sysdeps/mach/hurd/dl-sysdep.c: Likewise. * sysdeps/nptl/fork.c: Likewise. * sysdeps/posix/clock_getres.c: Likewise. * sysdeps/unix/clock_gettime.c: Likewise. * sysdeps/unix/clock_nanosleep.c: Likewise. * sysdeps/unix/clock_settime.c: Likewise. * sysdeps/unix/sysv/linux/sysconf.c: Likewise. diff --git a/elf/dl-support.c b/elf/dl-support.c index 42c350c75d89ebdac1d6ec4bb50c2e0897e2fd87..b1290361a9f08973a16c020168c49bb99d6bb8d1 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -130,7 +130,7 @@ void *_dl_random; #include /* Initial value of the CPU clock. */ -#ifndef HP_TIMING_NONAVAIL +#if HP_TIMING_INLINE hp_timing_t _dl_cpuclock_offset; #endif @@ -314,8 +314,9 @@ _dl_non_dynamic_init (void) _dl_main_map.l_phdr = GL(dl_phdr); _dl_main_map.l_phnum = GL(dl_phnum); - if (HP_SMALL_TIMING_AVAIL) - HP_TIMING_NOW (_dl_cpuclock_offset); +#if HP_TIMING_INLINE + HP_TIMING_NOW (_dl_cpuclock_offset); +#endif _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1; diff --git a/elf/rtld.c b/elf/rtld.c index 5d97f41b7bccb61592e7fb84521f869475587734..f74ab30f363e04e3d355e91e1d86b1c239b18d08 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -46,6 +46,10 @@ #include +#if !HP_TIMING_INLINE +# define HP_TIMING_NONAVAIL 1 +#endif + /* Avoid PLT use for our local calls at startup. */ extern __typeof (__mempcpy) __mempcpy attribute_hidden; @@ -335,7 +339,7 @@ static ElfW(Addr) _dl_start_final (void *arg); struct dl_start_final_info { struct link_map l; -#if !defined HP_TIMING_NONAVAIL && HP_TIMING_INLINE +#ifndef HP_TIMING_NONAVAIL hp_timing_t start_time; #endif }; @@ -371,16 +375,9 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) { ElfW(Addr) start_addr; - if (HP_SMALL_TIMING_AVAIL) - { - /* If it hasn't happen yet record the startup time. */ - if (! HP_TIMING_INLINE) - HP_TIMING_NOW (start_time); #if !defined DONT_USE_BOOTSTRAP_MAP && !defined HP_TIMING_NONAVAIL - else - start_time = info->start_time; + start_time = info->start_time; #endif - } /* Transfer data about ourselves to the permanent link_map structure. */ #ifndef DONT_USE_BOOTSTRAP_MAP @@ -403,7 +400,9 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) # endif #endif +#if HP_TIMING_INLINE HP_TIMING_NOW (GL(dl_cpuclock_offset)); +#endif /* Initialize the stack end variable. */ __libc_stack_end = __builtin_frame_address (0); @@ -416,16 +415,13 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) #ifndef HP_TIMING_NONAVAIL hp_timing_t rtld_total_time; - if (HP_SMALL_TIMING_AVAIL) - { - hp_timing_t end_time; + hp_timing_t end_time; - /* Get the current time. */ - HP_TIMING_NOW (end_time); + /* Get the current time. */ + HP_TIMING_NOW (end_time); - /* Compute the difference. */ - HP_TIMING_DIFF (rtld_total_time, start_time, end_time); - } + /* Compute the difference. */ + HP_TIMING_DIFF (rtld_total_time, start_time, end_time); #endif if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS)) @@ -459,11 +455,12 @@ _dl_start (void *arg) #define RESOLVE_MAP(sym, version, flags) BOOTSTRAP_MAP #include "dynamic-link.h" - if (HP_TIMING_INLINE && HP_SMALL_TIMING_AVAIL) -#ifdef DONT_USE_BOOTSTRAP_MAP +#ifndef HP_TIMING_NONAVAIL +# ifdef DONT_USE_BOOTSTRAP_MAP HP_TIMING_NOW (start_time); -#else +# else HP_TIMING_NOW (info.start_time); +# endif #endif /* Partly clean the `bootstrap_map' structure up. Don't use @@ -1050,12 +1047,16 @@ of this helper program; chances are you did not intend to run this program.\n\ } else { +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (start); +#endif _dl_map_object (NULL, rtld_progname, lt_executable, 0, __RTLD_OPENEXEC, LM_ID_BASE); +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (stop); HP_TIMING_DIFF (load_time, start, stop); +#endif } /* Now the map for the main executable is available. */ @@ -1619,11 +1620,15 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (__glibc_unlikely (preloadlist != NULL)) { +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (start); +#endif npreloads += handle_ld_preload (preloadlist, main_map); +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (stop); HP_TIMING_DIFF (diff, start, stop); HP_TIMING_ACCUM_NT (load_time, diff); +#endif } /* There usually is no ld.so.preload file, it should only be used @@ -1682,9 +1687,9 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", problem = NULL; file[file_size - 1] = '\0'; } - +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (start); - +#endif if (file != problem) { char *p; @@ -1700,11 +1705,11 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", npreloads += do_preload (p, main_map, preload_file); } - +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (stop); HP_TIMING_DIFF (diff, start, stop); HP_TIMING_ACCUM_NT (load_time, diff); - +#endif /* We don't need the file anymore. */ __munmap (file, file_size); } @@ -1727,12 +1732,15 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", /* Load all the libraries specified by DT_NEEDED entries. If LD_PRELOAD specified some libraries to load, these are inserted before the actual dependencies in the executable's searchlist for symbol resolution. */ +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (start); +#endif _dl_map_object_deps (main_map, preloads, npreloads, mode == trace, 0); +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (stop); HP_TIMING_DIFF (diff, start, stop); HP_TIMING_ACCUM_NT (load_time, diff); - +#endif /* Mark all objects as being in the global scope. */ for (i = main_map->l_searchlist.r_nlist; i > 0; ) main_map->l_searchlist.r_list[--i]->l_global = 1; @@ -2127,9 +2135,8 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", #ifndef HP_TIMING_NONAVAIL hp_timing_t start; hp_timing_t stop; -#endif - HP_TIMING_NOW (start); +#endif assert (main_map->l_info [VALIDX (DT_GNU_CONFLICTSZ)] != NULL); conflict = (ElfW(Rela) *) main_map->l_info [ADDRIDX (DT_GNU_CONFLICT)]->d_un.d_ptr; @@ -2137,8 +2144,10 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", ((char *) conflict + main_map->l_info [VALIDX (DT_GNU_CONFLICTSZ)]->d_un.d_val); _dl_resolve_conflicts (main_map, conflict, conflictend); +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (stop); HP_TIMING_DIFF (relocate_time, start, stop); +#endif } @@ -2169,12 +2178,12 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", #ifndef HP_TIMING_NONAVAIL hp_timing_t start; hp_timing_t stop; + HP_TIMING_NOW (start); #endif /* If we are profiling we also must do lazy reloaction. */ GLRO(dl_lazy) |= consider_profiling; - HP_TIMING_NOW (start); unsigned i = main_map->l_searchlist.r_nlist; while (i-- > 0) { @@ -2201,10 +2210,11 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (l->l_tls_blocksize != 0 && tls_init_tp_called) _dl_add_to_slotinfo (l); } +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (stop); HP_TIMING_DIFF (relocate_time, start, stop); - +#endif /* Now enable profiling if needed. Like the previous call, this has to go here because the calls it makes should use the rtld versions of the functions (particularly calloc()), but it @@ -2250,15 +2260,17 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", hp_timing_t start; hp_timing_t stop; hp_timing_t add; + HP_TIMING_NOW (start); #endif - HP_TIMING_NOW (start); /* Mark the link map as not yet relocated again. */ GL(dl_rtld_map).l_relocated = 0; _dl_relocate_object (&GL(dl_rtld_map), main_map->l_scope, 0, 0); +#ifndef HP_TIMING_NONAVAIL HP_TIMING_NOW (stop); HP_TIMING_DIFF (add, start, stop); HP_TIMING_ACCUM_NT (relocate_time, add); +#endif } /* Do any necessary cleanups for the startup OS interface code. @@ -2702,7 +2714,6 @@ print_statistics (hp_timing_t *rtld_total_timep) char *wp; /* Total time rtld used. */ - if (HP_SMALL_TIMING_AVAIL) { HP_TIMING_PRINT (buf, sizeof (buf), *rtld_total_timep); _dl_debug_printf ("\nruntime linker statistics:\n" @@ -2770,7 +2781,6 @@ print_statistics (hp_timing_t *rtld_total_timep) #ifndef HP_TIMING_NONAVAIL /* Time spend while loading the object and the dependencies. */ - if (HP_SMALL_TIMING_AVAIL) { char pbuf[30]; HP_TIMING_PRINT (buf, sizeof (buf), load_time); diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 670cb8ffe65c4ee93e65f79c036229362da03f55..318d08e9ea55e484561629570ca8e1b72506d428 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -962,7 +962,7 @@ __reclaim_stacks (void) } -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE # undef __find_thread_by_id /* Find a thread given the thread ID. */ attribute_hidden diff --git a/nptl/descr.h b/nptl/descr.h index 9c54cbc8f2bb0d7cb8ec62d21c70ddbab762a483..a114656d99239c0084b83986f756e233e8a7530f 100644 --- a/nptl/descr.h +++ b/nptl/descr.h @@ -342,7 +342,7 @@ struct pthread /* Lock for synchronizing setxid calls. */ unsigned int setxid_futex; -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE /* Offset of the CPU clock at start thread start time. */ hp_timing_t cpuclock_offset; #endif diff --git a/nptl/nptl-init.c b/nptl/nptl-init.c index b5895fabf32026182434cb1d92e3f7a6431653ea..5e4527cc4dc91138568d7606f4f8e03850621ee5 100644 --- a/nptl/nptl-init.c +++ b/nptl/nptl-init.c @@ -276,7 +276,7 @@ __pthread_initialize_minimal_internal (void) THREAD_SETMEM (pd, user_stack, true); if (LLL_LOCK_INITIALIZER != 0) THREAD_SETMEM (pd, lock, LLL_LOCK_INITIALIZER); -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE THREAD_SETMEM (pd, cpuclock_offset, GL(dl_cpuclock_offset)); #endif diff --git a/nptl/pthread_clock_gettime.c b/nptl/pthread_clock_gettime.c index f1d9104b24a00d45d192011ea530360a522d3157..7d1008e21f4e541261fcc95c6dc004bb24efa33a 100644 --- a/nptl/pthread_clock_gettime.c +++ b/nptl/pthread_clock_gettime.c @@ -21,7 +21,7 @@ #include "pthreadP.h" -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE int __pthread_clock_gettime (clockid_t clock_id, hp_timing_t freq, struct timespec *tp) diff --git a/nptl/pthread_clock_settime.c b/nptl/pthread_clock_settime.c index 0fe6482f7898d1976a78c6f4fc91996d87859f69..0fee8721d2c5771e4cc1964d5c0ed488720cbd35 100644 --- a/nptl/pthread_clock_settime.c +++ b/nptl/pthread_clock_settime.c @@ -21,7 +21,7 @@ #include "pthreadP.h" -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE int __pthread_clock_settime (clockid_t clock_id, hp_timing_t offset) { diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index 2bd2b10727812f277e51fa0b681a7b802f18516f..bb4b001ae901aa84e541b1a28b3539f19bfb4634 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -379,7 +379,7 @@ START_THREAD_DEFN { struct pthread *pd = START_THREAD_SELF; -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE /* Remember the time when the thread was started. */ hp_timing_t now; HP_TIMING_NOW (now); diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 37cab6f06b29335f942d7e1a9d9af20daef36908..78658e2d4d35ea2d052d2107e2d0675b5e0b28f6 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -352,7 +352,7 @@ struct rtld_global /* The object to be initialized first. */ EXTERN struct link_map *_dl_initfirst; -#if HP_SMALL_TIMING_AVAIL +#if HP_TIMING_INLINE /* Start time on CPU clock. */ EXTERN hp_timing_t _dl_cpuclock_offset; #endif diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index a58338c9302d13baea014fa3cb3c63c3d0f1ae0e..ea55726151f75a33f02c738a51efe44135ae0353 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -62,7 +62,7 @@ int __libc_multiple_libcs = 0; /* Defining this here avoids the inclusion void *__libc_stack_end = NULL; rtld_hidden_data_def(__libc_stack_end) -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE hp_timing_t _dl_cpuclock_offset; #endif @@ -246,7 +246,7 @@ unfmh(); /* XXX */ /* Initialize frequently used global variable. */ GLRO(dl_pagesize) = __getpagesize (); -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE HP_TIMING_NOW (_dl_cpuclock_offset); #endif diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c index bd68f18b459c1ffd25b2a66584dd741ab2061b18..839df1a9a929ea4a33963fd66a30429c4e9fa7aa 100644 --- a/sysdeps/nptl/fork.c +++ b/sysdeps/nptl/fork.c @@ -83,7 +83,7 @@ __libc_fork (void) if (__fork_generation_pointer != NULL) *__fork_generation_pointer += __PTHREAD_ONCE_FORK_GEN_INCR; -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE /* The CPU clock of the thread and process have to be set to zero. */ hp_timing_t now; HP_TIMING_NOW (now); diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c index dac4761fcc2c86cb0d53425cab4e88d587696540..9365e0edaf5601f5d1e039203977f0d965ac7d28 100644 --- a/sysdeps/posix/clock_getres.c +++ b/sysdeps/posix/clock_getres.c @@ -24,7 +24,7 @@ #include -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE static long int nsec; /* Clock frequency of the processor. */ static int @@ -87,7 +87,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res) break; default: -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1)) == CLOCK_THREAD_CPUTIME_ID) retval = hp_timing_getres (res); @@ -96,7 +96,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res) __set_errno (EINVAL); break; -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE case CLOCK_PROCESS_CPUTIME_ID: case CLOCK_THREAD_CPUTIME_ID: retval = hp_timing_getres (res); diff --git a/sysdeps/unix/clock_gettime.c b/sysdeps/unix/clock_gettime.c index 33a1f3335c269eec2b4f01fb927e3836a191b5eb..c21a530d21eee81d2d36793431973c646904615c 100644 --- a/sysdeps/unix/clock_gettime.c +++ b/sysdeps/unix/clock_gettime.c @@ -24,7 +24,7 @@ #include -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE /* Clock frequency of the processor. We make it a 64-bit variable because some jokers are already playing with processors with more than 4GHz. */ @@ -105,7 +105,7 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp) break; default: -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE if ((clock_id & ((1 << CLOCK_IDFIELD_SIZE) - 1)) == CLOCK_THREAD_CPUTIME_ID) retval = hp_timing_gettime (clock_id, tp); @@ -114,7 +114,7 @@ __clock_gettime (clockid_t clock_id, struct timespec *tp) __set_errno (EINVAL); break; -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE case CLOCK_PROCESS_CPUTIME_ID: retval = hp_timing_gettime (clock_id, tp); break; diff --git a/sysdeps/unix/clock_nanosleep.c b/sysdeps/unix/clock_nanosleep.c index 7722d1111c7908463cd0b71b2c5e53012dabfa86..9d7497272dc4efd0643df5d5cfc1c6b2dfd35086 100644 --- a/sysdeps/unix/clock_nanosleep.c +++ b/sysdeps/unix/clock_nanosleep.c @@ -22,7 +22,7 @@ #include #include -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE # define CPUCLOCK_P(clock) \ ((clock) == CLOCK_PROCESS_CPUTIME_ID \ || ((clock) & ((1 << CLOCK_IDFIELD_SIZE) - 1)) == CLOCK_THREAD_CPUTIME_ID) diff --git a/sysdeps/unix/clock_settime.c b/sysdeps/unix/clock_settime.c index 24d73b048c1b891906dacdf0c199544b85d924d2..166bc5aadb8e09d3fdfbe3078aef8dbbcfb6eba2 100644 --- a/sysdeps/unix/clock_settime.c +++ b/sysdeps/unix/clock_settime.c @@ -21,7 +21,7 @@ #include -#if HP_TIMING_AVAIL +#if HP_TIMING_INLINE /* Clock frequency of the processor. We make it a 64-bit variable because some jokers are already playing with processors with more than 4GHz. */ @@ -93,7 +93,7 @@ __clock_settime (clockid_t clock_id, const struct timespec *tp) break; default: -# if HP_TIMING_AVAIL +# if HP_TIMING_INLINE if (CPUCLOCK_WHICH (clock_id) == CLOCK_PROCESS_CPUTIME_ID || CPUCLOCK_WHICH (clock_id) == CLOCK_THREAD_CPUTIME_ID) retval = hp_timing_settime (clock_id, tp); diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c index 4b297ba35fccdb92a02f0071efbe9fe84dd8e0e5..320b5f64e45068cbc213d69abdfc9f14c6ad4de7 100644 --- a/sysdeps/unix/sysv/linux/sysconf.c +++ b/sysdeps/unix/sysv/linux/sysconf.c @@ -39,10 +39,10 @@ static long int posix_sysconf (int name); static long int has_cpuclock (int name) { -# if defined __NR_clock_getres || HP_TIMING_AVAIL +# if defined __NR_clock_getres || HP_TIMING_INLINE /* If we have HP_TIMING, we will fall back on that if the system call does not work, so we support it either way. */ -# if !HP_TIMING_AVAIL +# if !HP_TIMING_INLINE /* Check using the clock_getres system call. */ struct timespec ts; INTERNAL_SYSCALL_DECL (err); From patchwork Fri Jan 25 16:20:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1031178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99561-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="nP6GMhsC"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="pCWdnklZ"; 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 43mPQ841shz9s4s for ; Sat, 26 Jan 2019 03:20:32 +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 :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=oJt7PUmGgyIr//juQogSgJwobs9lSft0h08WhMJgzQl7P3adp4cds /EDumpyYhHDHYRa5yHGNB0rmrvES7EjN2eJzaH9H8Lr41IMjXo85iZpoqrKP2GiF SGE2bZoXbv3ioMC557lMPe18SGcfwtkABGZW8QOiedif0/C6k2gN/A= 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 :content-type:content-transfer-encoding:mime-version; s=default; bh=w2h5iooB81jWCJT4ryFxL4onfMc=; b=nP6GMhsCU44KCbzB6cR8JKUlkWzF u/B+gCgjkk6kBbnJjrrtY1eMVf3jXpQQ5GVU18ohB9hM6Lw5wrecdq0iy5UsDI30 uldbLOEx4yjPA12P4Zos71TF1x701WvL/BbFUoEc+pecaKlLpJJwW9mTs9p6TsDd mDDye1OmdZDbi+4= Received: (qmail 54543 invoked by alias); 25 Jan 2019 16:20:26 -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 53448 invoked by uid 89); 25 Jan 2019 16:20:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=sparcv9 X-HELO: EUR04-DB3-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L3KABdoTmFh35wxMR2WrIIrsudjAz1/GSYRD1wKElh8=; b=pCWdnklZnLHqame5ZtZrFd4bDQi4isHbQeQDbIh5D3Y4YkV4lShLWK+tLZQPyabENubwx+BkPzFOVIMCDxRGdVqJsJ/N9Y89yq6YAR/cndzsb9ooH4JIlqzllWLyaQzjOvoFr156Q11Oo/PXG8TmnoUpKkJvvxJE2qk/JmjKP98= From: Wilco Dijkstra To: 'GNU C Library' CC: nd Subject: [PATCHv2 3/4] Add generic hp-timing support Date: Fri, 25 Jan 2019 16:20:20 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 v2: use stdint.h rather than inttypes.h Add missing generic hp_timing support. Remove unused HP_TIMING_AVAIL and HP_SMALL_TIMING_AVAIL. Use the VDSO clock_gettime (CLOCK_MONOTONIC, ) on targets which don't use an inlined instruction returning time/cycles. ChangeLog: 2019-01-25 Wilco Dijkstra * sysdeps/alpha/hp-timing.h (HP_TIMING_AVAIL): Remove define. (HP_SMALL_TIMING_AVAIL) Remove. * sysdeps/generic/hp-timing.h (HP_TIMING_NONAVAIL): Remove. (HP_TIMING_NOW): Add generic implementation. * sysdeps/generic/hp-timing-common.h (HP_TIMING_AVAIL): Remove. * sysdeps/ia64/hp-timing.h (HP_TIMING_AVAIL): Remove define. (HP_SMALL_TIMING_AVAIL) Remove. * sysdeps/powerpc/powerpc32/power4/hp-timing.h: Likewise. * sysdeps/powerpc/powerpc64/hp-timing.h: Likewise. * sysdeps/sparc/sparc32/sparcv9/hp-timing.h: Likewise. * sysdeps/sparc/sparc64/hp-timing.h: Likewise. * sysdeps/x86/hp-timing.h: Likewise. diff --git a/sysdeps/alpha/hp-timing.h b/sysdeps/alpha/hp-timing.h index 481132663ce0268de1b3384a7a01084e70d9af66..65db6031ee19dbd86ae42806faa66d00bf09ab12 100644 --- a/sysdeps/alpha/hp-timing.h +++ b/sysdeps/alpha/hp-timing.h @@ -21,12 +21,8 @@ #define _HP_TIMING_H 1 /* We always have the timestamp register, but it's got only a 4 second - range. Use it for ld.so profiling only. */ -#define HP_TIMING_AVAIL (0) -#define HP_SMALL_TIMING_AVAIL (1) - -/* We indeed have inlined functions. */ -#define HP_TIMING_INLINE (1) + range. Only use it for benchmarking. */ +#define HP_TIMING_INLINE (0) /* We use 32 bit values for the times. */ typedef unsigned int hp_timing_t; diff --git a/sysdeps/generic/hp-timing-common.h b/sysdeps/generic/hp-timing-common.h index 0ffb8534442165bdb93628bf973cb758bb8546f6..f7a0147a4f2788ae9c7a14b248fd580e7cc04b07 100644 --- a/sysdeps/generic/hp-timing-common.h +++ b/sysdeps/generic/hp-timing-common.h @@ -20,8 +20,6 @@ /* In case a platform supports timers in the hardware the following macros and types must be defined: - - HP_TIMING_AVAIL: test for availability. - - HP_TIMING_INLINE: this macro is non-zero if the functionality is not implemented using function calls but instead uses some inlined code which might simply consist of a few assembler instructions. We have to diff --git a/sysdeps/generic/hp-timing.h b/sysdeps/generic/hp-timing.h index fb2a6036fc9a208b7d5524c45927c273c96746a8..aad768dc849ff4b81844c4a7514e15f144ffa2f3 100644 --- a/sysdeps/generic/hp-timing.h +++ b/sysdeps/generic/hp-timing.h @@ -20,21 +20,19 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -/* There are no generic definitions for the times. We could write something - using the `gettimeofday' system call where available but the overhead of - the system call might be too high. */ +#include +#include +#include -/* Provide dummy definitions. */ -#define HP_TIMING_AVAIL (0) -#define HP_SMALL_TIMING_AVAIL (0) #define HP_TIMING_INLINE (0) -typedef int hp_timing_t; -#define HP_TIMING_NOW(var) -#define HP_TIMING_DIFF(Diff, Start, End) -#define HP_TIMING_ACCUM_NT(Sum, Diff) -#define HP_TIMING_PRINT(Buf, Len, Val) - -/* Since this implementation is not available we tell the user about it. */ -#define HP_TIMING_NONAVAIL 1 + +typedef uint64_t hp_timing_t; + +#define HP_TIMING_NOW(var) \ +({ \ + struct timespec tv; \ + __clock_gettime (CLOCK_MONOTONIC, &tv); \ + (var) = (tv.tv_nsec + (uint64_t) 1000000000 * tv.tv_sec); \ +}) #endif /* hp-timing.h */ diff --git a/sysdeps/ia64/hp-timing.h b/sysdeps/ia64/hp-timing.h index 17ef023a11564de9afd4eb9bfb706539d4400163..2ca248a530ab239c4789a00fb0e46d6ca43861ef 100644 --- a/sysdeps/ia64/hp-timing.h +++ b/sysdeps/ia64/hp-timing.h @@ -20,10 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -/* We always assume having the timestamp register. */ -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) - /* We indeed have inlined functions. */ #define HP_TIMING_INLINE (1) diff --git a/sysdeps/powerpc/powerpc32/power4/hp-timing.h b/sysdeps/powerpc/powerpc32/power4/hp-timing.h index 0d77aa0992afd2487abb5bdf894585d81a4c02ee..ed2ca9bc7a0506945fcea65b9ebf699dba0f6ea0 100644 --- a/sysdeps/powerpc/powerpc32/power4/hp-timing.h +++ b/sysdeps/powerpc/powerpc32/power4/hp-timing.h @@ -20,10 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -/* We always assume having the timestamp register. */ -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) - /* We indeed have inlined functions. */ #define HP_TIMING_INLINE (1) diff --git a/sysdeps/powerpc/powerpc64/hp-timing.h b/sysdeps/powerpc/powerpc64/hp-timing.h index fb9ac1ce2a5e70f4c185380ca8df43cabcc6fd48..01678cd63432a8edd19f274122add87fc7e8a7e8 100644 --- a/sysdeps/powerpc/powerpc64/hp-timing.h +++ b/sysdeps/powerpc/powerpc64/hp-timing.h @@ -20,10 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -/* We always assume having the timestamp register. */ -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) - /* We indeed have inlined functions. */ #define HP_TIMING_INLINE (1) diff --git a/sysdeps/sparc/sparc32/sparcv9/hp-timing.h b/sysdeps/sparc/sparc32/sparcv9/hp-timing.h index 6a4ab08679330b019fc419ec64d4f4bd0079f609..3270c5b40a17c4af5e4c3d9c1f5b028a9a7a8a62 100644 --- a/sysdeps/sparc/sparc32/sparcv9/hp-timing.h +++ b/sysdeps/sparc/sparc32/sparcv9/hp-timing.h @@ -20,8 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) #define HP_TIMING_INLINE (1) typedef unsigned long long int hp_timing_t; diff --git a/sysdeps/sparc/sparc64/hp-timing.h b/sysdeps/sparc/sparc64/hp-timing.h index db95c02a8d91eea8db4a00d542c331e30f9f38e9..0f02b2a98f267d0e90e5297d5855753bc58c907c 100644 --- a/sysdeps/sparc/sparc64/hp-timing.h +++ b/sysdeps/sparc/sparc64/hp-timing.h @@ -20,8 +20,6 @@ #ifndef _HP_TIMING_H #define _HP_TIMING_H 1 -#define HP_TIMING_AVAIL (1) -#define HP_SMALL_TIMING_AVAIL (1) #define HP_TIMING_INLINE (1) typedef unsigned long int hp_timing_t; diff --git a/sysdeps/x86/hp-timing.h b/sysdeps/x86/hp-timing.h index 9b6a998bcdd594d6260f0be9a8a783edbc8d333b..57b4c293cd65485669d359127e580d2ffacd3644 100644 --- a/sysdeps/x86/hp-timing.h +++ b/sysdeps/x86/hp-timing.h @@ -22,9 +22,6 @@ #include #if MINIMUM_ISA == 686 || MINIMUM_ISA == 8664 -/* We always assume having the timestamp register. */ -# define HP_TIMING_AVAIL (1) -# define HP_SMALL_TIMING_AVAIL (1) /* We indeed have inlined functions. */ # define HP_TIMING_INLINE (1) From patchwork Fri Jan 25 16:22:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 1031179 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-99562-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="JC1eiS7m"; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="m5an7oL8"; 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 43mPSX5xXlz9s4s for ; Sat, 26 Jan 2019 03:22:36 +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 :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=W6x+nhtO7lH/QxagaRRye94xvsaNeV5KPh06CR62+nHWtOF+PHaZ/ fUH/pyioyMf/iQebe9Cj0OUfW0JrMzfiRK69mO8F2ioHqUIrhLHUMSAoSxzMQv4S HBbiNhPav7BK3U2grueYeTWiCvRJWwXgVGjyCmIlaz2rQtSZWMjHNg= 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 :content-type:content-transfer-encoding:mime-version; s=default; bh=DjkKjwpzDAj6BRmdIimYv8Ra7N0=; b=JC1eiS7mDelZVse6Ayu9mtE37PXV eKKT3RYi58MholS6NuybWru5D8DT+XKmuLfc6RMhF4SufWEKkW5G/2PQ94KhoCbw kL7Tea+yGkFWVv1hilCucJ+tA++S5E1ujtavG3s6h9Dq8x4FLyfoUiK5ZtvPXQdF SYkqSkWhPatAA9w= Received: (qmail 99133 invoked by alias); 25 Jan 2019 16:22: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 98797 invoked by uid 89); 25 Jan 2019 16:22:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=machines X-HELO: EUR04-DB3-obe.outbound.protection.outlook.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zAnbmqjOjN+CBbaLIrLoY6t9kCE0F1d5v8KFvjKqg3k=; b=m5an7oL87eleVjP2xJvMMk4VEEhEW1k2vBFlZHsy/SdFSIS45euaH3VXQV41npHBGIN/dJ/R+zA7ScNsof7YjoGH+pLfcI95s35Ciua81IGTj2yCTjAf9nk+W4+svTXqhpG23T+Q8mt7QKblrXDHX9Kre4WvX1gieQ9kDfyQnwQ= From: Wilco Dijkstra To: 'GNU C Library' CC: nd Subject: [PATCHv2 4/4] Cleanup hp-timing uses Date: Fri, 25 Jan 2019 16:22:24 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 Now we have a generic hp-timing implementation, use it by default for benchmarking and a few cases where random bits are required (given the default CLOCK_MONOTONIC has an unspecified starting time and nano-second accuracy, its randomness is significantly better than using gettimeofday). ChangeLog: 2019-01-15 Wilco Dijkstra * benchtests/Makefile (USE_CLOCK_GETTIME) Remove. * benchtests/README: Update description. * benchtests/bench-timing.h: Default to hp-timing. * resolv/res_mkquery.c: Likewise. * resolv/res_send.c: Likewise. * sysdeps/posix/tempname.c: Likewise. diff --git a/benchtests/Makefile b/benchtests/Makefile index eef13bf1d1791d00fc3692af883cc9bbd092a5d0..12036b1935dc7ea84b421f024d6fe3190ae35a6e 100644 --- a/benchtests/Makefile +++ b/benchtests/Makefile @@ -127,17 +127,11 @@ endif CPPFLAGS-nonlib += -DDURATION=$(BENCH_DURATION) -D_ISOMAC -# Use clock_gettime to measure performance of functions. The default is to use -# HP_TIMING if it is available. -ifdef USE_CLOCK_GETTIME -CPPFLAGS-nonlib += -DUSE_CLOCK_GETTIME -else # On x86 processors, use RDTSCP, instead of RDTSC, to measure performance # of functions. All x86 processors since 2010 support RDTSCP instruction. ifdef USE_RDTSCP CPPFLAGS-nonlib += -DUSE_RDTSCP endif -endif DETAILED_OPT := diff --git a/benchtests/README b/benchtests/README index aaf0b659e2b25627230a7280cd858a29f5532392..c4f03fd872de8c5ec0c805e94a2a13e4b0adfa78 100644 --- a/benchtests/README +++ b/benchtests/README @@ -27,12 +27,7 @@ BENCH_DURATION. The benchmark suite does function call measurements using architecture-specific high precision timing instructions whenever available. When such support is -not available, it uses clock_gettime (CLOCK_PROCESS_CPUTIME_ID). One can force -the benchmark to use clock_gettime by invoking make as follows: - - $ make USE_CLOCK_GETTIME=1 bench - -Again, one must run `make bench-clean' before changing the measurement method. +not available, it uses clock_gettime (CLOCK_MONOTONIC). On x86 processors, RDTSCP instruction provides more precise timing data than RDTSC instruction. All x86 processors since 2010 support RDTSCP diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h index 41b7324527b9deed67b3479cb1308fbd291bc5ca..42f907e850d1ff901b0a5cdcedf00c4c44a8829f 100644 --- a/benchtests/bench-timing.h +++ b/benchtests/bench-timing.h @@ -18,49 +18,18 @@ #undef attribute_hidden #define attribute_hidden +#define __clock_gettime clock_gettime #include -#include -#if HP_TIMING_AVAIL && !defined USE_CLOCK_GETTIME # define GL(x) _##x # define GLRO(x) _##x typedef hp_timing_t timing_t; # define TIMING_TYPE "hp_timing" - # define TIMING_INIT(res) ({ (res) = 1; }) - # define TIMING_NOW(var) HP_TIMING_NOW (var) # define TIMING_DIFF(diff, start, end) HP_TIMING_DIFF ((diff), (start), (end)) # define TIMING_ACCUM(sum, diff) HP_TIMING_ACCUM_NT ((sum), (diff)) -#else - -#include -typedef uint64_t timing_t; - -# define TIMING_TYPE "clock_gettime" - -/* Measure the resolution of the clock so we can scale the number of - benchmark iterations by this value. */ -# define TIMING_INIT(res) \ -({ \ - struct timespec start; \ - clock_getres (CLOCK_PROCESS_CPUTIME_ID, &start); \ - (res) = start.tv_nsec; \ -}) - -# define TIMING_NOW(var) \ -({ \ - struct timespec tv; \ - clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &tv); \ - (var) = (uint64_t) (tv.tv_nsec + (uint64_t) 1000000000 * tv.tv_sec); \ -}) - -# define TIMING_DIFF(diff, start, end) (diff) = (end) - (start) -# define TIMING_ACCUM(sum, diff) (sum) += (diff) - -#endif - #define TIMING_PRINT_MEAN(d_total_s, d_iters) \ printf ("\t%g", (d_total_s) / (d_iters)) diff --git a/resolv/res_mkquery.c b/resolv/res_mkquery.c index 19b8b402c44a4ac5cff6e0cefac9f054b4fd3081..4d5ef9dced9ec7180031760c6620958fcd1bc937 100644 --- a/resolv/res_mkquery.c +++ b/resolv/res_mkquery.c @@ -95,9 +95,6 @@ #include #include -#if HP_TIMING_AVAIL -# define RANDOM_BITS(Var) { uint64_t v64; HP_TIMING_NOW (v64); Var = v64; } -#endif int __res_context_mkquery (struct resolv_context *ctx, int op, const char *dname, @@ -120,14 +117,8 @@ __res_context_mkquery (struct resolv_context *ctx, int op, const char *dname, /* We randomize the IDs every time. The old code just incremented by one after the initial randomization which still predictable if the application does multiple requests. */ - int randombits; -#ifdef RANDOM_BITS - RANDOM_BITS (randombits); -#else - struct timeval tv; - __gettimeofday (&tv, NULL); - randombits = (tv.tv_sec << 8) ^ tv.tv_usec; -#endif + hp_timing_t randombits; + HP_TIMING_NOW (randombits); hp->id = randombits; hp->opcode = op; diff --git a/resolv/res_send.c b/resolv/res_send.c index fa040c1198fadce5ae9b2d8c373bfb4c0489f6c4..7152527f57975618a0723a92e0a134ea18436491 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -309,15 +309,9 @@ nameserver_offset (struct __res_state *statp) if ((offset & 1) == 0) { /* Initialization is required. */ -#if HP_TIMING_AVAIL - uint64_t ticks; + hp_timing_t ticks; HP_TIMING_NOW (ticks); offset = ticks; -#else - struct timeval tv; - __gettimeofday (&tv, NULL); - offset = ((tv.tv_sec << 8) ^ tv.tv_usec); -#endif /* The lowest bit is the most random. Preserve it. */ offset <<= 1; diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c index 2ed39d1a42989417c159bdd199bcfd9473592177..f8a4ff0aab099a9fe8c62230a86bc820012d3d61 100644 --- a/sysdeps/posix/tempname.c +++ b/sysdeps/posix/tempname.c @@ -72,21 +72,6 @@ #ifdef _LIBC # include -# if HP_TIMING_AVAIL -# define RANDOM_BITS(Var) \ - if (__glibc_unlikely (value == UINT64_C (0))) \ - { \ - /* If this is the first time this function is used initialize \ - the variable we accumulate the value in to some somewhat \ - random value. If we'd not do this programs at startup time \ - might have a reduced set of possible names, at least on slow \ - machines. */ \ - struct timeval tv; \ - __gettimeofday (&tv, NULL); \ - value = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; \ - } \ - HP_TIMING_NOW (Var) -# endif #endif /* Use the widest available unsigned type if uint64_t is not @@ -194,7 +179,7 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind) int len; char *XXXXXX; static uint64_t value; - uint64_t random_time_bits; + hp_timing_t random_time_bits; unsigned int count; int fd = -1; int save_errno = errno; @@ -227,15 +212,7 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind) XXXXXX = &tmpl[len - 6 - suffixlen]; /* Get some more or less random data. */ -#ifdef RANDOM_BITS - RANDOM_BITS (random_time_bits); -#else - { - struct timeval tv; - __gettimeofday (&tv, NULL); - random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec; - } -#endif + HP_TIMING_NOW (random_time_bits); value += random_time_bits ^ __getpid (); for (count = 0; count < attempts; value += 7777, ++count)