[lkml]   [1997]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectUtilizing rdtsc on i586?
    I made the following module to try out the Pentium cycle counter,
    but I believe it's broken. For one thing, it seems to cause random
    processes to segfault upon loading (at least, it did this before adding
    the cli()/sti() around the main code... not sure if it would do it
    anymore). For another, it returns 67 cycles
    for a for loop that [according to the assembly output] should take
    about 20. It returns around 5000 cycles if the index starts out as
    1000. (I have a p100)

    Hope there's a kind soul out there willing to point out my mistakes,
    or why this has anomalous output.

    [cut here]
    #include <linux/config.h>
    #include <linux/module.h>
    #include <asm/system.h>
    #include <asm/segment.h>
    #include <asm/uaccess.h>
    #include <linux/types.h>
    #include <linux/stddef.h>
    #include <linux/timer.h>
    #include <linux/malloc.h>

    #ifdef MODULE

    int init_module(void)
    unsigned int cnt3, cnt2, cnt1;
    int i;
    printk("cc: started... ");
    __asm__(".byte 0x0f,0x31" : "=a" (cnt1), "=d" (cnt3));
    /* put code to time here */
    /* end code to time here */
    __asm__(".byte 0x0f,0x31" : "=a" (cnt2), "=d" (cnt3));
    printk(" operation took %d cycles\n", cnt2-cnt1);
    return 0;

    void cleanup_module(void)
    [cut here]
    _ ____ Joe Fouche (
    ___| |--- Deranged College Student

     \ /
      Last update: 2005-03-22 13:39    [W:0.019 / U:0.612 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site