Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758445AbWK0RXU (ORCPT ); Mon, 27 Nov 2006 12:23:20 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758455AbWK0RXU (ORCPT ); Mon, 27 Nov 2006 12:23:20 -0500 Received: from wx-out-0506.google.com ([66.249.82.226]:16486 "EHLO wx-out-0506.google.com") by vger.kernel.org with ESMTP id S1758443AbWK0RXT (ORCPT ); Mon, 27 Nov 2006 12:23:19 -0500 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=pfg79C39wUqOe0V+aloBh5Z7NebzEqCMp2wSkdq0o5eey45M88SJ5hfjy4IeYQaOEP8SGNtlbOto1Gb95UKRkp8zdDbGdXJcRIwB2IF/jSU4RLOhDX/rlnXeQJsKm8hfmkPvOH5t4nJP22GY1nDZSuxos0OPLb7ALLXawWh71lU= Message-ID: Date: Mon, 27 Nov 2006 10:23:17 -0700 From: "Robert Crocombe" To: linux-kernel Subject: Re: [patch] x86: unify/rewrite SMP TSC sync code MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_16000_17110430.1164648197624" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6809 Lines: 121 ------=_Part_16000_17110430.1164648197624 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline The difference that Wink reports is tiny compared to that measured on my Opteron machines: dual (2.6.17): rcrocomb@netfires-aptest:cyclecounter_test$ ./rdtsc-pref 1000000 rdtsc: average ticks= 10 gtod: average ticks=4296 gtod_us: average ticks=4328 quad (2.6.16-rt29): rcrocomb@spanky:wink_saville_test$ ./rdtsc-pref 1000000 rdtsc: average ticks= 10 gtod: average ticks=5688 gtod_us: average ticks=5711 I have my own little test that I'll attach, but it gives a similar result. Here are the results from the 2x box: rcrocomb@netfires-aptest:cyclecounter_test$ ./timing Using the cycle counter Calibrated timer as 2593081969.758825 Hz 4194304 iterations in 0.016 seconds is 0.004 useconds per iteration. rcrocomb@netfires-aptest:cyclecounter_test$ ./timing_gettimeofday Using gettimeofday 4194304 iterations in 6.793 seconds is 1.620 useconds per iteration. I have used the pthread affinity and/or cpuset, etc. mechanisms to try and inject some reliability into the measurement. Using gtod() can amount to a substantial disturbance of the thing to be measured. Using rdtsc, things seem reliable so far, and we have an FPGA (accessed through the PCI bus) that has been programmed to give access to an 8MHz clock and we do some checks against that. -- Robert Crocombe rcrocomb@gmail.com ------=_Part_16000_17110430.1164648197624 Content-Type: text/x-c++src; name=timing.cpp; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 X-Attachment-Id: f_ev15agbj Content-Disposition: attachment; filename="timing.cpp" I2luY2x1ZGUgPHN0ZGlvLmg+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIHBy aW50ZigpCiNpbmNsdWRlIDxzdGRpbnQuaD4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAvLyB1aW50NjRfdAojaW5jbHVkZSA8c3RkbGliLmg+ICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgLy8gZHJhbmQ0OCgpCiNpbmNsdWRlIDxzeXMvc2VsZWN0Lmg+ICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAvLyBzZWxlY3QoKQojaW5jbHVkZSA8c3lzL3RpbWUuaD4gICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgLy8gZ2V0dGltZW9mZGF5CiNpbmNsdWRlIDx0aW1lLmg+ CiNpbmNsdWRlIDxhc20teDg2XzY0L21zci5oPiAgICAgICAgICAgICAgICAgICAgICAgICAvLyBy ZHRzY2xsKCkKCgovLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8v Ly8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLy8vLwovLyBHbG9iYWxzCi8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wOyBpIDwg SVRFUkFUSU9OUzsgKytpKQogICAgewogICAgICAgIGRvdWJsZSB0aGVfdGltZTsKICAgICAgICB0 aGVfdGltZSA9IGdldF90aW1lKCk7CiAgICB9CiAgICBkb3VibGUgdGltZV9lbmQgPSBnaW1tZV90 aW1lb2ZkYXkoKTsKI2Vsc2UgICAvLyB1c2luZyBnZXR0aW1lb2ZkYXkoKQogICAgcHJpbnRmKCJV c2luZyBnZXR0aW1lb2ZkYXlcbiIpOwogICAgZG91YmxlIHRpbWVfc3RhcnQgPSBnaW1tZV90aW1l b2ZkYXkoKTsKICAgIGZvciAodW5zaWduZWQgaW50IGkgPSAwOyBpIDwgSVRFUkFUSU9OUzsgKytp KQogICAgewogICAgICAgIGRvdWJsZSB0aGVfdGltZTsKICAgICAgICB0aGVfdGltZSA9IGdpbW1l X3RpbWVvZmRheSgpOwogICAgfQogICAgZG91YmxlIHRpbWVfZW5kID0gZ2ltbWVfdGltZW9mZGF5 KCk7CiNlbmRpZgoKICAgIGRvdWJsZSBkaWZmID0gdGltZV9lbmQgLSB0aW1lX3N0YXJ0OwoKICAg IGRvdWJsZSB1c2Vjb25kcyA9IChkaWZmIC8gSVRFUkFUSU9OUykgKiAxZTY7CgogICAgcHJpbnRm KCIldSBpdGVyYXRpb25zIGluICUuM2Ygc2Vjb25kcyBpcyAlLjNmIHVzZWNvbmRzIHBlciBpdGVy YXRpb24uXG4iLAogICAgICAgICAgSVRFUkFUSU9OUywgZGlmZiwgdXNlY29uZHMpOwoKICAgIHBy aW50ZigiRG9uZVxuIik7CiAgICByZXR1cm4gMDsKfQo= ------=_Part_16000_17110430.1164648197624-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/