All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Revell <rlrevell@joe-job.com>
To: Andi Kleen <ak@suse.de>
Cc: "Brown, Len" <len.brown@intel.com>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@osdl.org>,
	acpi-devel@lists.sourceforge.net, nando@ccrma.Stanford.EDU,
	linux-kernel@vger.kernel.org, paulmck@us.ibm.com, kr@cybsft.com,
	tglx@linutronix.de, pluto@agmk.net, john.cooper@timesys.com,
	bene@linutronix.de, dwalker@mvista.com,
	trini@kernel.crashing.org, george@mvista.com
Subject: Re: [RFC][PATCH] Runtime switching of the idle function [take 2]
Date: Tue, 29 Nov 2005 18:55:05 -0500	[thread overview]
Message-ID: <1133308505.4627.31.camel@mindpipe> (raw)
In-Reply-To: <20051129205108.GQ19515@wotan.suse.de>

On Tue, 2005-11-29 at 21:51 +0100, Andi Kleen wrote:
> On Tue, Nov 29, 2005 at 03:35:39PM -0500, Lee Revell wrote:
> > On Tue, 2005-11-29 at 20:53 +0100, Andi Kleen wrote:
> > > We're mostly addressing it - there are problems left, but
> > > overall it's looking good. The remaining problem is 
> > > an education issue of users to not use RDTSC directly, 
> > > but use gettimeofday/clock_gettime 
> > 
> > No the issue is to make gettimeofday fast enough that the people who
> > currently have to use the TSC can use it.  Right now it's 1500-3000 nsec
> > or so, Vojtech mentioned that he has a patch that could reduce that to
> 
> It's only that slow if the hardware can't do better.
> 
> And the kernel makes it only slow when using RDTSC directly
> is unsafe - so if you use it directly thinking the kernel cheats
> you for your cycles you're just shoting yourself in the own foot.
> 
> > 150-300 nsec.
> 
> If you have capable hardware it can already do much better.
> 

But on my system gettimeofday uses the TSC and it's still ~35x slower
than RDTSC:

rlrevell@mindpipe:~$ ./timetest 
rdtsc: 10000 calls in 1079 usecs
gettimeofday: 10000 calls in 36628 usecs

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

typedef unsigned long long cycles_t;

#define rdtscll(val) \
     __asm__ __volatile__("rdtsc" : "=A" (val))

static inline cycles_t get_cycles_tsc (void)
{
	unsigned long long ret;

	rdtscll(ret);
	return ret;
}

static inline cycles_t get_cycles_gtod (void)
{
       struct timeval tv;
       gettimeofday (&tv, NULL);

       return tv.tv_usec;
}

int main (void) {
	int i;
	cycles_t start_time;
	start_time= get_cycles_gtod();
	for (i = 0; i < 10000; i++) {
		get_cycles_tsc();
	}
	printf("rdtsc: %i calls in %llu usecs\n", i, get_cycles_gtod() - start_time);
	start_time = get_cycles_gtod();
	for (i = 0; i < 10000; i++) {
		get_cycles_gtod();
	}
	printf("gettimeofday: %i calls in %llu usecs\n", i, get_cycles_gtod() - start_time);
	return 0;
}

  reply	other threads:[~2005-11-29 23:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-29 19:37 [RFC][PATCH] Runtime switching of the idle function [take 2] Brown, Len
2005-11-29 19:37 ` Brown, Len
2005-11-29 19:53 ` Andi Kleen
2005-11-29 20:35   ` Lee Revell
2005-11-29 20:51     ` Andi Kleen
2005-11-29 23:55       ` Lee Revell [this message]
2005-11-30  1:06         ` Andi Kleen
2005-11-30  1:22           ` Lee Revell
2005-11-30  1:58             ` Andi Kleen
2005-11-30  2:19               ` john stultz
  -- strict thread matches above, loose matches on Subject: below --
2005-11-15  9:08 2.6.14-rt13 Ingo Molnar
2005-11-18 18:02 ` 2.6.14-rt13 Fernando Lopez-Lezcano
2005-11-18 21:54   ` 2.6.14-rt13 Lee Revell
2005-11-18 22:05     ` 2.6.14-rt13 Fernando Lopez-Lezcano
2005-11-18 22:07       ` 2.6.14-rt13 Ingo Molnar
2005-11-18 22:41         ` 2.6.14-rt13 Fernando Lopez-Lezcano
2005-11-19  2:39           ` 2.6.14-rt13 Steven Rostedt
2005-11-24 15:07             ` 2.6.14-rt13 Ingo Molnar
2005-11-25 20:56               ` [RFC][PATCH] Runtime switching to idle_poll (was: Re: 2.6.14-rt13) Steven Rostedt
2005-11-26 13:05                 ` Ingo Molnar
2005-11-29  2:48                   ` [RFC][PATCH] Runtime switching of the idle function [take 2] Steven Rostedt
2005-11-29  3:02                     ` Andrew Morton
2005-11-29  3:42                       ` Steven Rostedt
2005-11-29  4:01                         ` Andrew Morton
2005-11-29  6:44                           ` Ingo Molnar
2005-11-29  6:55                             ` Nick Piggin
2005-11-29 18:05                             ` Andi Kleen
2005-11-29 14:19                               ` Steven Rostedt
2005-11-29 14:50                                 ` Andi Kleen
2005-11-29 15:42                                   ` Steven Rostedt
2005-12-02  1:27                               ` Max Krasnyansky
2005-12-02  1:45                                 ` Andi Kleen
2005-12-03  2:17                                   ` Max Krasnyansky
2005-11-29  4:22                         ` john stultz
2005-11-29 14:22                           ` Steven Rostedt
2005-11-29 13:08                     ` Pavel Machek
2005-12-18 15:26                       ` Steven Rostedt

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=1133308505.4627.31.camel@mindpipe \
    --to=rlrevell@joe-job.com \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=bene@linutronix.de \
    --cc=dwalker@mvista.com \
    --cc=george@mvista.com \
    --cc=john.cooper@timesys.com \
    --cc=kr@cybsft.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nando@ccrma.Stanford.EDU \
    --cc=nickpiggin@yahoo.com.au \
    --cc=paulmck@us.ibm.com \
    --cc=pluto@agmk.net \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=trini@kernel.crashing.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.