mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* How to measure i386 timer interrupt overhead
@ 2004-12-07  3:05 Chuck Ebbert
  2004-12-07 11:36 ` Jan Engelhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Chuck Ebbert @ 2004-12-07  3:05 UTC (permalink / raw)
  To: linux-kernel

If this program actually works, then the SMP timer interrupt on this
system takes 1200-1420 cycles, with 448 of 945 taking 1200-1219 cycles.
(All the normal interrupts are bound to CPU 0.)

Is this a valid test program?

$ taskset 2 ./t 6800 332490000 | sort -g | uniq -c | grep -v '^      [1-9]'
Elasped time: 945 ticks (assuming Hz = 1000)
   9731 0
     35 10
    224 1200
    204 1210
     16 1220
     14 1270
     65 1300
    131 1310
     33 1320
     14 1370
     20 1380
     22 1420

$ cat t.c
/* Measure i386 timer overhead by timing loops with TSC and
 * subtracting out the minimum time.  Rounds to granularity 10.
 * (Run this on an otherwise idle system.)
 */
#include <stdio.h>
#define HZ              1000
#define NUM_TESTS       (11000 + 1)
unsigned long long t0, t1, t2, t3;
unsigned long long sample[NUM_TESTS], min = 1000000;
unsigned int loop_iters, tsc_per_tick, i, j;

main (int argc, char **argv) {
        if (argc < 3) {
                fprintf(stderr, "Usage: %s <loop_size> <CPU Hz>\n", argv[0]);
                exit(1);
        }
        loop_iters   = atoi(argv[1]);
        tsc_per_tick = atoll(argv[2]) / HZ;
restart:
        asm volatile ("rdtsc" : "=A"(t0));
        for (i = 0; i < NUM_TESTS; i++) {
                asm volatile ("rdtsc" : "=A"(t1));
                for (j = 0; j < loop_iters; j++)
                        /* empty */;
                asm volatile ("rdtsc" : "=A"(t2));
                sample[i] = t2 - t1;
        }
        asm volatile ("rdtsc" : "=A"(t3));
        if (t3 < t0)
                goto restart;
        for (i = 1; i < NUM_TESTS; i++) { /* skip first sample */
                if (min > sample[i])
                        min = sample[i];
        }
        for (i = 1; i < NUM_TESTS; i++)
                printf("%llu\n", (sample[i] - min) / 10 * 10);
        fprintf(stderr, "Elasped time: %d ticks (assuming Hz = %d)\n",
                        (int)((t3 - t0) / tsc_per_tick), HZ);
}

--Chuck Ebbert  06-Dec-04  22:03:04

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to measure i386 timer interrupt overhead
  2004-12-07  3:05 How to measure i386 timer interrupt overhead Chuck Ebbert
@ 2004-12-07 11:36 ` Jan Engelhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Engelhardt @ 2004-12-07 11:36 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: linux-kernel

>If this program actually works, then the SMP timer interrupt on this
>system takes 1200-1420 cycles, with 448 of 945 taking 1200-1219 cycles.
>(All the normal interrupts are bound to CPU 0.)

Did you intend to measure the cycles, ticks(jiffies) or usec overhead?



Jan Engelhardt
-- 
ENOSPC

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-12-07 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-12-07  3:05 How to measure i386 timer interrupt overhead Chuck Ebbert
2004-12-07 11:36 ` Jan Engelhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome