From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16268 invoked by alias); 17 Mar 2004 12:52:00 -0000 Mailing-List: contact libc-hacker-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sources.redhat.com Received: (qmail 15812 invoked from network); 17 Mar 2004 12:51:57 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.15.26) by sources.redhat.com with SMTP; 17 Mar 2004 12:51:57 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id i2HAgSGc000570; Wed, 17 Mar 2004 11:42:28 +0100 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id i2HAgS3g000566; Wed, 17 Mar 2004 11:42:28 +0100 Date: Wed, 17 Mar 2004 12:52:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix LD_DEBUG=statistics on x86-64 Message-ID: <20040317104228.GB6393@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2004-03/txt/msg00089.txt.bz2 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 * 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