mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris K Cockrum <kernel@cockrum.net>
To: linux-kernel@vger.kernel.org
Subject: Module Profiling Problem
Date: Mon, 22 Jan 2001 18:44:28 -0500	[thread overview]
Message-ID: <4.3.2.7.2.20010122183536.00b0b810@cockrum.net> (raw)

I have been developing a driver for an audio card and encountered a problem 
which I have duplicated in the test code below.  My problem is that when 
trying to profile a section of code in a kernel module I get erratic 
results.  My cycle counts are sometimes 73xxx cycles more that I expect 
them to be.  Does anyone know what could be causing this?

Thanks in Advance,
Chris K Cockrum
iBiquity Digital Corp.
http://www.ibiquity.com


Running Linux 2.4.0 on a Tyan Tiger Dual 800MHz Motherboard w/133MHz Bus

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <asm/smplock.h>

/* Declare Spinlock */
spinlock_t testlock;

int init_module(void)
{
    unsigned long long starttime,stoptime;

    unsigned int lockflags,n,tempval=20000;

    spin_lock_init(&testlock);

    for (n=0;n<40;n++)
    {
       spin_lock_irqsave(&testlock,lockflags);

       /* Clear Interrupt Flag */
       __asm__ __volatile__ ("cli");

       /* Get CPU Clock */
       __asm__ __volatile__ ("rdtsc\n\t" \
                             "movl %%eax, (%%ecx)\n\t" \
                             "movl %%edx, 4(%%ecx)"\
                             ::"c" (&starttime));

       /* Waste Time-Register Moves Looped tempval Times */
       __asm__ __volatile__ ("loop: movl %%ecx,%%eax\t\n" \
                             "      decl %%ecx\t\n" \
                             "      jnz loop" \
                             :: "c" (tempval) : "%eax");

       /* Get CPU Clock */
       __asm__ __volatile__ ("rdtsc\n\t" \
                             "movl %%eax, (%%ecx)\n\t" \
                             "movl %%edx, 4(%%ecx)"\
                             ::"c" (&stoptime));

       spin_unlock_irqrestore(&testlock,lockflags);

       printk(KERN_DEBUG "Test: 0x%08X:%08X - %d Cycles\n", \
             (unsigned int) (((stoptime-starttime)>>32)&0xFFFFFFFF), \
             (unsigned int)  ((stoptime-starttime)     &0xFFFFFFFF), \
             (unsigned int)  ((stoptime-starttime)     &0xFFFFFFFF)  );

    }
    return 0;
}

void cleanup_module(void)
{
printk(KERN_DEBUG "Unloaded\n");
}


Results:

Test: 0x00000000:0000EA94 - 60052 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:00020977 - 133495 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:00020997 - 133527 Cycles
Test: 0x00000000:0002098F - 133519 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:00020976 - 133494 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0002098A - 133514 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0002098E - 133518 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles
Test: 0x00000000:0002098A - 133514 Cycles
Test: 0x00000000:0000EA87 - 60039 Cycles

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

                 reply	other threads:[~2001-01-22 23:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4.3.2.7.2.20010122183536.00b0b810@cockrum.net \
    --to=kernel@cockrum.net \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®