Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S267248AbUIFHon (ORCPT ); Mon, 6 Sep 2004 03:44:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S267555AbUIFHon (ORCPT ); Mon, 6 Sep 2004 03:44:43 -0400 Received: from mustang.oldcity.dca.net ([216.158.38.3]:58833 "HELO mustang.oldcity.dca.net") by vger.kernel.org with SMTP id S267248AbUIFHoC (ORCPT ); Mon, 6 Sep 2004 03:44:02 -0400 Subject: Re: [patch] voluntary-preempt-2.6.9-rc1-bk12-R5 From: Lee Revell To: Ingo Molnar Cc: Florian Schmidt , "K.R. Foley" , linux-kernel , felipe_alfaro@linuxmail.org In-Reply-To: <20040906063040.GA11541@elte.hu> References: <20040903120957.00665413@mango.fruits.de> <20040904195141.GA6208@elte.hu> <20040905140249.GA23502@elte.hu> <1094408203.4445.5.camel@krustophenia.net> <20040905191227.GA29797@elte.hu> <1094418192.4445.58.camel@krustophenia.net> <20040906063040.GA11541@elte.hu> Content-Type: text/plain Message-Id: <1094456653.29921.45.camel@krustophenia.net> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 06 Sep 2004 03:44:16 -0400 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7419 Lines: 363 On Mon, 2004-09-06 at 02:30, Ingo Molnar wrote: > * Lee Revell wrote: > > > http://krustophenia.net/testresults.php?dataset=2.6.9-rc1-R0#/var/www/2.6.9-rc1-R0/foo.hist > > > > I find the two smaller spikes to either side of the central spike > > really odd. These showed up in my jackd tests too, I had attributed > > them to some measurement artifact, but they seem real. Maybe a > > rounding bug, or some kind of weird cache effect? > > interesting - the histograms are pretty symmetric around the center. > E.g. the exponential foo.hist2 diagram is way too symmetric around 50 > usecs! What precisely is being measured? > Here's the program. It does mlockall(), acquires realtime scheduling, then sets up a 2048 Hz stream of interupts from the RTC and measures the delay. It's quite possible there's a bug, the amlat program did not seem to work, something must have changed with the RTC from 2.4 to 2.6. /* * This was originally written by Mark Hahn. Obtained from * http://brain.mcmaster.ca/~hahn/realfeel.c */ #include #include #include #include #include #include #include #include #include #include #include #include #include #define _GNU_SOURCE #include /* global vars */ int stopit; /* set to stop measuring */ #define SAMPLES 10000 int histogram[SAMPLES]; /* Milliseconds */ #define PAGE_SIZE 4096UL /* virtual memory page size */ #define OSCR_HZ 3686400 /* frequency of clock ticks */ #define OSCR 0x90000010 /* physical address of OSCR register */ unsigned long *oscr; /* ptr to OSCR */ void setup_clock (void) { int fd; void *map_base; off_t target; off_t page; #ifndef ARCHARM return; #endif fd = open ("/dev/mem", O_RDWR | O_SYNC); if (-1 == fd) { perror ("open of /dev/mem failed\n"); exit (1); } /* Map one page */ target = OSCR; page = target & ~(PAGE_SIZE - 1); map_base = mmap (0, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, page); if (MAP_FAILED == map_base) { perror ("mmap failed"); (void) close (fd); exit (2); } oscr = map_base + (target - page); /* This does not end the mmap, * the mmap will go away when the process dies */ close (fd); } double second() { struct timeval tv; gettimeofday(&tv,0); return tv.tv_sec + 1e-6 * tv.tv_usec; } typedef unsigned long long u64; u64 rdtsc() { u64 tsc; #ifdef ARCHARM tsc = *oscr; #else __asm__ __volatile__("rdtsc" : "=A" (tsc)); #endif return tsc; } void selectsleep(unsigned us) { struct timeval tv; tv.tv_sec = 0; tv.tv_usec = us; select(0,0,0,0,&tv); } double secondsPerTick, ticksPerSecond; void calibrate() { double sumx = 0; double sumy = 0; double sumxx = 0; double sumxy = 0; double slope; // least squares linear regression of ticks onto real time // as returned by gettimeofday. const unsigned n = 30; unsigned i; for (i=0; i 2048) { fprintf(stderr, "max allowable interrupt frequency is 2048 Hz\n"); hz = 2048; } else if (hz <= 0) { fprintf(stderr, "zero or negative frequency doesn't make sense!\n"); hz = 1; } } } if (argv[optind] == NULL) { fprintf(stderr, "histogram file name required\n"); usage(); exit (2); } return argv[optind]; } #define msec(f) (1e3 * (f)) #define usec(f) (1e6 * (f)) int main(int argc, char *argv[]) { int fd; double ideal; u64 last; double max_delay = 0; char *histfile = parse_options(argc, argv); if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0) { perror("mlockall"); exit(1); } setup_clock (); set_realtime_priority(); calibrate(); printf("secondsPerTick=%f\n", secondsPerTick); printf("ticksPerSecond=%f\n", ticksPerSecond); fd = open("/dev/rtc",O_RDONLY); if (fd == -1) fatal("failed to open /dev/rtc"); ideal = 1.0 / hz; if (ioctl(fd, RTC_IRQP_SET, hz) == -1) fatal("ioctl(RTC_IRQP_SET) failed"); printf("Interrupt frequency: %d Hz\n",hz); if (bounded) { printf("running for %d samples\n", ncycles); } /* Enable periodic interrupts */ if (ioctl(fd, RTC_PIE_ON, 0) == -1) fatal("ioctl(RTC_PIE_ON) failed"); signal(SIGINT, signalled); last = rdtsc(); while (!stopit) { u64 now; double delay; int data; int ms; if (read(fd, &data, sizeof(data)) == -1) fatal("blocking read failed"); now = rdtsc(); delay = secondsPerTick * (now - last); if (delay > max_delay) { max_delay = delay; // printf("%.3f msec\n", -(1e3 * (ideal - delay))); } ms = (-(ideal - delay) + 1.0/20000.0) * 10000000; if (ms < 0) ms = 0; /* hmmm */ if (ms >= SAMPLES) ms = SAMPLES; histogram[ms]++; if (bounded) { if (++current >= ncycles) { printf ("finished collecting %d samples\n", ncycles); printf ("maximum cycle time: %.3fms\n", -msec(ideal - max_delay)); break; } if ((current % 10000) == 0) { printf("%d cycles (max cycle time so far: %.3fus)\n", current, -(usec(ideal - max_delay))); } } last = now; } if (ioctl(fd, RTC_PIE_OFF, 0) == -1) fatal("ioctl(RTC_PIE_OFF) failed"); hist(histfile); return 0; } > Ingo > - 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/