From patchwork Fri Feb 8 18:39:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 157871 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2284611jaa; Fri, 8 Feb 2019 10:40:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IbxscGRpgOwETSy6hLWb2QqwW/Efk9cRGk+xgR4pcDMQ/BVESm9ZzuGVfo6LXq6LQB+0Pbc X-Received: by 2002:a17:902:bd86:: with SMTP id q6mr23620759pls.16.1549651224348; Fri, 08 Feb 2019 10:40:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549651224; cv=none; d=google.com; s=arc-20160816; b=iJezh8UhyX2NOtI/8+Po97JVwjDJB4Q1E5N1Zk29taKhDPJz3mCT0MojgkTJFs8Syn Mq644l8jiLaeQ/A8H3zJewth2bb1wb83SKzmxdNEdTkX7tAdqci75I1WqKL4rjf5w4sR 4Yqq4YSCFftC+eRu7a2SzoqRuMQYtKMy5U4z4idXR+8GisAEXkdYuXry7DYMYfqKT6Kd PAO76/3tHnxqYR7L1tXDXRvNFKTf8mjSRqS0s4ZVP8aFE8EGEFb1S2Pol/yZyPdS88At C+ucT8ByDo6XVi5ITnzY/1pS/b8LSdbfBPP9eSXUSXXrUiVZc/V8wjlf8tbdabNxfB0y xVqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=Uw1w0TslApD4D90ZXkCqPciwF5rsC+h8yrGd9kiS6Wo=; b=00TH68DLnYMxQmXl1NsyUkEssIqDzTqqU5bf3uu2dIsUu9Hwkog2HaJiAkKPIghQHE 8jWlbw9390yNglI91b9cyhA5GEWjluUOBRooyxgl0WSmzCbRtfevnhnGgGlUnyzbpyvc IZ7NHPZYeSY9peY5tUSI2ztilwWzZR6cU3PVXhC7JvNuHBcBASarVLQlT7eUQfw+jCJp 9hTvkmqCNxxDlDLkMIrl/w2ry3p9KBk3APGiEZLkKE6m5ObRtOSgLj6LViublYDcRQjy ScfWTfU4UzonEowSxM+xegUL+OPLd9UyhAoIsclrvZP2eUfh2ZEQt6SIT0y1IJiCI4eo mDyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="NpNmAMb/"; dkim=pass header.i=@linaro.org header.s=google header.b=kiu8hprP; spf=pass (google.com: domain of libc-alpha-return-99888-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-99888-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w2si2628302pgp.546.2019.02.08.10.40.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Feb 2019 10:40:24 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-99888-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="NpNmAMb/"; dkim=pass header.i=@linaro.org header.s=google header.b=kiu8hprP; spf=pass (google.com: domain of libc-alpha-return-99888-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-99888-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=koIDucLUJr0nxl6Z65RvR4Dnvq3FlqL usEOP7h68YD+qghKf6NA557/tjqxCw7FjgZoYeXS6P6TPLAOSMbP3LWgs0E3ZUTW dK7IhlImOBeoBI+rbjqPfYfMucF0PquUAqF9UqQo9Jqu4zo5uGzpLmhyHhL9WfQC R+kbOvmpysFo= 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:subject:date:message-id:in-reply-to :references; s=default; bh=C478uP4514uP2LAR0o2jyY/+cIg=; b=NpNmA Mb/1RHf0XbdiOtrWMNfTrWx6RL1GAsjmNl1OAPpkDYSMXdoGZy5tXVcSpoZEjmRn v1pZotSHAg/jjLndkqTbfH4fDQItpYPK83xkYtG8MV5E2eZs3mrWiJH2losw7akn vl4bp1vRiBMWASI2YNJ2rzqbI+yEhDM1X1IGVE= Received: (qmail 77547 invoked by alias); 8 Feb 2019 18:39: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 77415 invoked by uid 89); 8 Feb 2019 18:39:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Transfer, selfcontained, self-contained X-HELO: mail-qt1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Uw1w0TslApD4D90ZXkCqPciwF5rsC+h8yrGd9kiS6Wo=; b=kiu8hprPSx/Uq19pFV48bOMr/JMliIfznFB1sjLG3b1JG3jTvjvZ7Z9BhNv6kBzmA7 Zz15SpNzu2RojbPvsVBd5n0Ztl1Z4zgeXtJweZwbJ8MOTdcmTF6srtcoyJ4oIdJhUGVP 7bQrajpwtMtNdeXEQCCiAbiU0jIntxZkRYlnQmiGOPqqf8t8GV7i9SktLccjdoN5Gsyj HSPL1zJEYHIJb//Yp1wu+yTlN9Le5jqOtCTO1rIO3a8gtHuye6kIl9s0Aug/eyO5+nfy VbBlsERSPvQpm8JGxH4fIwnkCQbpI0F1G/arZgv8QNJHLPs2UPDpr8TYLt6xzEjj2YDD 8fOA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 5/6] Refactor hp-timing rtld usage Date: Fri, 8 Feb 2019 16:39:09 -0200 Message-Id: <20190208183910.30799-5-adhemerval.zanella@linaro.org> In-Reply-To: <20190208183910.30799-1-adhemerval.zanella@linaro.org> References: <20190208183910.30799-1-adhemerval.zanella@linaro.org> This patch refactor how hp-timing is used on loader code for statistics report. The HP_TIMING_AVAIL and HP_SMALL_TIMING_AVAIL are removed and HP_TIMING_INLINE is used instead to check for hp-timing avaliability. For alpha, which only defines HP_SMALL_TIMING_AVAIL, the HP_TIMING_INLINE is set iff for IS_IN(rtld). Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also checked the builds for all afected ABIs. * benchtests/bench-timing.h: Replace HP_TIMING_AVAIL with HP_TIMING_INLINE. * nptl/descr.h: Likewise. * elf/rtld.c (RLTD_TIMING_DECLARE, RTLD_TIMING_NOW, RTLD_TIMING_DIFF, RTLD_TIMING_ACCUM_NT, RTLD_TIMING_SET): Define. (dl_start_final_info, _dl_start_final, dl_main, print_statistics): Abstract hp-timing usage with RTLD_* macros. * sysdeps/alpha/hp-timing.h (HP_TIMING_INLINE): Define iff IS_IN(rtld). (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Remove. * sysdeps/generic/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL, HP_TIMING_NONAVAIL): Likewise. * sysdeps/ia64/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Likewise. * sysdeps/powerpc/powerpc32/power4/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Likewise. * sysdeps/powerpc/powerpc64/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Likewise. * sysdeps/sparc/sparc32/sparcv9/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Likewise. * sysdeps/sparc/sparc64/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Likewise. * sysdeps/x86/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Likewise. * sysdeps/generic/hp-timing-common.h: Update comment with HP_TIMING_AVAIL removal. --- benchtests/bench-timing.h | 2 +- elf/rtld.c | 231 +++++++++---------- nptl/descr.h | 2 +- sysdeps/alpha/hp-timing.h | 18 +- sysdeps/generic/hp-timing-common.h | 2 - sysdeps/generic/hp-timing.h | 5 - sysdeps/ia64/hp-timing.h | 4 - sysdeps/powerpc/powerpc32/power4/hp-timing.h | 4 - sysdeps/powerpc/powerpc64/hp-timing.h | 4 - sysdeps/sparc/sparc32/sparcv9/hp-timing.h | 2 - sysdeps/sparc/sparc64/hp-timing.h | 2 - sysdeps/x86/hp-timing.h | 4 - 12 files changed, 117 insertions(+), 163 deletions(-) -- 2.17.1 diff --git a/benchtests/bench-timing.h b/benchtests/bench-timing.h index 41b7324527..93fe379f99 100644 --- a/benchtests/bench-timing.h +++ b/benchtests/bench-timing.h @@ -21,7 +21,7 @@ #include #include -#if HP_TIMING_AVAIL && !defined USE_CLOCK_GETTIME +#if HP_TIMING_INLINE && !defined USE_CLOCK_GETTIME # define GL(x) _##x # define GLRO(x) _##x typedef hp_timing_t timing_t; diff --git a/elf/rtld.c b/elf/rtld.c index 34c9016da1..d4089de735 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -46,6 +46,21 @@ #include +#if HP_TIMING_INLINE +# define RLTD_TIMING_DECLARE(var, classifier,...) \ + classifier hp_timing_t var __VA_ARGS__ +# define RTLD_TIMING_NOW(var) HP_TIMING_NOW(var) +# define RTLD_TIMING_DIFF(diff, start, end) HP_TIMING_DIFF(diff, start, end) +# define RTLD_TIMING_ACCUM_NT(sum, diff) HP_TIMING_ACCUM_NT(sum, diff) +# define RTLD_TIMING_SET(var, value) (var) = (value) +#else +# define RLTD_TIMING_DECLARE(var, classifier...) +# define RTLD_TIMING_NOW(var) +# define RTLD_TIMING_DIFF(diff, start, end) +# define RTLD_TIMING_ACCUM_NT(sum, diff) +# define RTLD_TIMING_SET(var, value) +#endif + /* Avoid PLT use for our local calls at startup. */ extern __typeof (__mempcpy) __mempcpy attribute_hidden; @@ -303,11 +318,9 @@ static struct libname_list _dl_rtld_libname; static struct libname_list _dl_rtld_libname2; /* Variable for statistics. */ -#ifndef HP_TIMING_NONAVAIL -static hp_timing_t relocate_time; -static hp_timing_t load_time attribute_relro; -static hp_timing_t start_time attribute_relro; -#endif +RLTD_TIMING_DECLARE (relocate_time, static); +RLTD_TIMING_DECLARE (load_time, static, attribute_relro); +RLTD_TIMING_DECLARE (start_time, static, attribute_relro); /* Additional definitions needed by TLS initialization. */ #ifdef TLS_INIT_HELPER @@ -335,9 +348,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 - hp_timing_t start_time; -#endif + RLTD_TIMING_DECLARE (start_time,); }; static ElfW(Addr) _dl_start_final (void *arg, struct dl_start_final_info *info); @@ -371,16 +382,10 @@ _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; + /* If it hasn't happen yet record the startup time. */ +#if !defined DONT_USE_BOOTSTRAP_MAP + RTLD_TIMING_SET (start_time, info->start_time); #endif - } /* Transfer data about ourselves to the permanent link_map structure. */ #ifndef DONT_USE_BOOTSTRAP_MAP @@ -412,23 +417,16 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) entry point on the same stack we entered on. */ start_addr = _dl_sysdep_start (arg, &dl_main); -#ifndef HP_TIMING_NONAVAIL - hp_timing_t rtld_total_time; - if (HP_SMALL_TIMING_AVAIL) - { - hp_timing_t end_time; + RLTD_TIMING_DECLARE (rtld_total_time,); + RLTD_TIMING_DECLARE (end_time,); - /* Get the current time. */ - HP_TIMING_NOW (end_time); + RTLD_TIMING_NOW (end_time); - /* Compute the difference. */ - HP_TIMING_DIFF (rtld_total_time, start_time, end_time); - } -#endif + RTLD_TIMING_DIFF (rtld_total_time, start_time, end_time); if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_STATISTICS)) { -#ifndef HP_TIMING_NONAVAIL +#if HP_TIMING_INLINE print_statistics (&rtld_total_time); #else print_statistics (NULL); @@ -457,11 +455,10 @@ _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 - HP_TIMING_NOW (start_time); + RTLD_TIMING_NOW (start_time); #else - HP_TIMING_NOW (info.start_time); + RTLD_TIMING_NOW (info.start_time); #endif /* Partly clean the `bootstrap_map' structure up. Don't use @@ -879,11 +876,9 @@ dl_main (const ElfW(Phdr) *phdr, unsigned int i; bool prelinked = false; bool rtld_is_main = false; -#ifndef HP_TIMING_NONAVAIL - hp_timing_t start; - hp_timing_t stop; - hp_timing_t diff; -#endif + RLTD_TIMING_DECLARE (start,); + RLTD_TIMING_DECLARE (stop,); + RLTD_TIMING_DECLARE (diff,); void *tcbp = NULL; GL(dl_init_static_tls) = &_dl_nothread_init_static_tls; @@ -1059,12 +1054,12 @@ of this helper program; chances are you did not intend to run this program.\n\ } else { - HP_TIMING_NOW (start); + RTLD_TIMING_NOW (start); _dl_map_object (NULL, rtld_progname, lt_executable, 0, __RTLD_OPENEXEC, LM_ID_BASE); - HP_TIMING_NOW (stop); + RTLD_TIMING_NOW (stop); - HP_TIMING_DIFF (load_time, start, stop); + RTLD_TIMING_DIFF (load_time, start, stop); } /* Now the map for the main executable is available. */ @@ -1628,20 +1623,20 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (__glibc_unlikely (preloadlist != NULL)) { - HP_TIMING_NOW (start); + RTLD_TIMING_NOW (start); npreloads += handle_preload_list (preloadlist, main_map, "LD_PRELOAD"); - HP_TIMING_NOW (stop); - HP_TIMING_DIFF (diff, start, stop); - HP_TIMING_ACCUM_NT (load_time, diff); + RTLD_TIMING_NOW (stop); + RTLD_TIMING_DIFF (diff, start, stop); + RTLD_TIMING_ACCUM_NT (load_time, diff); } if (__glibc_unlikely (preloadarg != NULL)) { - HP_TIMING_NOW (start); + RTLD_TIMING_NOW (start); npreloads += handle_preload_list (preloadarg, main_map, "--preload"); - HP_TIMING_NOW (stop); - HP_TIMING_DIFF (diff, start, stop); - HP_TIMING_ACCUM_NT (load_time, diff); + RTLD_TIMING_NOW (stop); + RTLD_TIMING_DIFF (diff, start, stop); + RTLD_TIMING_ACCUM_NT (load_time, diff); } /* There usually is no ld.so.preload file, it should only be used @@ -1701,7 +1696,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", file[file_size - 1] = '\0'; } - HP_TIMING_NOW (start); + RTLD_TIMING_NOW (start); if (file != problem) { @@ -1719,9 +1714,9 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", npreloads += do_preload (p, main_map, preload_file); } - HP_TIMING_NOW (stop); - HP_TIMING_DIFF (diff, start, stop); - HP_TIMING_ACCUM_NT (load_time, diff); + RTLD_TIMING_NOW (stop); + RTLD_TIMING_DIFF (diff, start, stop); + RTLD_TIMING_ACCUM_NT (load_time, diff); /* We don't need the file anymore. */ __munmap (file, file_size); @@ -1745,11 +1740,11 @@ 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. */ - HP_TIMING_NOW (start); + RTLD_TIMING_NOW (start); _dl_map_object_deps (main_map, preloads, npreloads, mode == trace, 0); - HP_TIMING_NOW (stop); - HP_TIMING_DIFF (diff, start, stop); - HP_TIMING_ACCUM_NT (load_time, diff); + RTLD_TIMING_NOW (stop); + RTLD_TIMING_DIFF (diff, start, stop); + RTLD_TIMING_ACCUM_NT (load_time, diff); /* Mark all objects as being in the global scope. */ for (i = main_map->l_searchlist.r_nlist; i > 0; ) @@ -2142,12 +2137,10 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", if (main_map->l_info [ADDRIDX (DT_GNU_CONFLICT)] != NULL) { ElfW(Rela) *conflict, *conflictend; -#ifndef HP_TIMING_NONAVAIL - hp_timing_t start; - hp_timing_t stop; -#endif + RLTD_TIMING_DECLARE (start, ); + RLTD_TIMING_DECLARE (stop, ); - HP_TIMING_NOW (start); + RTLD_TIMING_NOW (start); 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; @@ -2155,8 +2148,8 @@ 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); - HP_TIMING_NOW (stop); - HP_TIMING_DIFF (relocate_time, start, stop); + RTLD_TIMING_NOW (stop); + RTLD_TIMING_DIFF (relocate_time, start, stop); } @@ -2184,15 +2177,13 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", know that because it is self-contained). */ int consider_profiling = GLRO(dl_profile) != NULL; -#ifndef HP_TIMING_NONAVAIL - hp_timing_t start; - hp_timing_t stop; -#endif + RLTD_TIMING_DECLARE (start, ); + RLTD_TIMING_DECLARE (stop, ); /* If we are profiling we also must do lazy reloaction. */ GLRO(dl_lazy) |= consider_profiling; - HP_TIMING_NOW (start); + RTLD_TIMING_NOW (start); unsigned i = main_map->l_searchlist.r_nlist; while (i-- > 0) { @@ -2219,9 +2210,9 @@ 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); } - HP_TIMING_NOW (stop); + RTLD_TIMING_NOW (stop); - HP_TIMING_DIFF (relocate_time, start, stop); + RTLD_TIMING_DIFF (relocate_time, start, stop); /* Now enable profiling if needed. Like the previous call, this has to go here because the calls it makes should use the @@ -2264,19 +2255,17 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", re-relocation, we might call a user-supplied function (e.g. calloc from _dl_relocate_object) that uses TLS data. */ -#ifndef HP_TIMING_NONAVAIL - hp_timing_t start; - hp_timing_t stop; - hp_timing_t add; -#endif + RLTD_TIMING_DECLARE (start,); + RLTD_TIMING_DECLARE (stop,); + RLTD_TIMING_DECLARE (add,); - HP_TIMING_NOW (start); + RTLD_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); - HP_TIMING_NOW (stop); - HP_TIMING_DIFF (add, start, stop); - HP_TIMING_ACCUM_NT (relocate_time, add); + RTLD_TIMING_NOW (stop); + RTLD_TIMING_DIFF (add, start, stop); + RTLD_TIMING_ACCUM_NT (relocate_time, add); } /* Do any necessary cleanups for the startup OS interface code. @@ -2714,38 +2703,35 @@ static void __attribute ((noinline)) print_statistics (hp_timing_t *rtld_total_timep) { -#ifndef HP_TIMING_NONAVAIL +#if HP_TIMING_INLINE char buf[200]; + char pbuf[30]; char *cp; 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" + " total startup time in dynamic loader: %s\n", buf); + + /* Print relocation statistics. */ + HP_TIMING_PRINT (buf, sizeof (buf), relocate_time); + cp = _itoa ((1000ULL * relocate_time) / *rtld_total_timep, + pbuf + sizeof (pbuf), 10, 0); + wp = pbuf; + switch (pbuf + sizeof (pbuf) - cp) { - HP_TIMING_PRINT (buf, sizeof (buf), *rtld_total_timep); - _dl_debug_printf ("\nruntime linker statistics:\n" - " total startup time in dynamic loader: %s\n", buf); - - /* Print relocation statistics. */ - char pbuf[30]; - HP_TIMING_PRINT (buf, sizeof (buf), relocate_time); - cp = _itoa ((1000ULL * relocate_time) / *rtld_total_timep, - pbuf + sizeof (pbuf), 10, 0); - wp = pbuf; - switch (pbuf + sizeof (pbuf) - cp) - { - case 3: - *wp++ = *cp++; - case 2: - *wp++ = *cp++; - case 1: - *wp++ = '.'; - *wp++ = *cp++; - } - *wp = '\0'; - _dl_debug_printf ("\ - time needed for relocation: %s (%s%%)\n", buf, pbuf); + case 3: + *wp++ = *cp++; + case 2: + *wp++ = *cp++; + case 1: + *wp++ = '.'; + *wp++ = *cp++; } + *wp = '\0'; + _dl_debug_printf ("\ + time needed for relocation: %s (%s%%)\n", buf, pbuf); #endif unsigned long int num_relative_relocations = 0; @@ -2786,29 +2772,24 @@ print_statistics (hp_timing_t *rtld_total_timep) GL(dl_num_cache_relocations), num_relative_relocations); -#ifndef HP_TIMING_NONAVAIL +#if HP_TIMING_INLINE /* Time spend while loading the object and the dependencies. */ - if (HP_SMALL_TIMING_AVAIL) + HP_TIMING_PRINT (buf, sizeof (buf), load_time); + cp = _itoa ((1000ULL * load_time) / *rtld_total_timep, + pbuf + sizeof (pbuf), 10, 0); + wp = pbuf; + switch (pbuf + sizeof (pbuf) - cp) { - char pbuf[30]; - HP_TIMING_PRINT (buf, sizeof (buf), load_time); - cp = _itoa ((1000ULL * load_time) / *rtld_total_timep, - pbuf + sizeof (pbuf), 10, 0); - wp = pbuf; - switch (pbuf + sizeof (pbuf) - cp) - { - case 3: - *wp++ = *cp++; - case 2: - *wp++ = *cp++; - case 1: - *wp++ = '.'; - *wp++ = *cp++; - } - *wp = '\0'; - _dl_debug_printf ("\ - time needed to load objects: %s (%s%%)\n", - buf, pbuf); + case 3: + *wp++ = *cp++; + case 2: + *wp++ = *cp++; + case 1: + *wp++ = '.'; + *wp++ = *cp++; } + *wp = '\0'; + _dl_debug_printf ("\ + time needed to load objects: %s (%s%%)\n", buf, pbuf); #endif } diff --git a/nptl/descr.h b/nptl/descr.h index 6fd2cb1c35..b62c4672c1 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 hp_timing_t cpuclock_offset_ununsed; #endif diff --git a/sysdeps/alpha/hp-timing.h b/sysdeps/alpha/hp-timing.h index 481132663c..08d8d6627c 100644 --- a/sysdeps/alpha/hp-timing.h +++ b/sysdeps/alpha/hp-timing.h @@ -17,16 +17,13 @@ License along with the GNU C Library. If not, see . */ -#ifndef _HP_TIMING_H -#define _HP_TIMING_H 1 +#ifndef _HP_TIMING_ALPHA_H +#define _HP_TIMING_ALPHA_H 1 +#if IS_IN(rtld) /* 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) +# define HP_TIMING_INLINE (1) /* We use 32 bit values for the times. */ typedef unsigned int hp_timing_t; @@ -34,13 +31,16 @@ typedef unsigned int hp_timing_t; /* The "rpcc" instruction returns a 32-bit counting half and a 32-bit "virtual cycle counter displacement". Subtracting the two gives us a virtual cycle count. */ -#define HP_TIMING_NOW(VAR) \ +# define HP_TIMING_NOW(VAR) \ do { \ unsigned long int x_; \ asm volatile ("rpcc %0" : "=r"(x_)); \ (VAR) = (int) (x_) - (int) (x_ >> 32); \ } while (0) +# include -#include +#else +# include +#endif /* IS_IN(rtld) */ #endif /* hp-timing.h */ diff --git a/sysdeps/generic/hp-timing-common.h b/sysdeps/generic/hp-timing-common.h index 0ffb853444..f7a0147a4f 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 fb2a6036fc..278998d2c2 100644 --- a/sysdeps/generic/hp-timing.h +++ b/sysdeps/generic/hp-timing.h @@ -25,8 +25,6 @@ the system call might be too high. */ /* 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) @@ -34,7 +32,4 @@ typedef int hp_timing_t; #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 - #endif /* hp-timing.h */ diff --git a/sysdeps/ia64/hp-timing.h b/sysdeps/ia64/hp-timing.h index 17ef023a11..2ca248a530 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 0d77aa0992..ed2ca9bc7a 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 fb9ac1ce2a..01678cd634 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 6a4ab08679..3270c5b40a 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 db95c02a8d..0f02b2a98f 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 9b6a998bcd..ccb9f9250a 100644 --- a/sysdeps/x86/hp-timing.h +++ b/sysdeps/x86/hp-timing.h @@ -22,10 +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)