From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4399 invoked by alias); 9 Oct 2006 18:56:18 -0000 Received: (qmail 4390 invoked by uid 22791); 9 Oct 2006 18:56:18 -0000 X-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from e35.co.us.ibm.com (HELO e35.co.us.ibm.com) (32.97.110.153) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 09 Oct 2006 18:56:15 +0000 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e35.co.us.ibm.com (8.13.8/8.12.11) with ESMTP id k99IuD2F022019 for ; Mon, 9 Oct 2006 14:56:13 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.6/8.13.6/NCO v8.1.1) with ESMTP id k99IuDN3360146 for ; Mon, 9 Oct 2006 12:56:13 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k99IuDq4011170 for ; Mon, 9 Oct 2006 12:56:13 -0600 Received: from [9.67.125.227] (wecm-9-67-125-227.wecm.ibm.com [9.67.125.227]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k99IuCoN011120 for ; Mon, 9 Oct 2006 12:56:12 -0600 Message-ID: <452AA406.1030109@us.ibm.com> Date: Mon, 09 Oct 2006 18:56:00 -0000 From: David Wilder User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: systemtap@sources.redhat.com Subject: S390 _stp_gettimeofday_ns() change Content-Type: multipart/mixed; boundary="------------010603080002060505000003" X-Virus-Checked: Checked by ClamAV on sourceware.org X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2006-q4/txt/msg00050.txt.bz2 This is a multi-part message in MIME format. --------------010603080002060505000003 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 718 While investigating a possible compiler bug on the s390 affecting __stp_estimate_cpufreq(), I came to the conclusion that this function made little sense on the s390. Both get_cycles() and udelay() use the TOD clock. On the s390 the TOD is always at a known frequency on all models. The following patch to _stp_gettimeofday_ns() simply converts get_cycles()'s return value into nanoseconds and it has the side effect of avoiding the gcc bug :) The per-cpu timer values are also not needed on the s390 as all cpus use the same TOD clock. However, I did not remove this code for ease of maintenance. -- David Wilder IBM Linux Technology Center Beaverton, Oregon, USA dwilder@us.ibm.com (503)578-3789 --------------010603080002060505000003 Content-Type: text/x-patch; name="s390_gtod.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="s390_gtod.patch" Content-length: 1263 diff --git a/src/runtime/time.c b/src/runtime/time.c index 058cfe4..fd9c26d 100644 --- a/src/runtime/time.c +++ b/src/runtime/time.c @@ -55,6 +55,15 @@ void *stp_time = NULL; * * FIXME: This not very accurate on Xen kernels! */ +#if defined (__s390__) || defined (__s390x__) +static unsigned int +__stp_estimate_cpufreq(void) +{ + // We don't need to find the cpu freq on s390 as the + // TOD clock is always a fix freq. (see: POO pg 4-36.) + return 0; +} +#else /* __s390x__ || __s390x__ */ static unsigned int __stp_estimate_cpufreq(void) { @@ -66,6 +75,7 @@ __stp_estimate_cpufreq(void) end = get_cycles(); barrier(); return (beg - 2*mid + end); } +#endif static void __stp_time_timer_callback(unsigned long val) @@ -230,10 +240,18 @@ _stp_gettimeofday_ns(void) preempt_enable(); +#if defined (__s390__) || defined (__s390x__) + // The TOD clock on the s390 (read by get_cycles() ) + // is converted to a nano-second value using the following: + // (get_cycles() * 125) >> 7; + + delta = (delta * 125) >> 7; + +#else /* __s390__ || __s390x__ */ // Verify units: // (D cycles) * (1E6 ns/ms) / (F cycles/ms [kHz]) = ns delta *= NSEC_PER_MSEC; do_div(delta, freq); +#endif return base + delta; } - --------------010603080002060505000003--