public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Fix LD_DEBUG=statistics on x86-64
Date: Wed, 17 Mar 2004 12:52:00 -0000	[thread overview]
Message-ID: <20040317104228.GB6393@sunsite.ms.mff.cuni.cz> (raw)

Hi!

     17214:     runtime linker statistics:
     17214:       total startup time in dynamic loader: 12434 clock cycles
     17214:                 time needed for relocation: 280243 clock cycles (%)
     17214:                      number of relocations: 98
     17214:           number of relocations from cache: 3
     17214:             number of relative relocations: 1286
     17214:                time needed to load objects: 0 clock cycles (.0%)
certainly doesn't look correct.
The problem is that without volatile in the rdtsc asm GCC happily merges
HP_TIMING_NOW (start);
call something
HP_TIMING_NOW (stop);
so that stop == start (rdtsc done only before the call).

     17232:     runtime linker statistics:
     17232:       total startup time in dynamic loader: 733738 clock cycles
     17232:                 time needed for relocation: 278644 clock cycles (37.9%)
     17232:                      number of relocations: 83
     17232:           number of relocations from cache: 3
     17232:             number of relative relocations: 1295
     17232:                time needed to load objects: 326662 clock cycles (44.5%)

looks better.

2004-03-17  Jakub Jelinek  <jakub@redhat.com>

	* sysdeps/x86_64/hp-timing.h (HP_TIMING_NOW): Make asm volatile.

--- libc/sysdeps/x86_64/hp-timing.h.jj	2002-08-31 01:09:29.000000000 +0200
+++ libc/sysdeps/x86_64/hp-timing.h	2004-03-17 13:26:02.139127766 +0100
@@ -1,5 +1,5 @@
 /* High precision, low overhead timing functions.  x86-64 version.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -25,7 +25,8 @@
 /* The "=A" constraint used in 32-bit mode does not work in 64-bit mode.  */
 # undef HP_TIMING_NOW
 # define HP_TIMING_NOW(Var) \
-  ({ unsigned int _hi, _lo; asm ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
+  ({ unsigned int _hi, _lo; \
+     asm volatile ("rdtsc" : "=a" (_lo), "=d" (_hi)); \
      (Var) = ((unsigned long long int) _hi << 32) | _lo; })
 
 /* The funny business for 32-bit mode is not required here.  */

	Jakub

             reply	other threads:[~2004-03-17 12:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-17 12:52 Jakub Jelinek [this message]
2004-03-17 17:29 ` Ulrich Drepper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040317104228.GB6393@sunsite.ms.mff.cuni.cz \
    --to=jakub@redhat.com \
    --cc=drepper@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).