On Nov 11, 2009, at 3:40 PM, Maynard Johnson <maynardj@us.ibm.com> wrote:

jobhunts02@aol.com wrote:
Sent from my iPhone 3G
On Nov 11, 2009, at 10:46 AM, Maynard Johnson <maynardj@us.ibm.com> wrote:
jobhunts02@aol.com wrote:
On Nov 10, 2009, at 5:40 PM, Maynard Johnson <maynardj@us.ibm.com> wrote:
jobhunts02@aol.com wrote:
On Nov 10, 2009, at 2:16 PM, Maynard Johnson <maynardj@us.ibm.com>
wrote:

jobhunts02@aol.com wrote:
Correction..driver.ko is in the /AAESystems/bin diectory.


On Nov 10, 2009, at 11:23 AM, Washington Ratso <JobHunts02@aol.com>
wrote:

I am running Linux 2.6.26 on an MPC8248 with busybox and JFFS2.  The
driver
that I want to profile (driver.ko) is in the /drivers directory.  I
loaded
the module using insmod.  Here are the commands I am using:

Eclipse # /usr/bin/opcontrol --setup --no-vmlinux
Eclipse # /usr/bin/opcontrol --start
Using 2.6+ OProfile kernel interface.
Using log file /var/lib/oprofile/samples/oprofiled.log
Daemon started.
Profiler running.
Eclipse # /usr/bin/opcontrol --stop
Stopping profiling.
Eclipse # /usr/bin/opreport -p=/AAESystems/bin
I presume this isn't *really* the way you specified the -p option,
since you would get an error this way.  Assuming you actually used '-
p /AAESystems/bin', then opreport should find your kernel module.
Are you sure the module was doing anything where it would actually
generate samples?

-Maynard

I get a report whether I use "-p=/AAESystems/bin" or "-p /AAESystems/
bin". No error either way.
At least the last couple of releases do *not* support '-p=blah'.  What oprofile release are you using?

The module is definitely running and several functions are being
executed repeatedly.  What do you mean by a module "doing anything
where it would actually generate samples?"
When the timer profiling timer pops, what's the likelihood that the driver is actively executing and, thus, be sampled by oprofile?  From the output below, it doesn't look like you're running oprofile very long -- only ~1200 samples.  Try running for lot longer period.  The sampling timer is not going to give you very fine-grained profile data, so you need to run much longer to get a valid profile.

-Maynard
I ran it longer (see below) and there is still no sign of my inserted module.  I did not run it longer because putting vmlinux on my board uses up almost all the memory and I was concerned I might run out of memory.
Note, there is also no sign of the oprofile module in the report either.
I also ran a test module which had a loop with 100 billion iterations to insure it would be in the function awhile and sampled and there was no sign of that module in the report either.
What could cause there not being any samples for the inserted modules?
Eclipse # /usr/bin/opreport
CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt

When using timer mode profiling, sampling is not possible when interrupts are disabled.  OProfile sampling code is executed with interrupts disabled, so that's why you see no samples for the oprofile module itself.  Likely the same reason you're not seeing samples for your own kernel module.

-Maynard
Below is the code for my test driver that I do not see samples for either.   As you can see, interrupts are not disabled.
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void)
{
   long long i=0;
   printk(KERN_WARNING "Hello world.  Before LOOP.\n");
   for(i=0; i< 10000000000; i++)
       ;
I plunked this piece of code into a module init and tried profiling it and didn't get any samples either when using timer mode.  I had to switch back to event-based profiling and took a sample every 10,000 cycles before I even saw 1 sample for my module load action.  The reason is that, typically, gcc will optimize this kind of brain-dead code so that the processor does not really sit and loop 10 billion times for nothing.  You have to trick gcc into not optimizing.  For example, I called getnstimeofday() before and after the loop (and also printed the sec and nsec values); then in the loop, I compared i==timespec.tv_nsec and then just incremented i if they were equal.  A meaningless action, but enough to fool gcc.  Switching back to timer-based profiling, I see several thousand samples for my module init, which now took several seconds to complete.  Your mileage may vary.

-Maynard

Here is the code I ran.  I could not use getnstimeofday() because I got an "Unknown symbol getnstimeofday" error when I tried to insert the module on my board.

 

#include <linux/module.h> 

#include <linux/kernel.h> 

#include <linux/time.h>

 

int init_module(void)

{

    long long i=0;

    struct timeval tv;

 

    do_gettimeofday(&tv);

    printk(KERN_WARNING "Before loop, time is %d.%06d\n", tv.tv_sec, tv.tv_usec);

    for(i=0; i< 10000000000; i++)

    {   

        if(i == tv.tv_usec)

        {

            i++;

        }

    }

    do_gettimeofday(&tv);

    printk(KERN_WARNING "After loop, time is %d.%06d\n", tv.tv_sec, tv.tv_usec);

 

    return 0;

}

 

void cleanup_module(void)

{

     printk(KERN_INFO "Goodbye world 1.\n");

}

 

I saw the following in /var/log/messages:

 

Nov 12 00:47:13 (none) user.warn kernel: Before loop, time is 1257986833.433372

Nov 12 00:52:25 (none) user.warn kernel: After loop, time is 1257987145.384882

 

The module (hello4.ko) ran for 312 seconds, but there is no sign of it when I run the opreport command:

 

Eclipse # /usr/bin/opreport

CPU: CPU with timer interrupt, speed 0 MHz (estimated)

Profiling through timer interrupt

          TIMER:0|

  samples|      %|

------------------

   225523 99.3975 vmlinux.PRO_MOD

      494  0.2177EclipseMSW.elf.NOV8

      319  0.1406 dropbearmulti

      305  0.1344 libc-2.6.so

       88  0.0388 oprofiled

       68  0.0300 snmpd

                  TIMER:0|

          samples|      %|

        ------------------

               67 98.5294 snmpd

                1  1.4706 [heap] (tgid:87 range:0x1016d000-0x1022f000)

       24  0.0106libEclipsePai.so

       18  0.0079libEclipseLog.so

       18  0.0079 ld-2.6.so

       16  0.0071 busybox-1.15.2.mtab

       14  0.0062 libm-2.6.so

        1 4.4e-04 gateway

        1 4.4e-04 libEclipseMmap.so

        1 4.4e-04 libpthread-2.6.so

 

 

This is the instruction sequence I used:

 

/usr/bin/opcontrol --setup --kernel-range=0xc0000000,0xc9500000 --vmlinux=/root/vmlinux.PRO_MOD

/usr/bin/opcontrol --start

insmod hello4.ko

/usr/bin/opcontrol --shutdown

/usr/bin/opreport

 



   printk(KERN_WARNING "Hello world.  After LOOP.\n");
   return 0;
}
void cleanup_module(void)
{
    printk(KERN_INFO "Goodbye world 1.\n");
}

        TIMER:0|
samples|      %|
------------------
  93763 95.7127 vmlinux.PRO_MOD
   2141  2.1855 EclipseMSW.elf.NOV8
                TIMER:0|
        samples|      %|
      ------------------
           2133 99.6263 EclipseMSW.elf.NOV8
              8  0.3737 [heap] (tgid:88 range:0x1011e000-0x104c1000)
   1251  1.2770 libc-2.6.so
    214  0.2184 libpthread-2.6.so
    132  0.1347 dropbearmulti
    123  0.1256 libEclipseSem.so
     83  0.0847 snmpd
     70  0.0715 libm-2.6.so
     50  0.0510 libEclipseLst.so
     43  0.0439 oprofiled
     39  0.0398 librt-2.6.so
     16  0.0163 libEclipseLog.so
     13  0.0133 ld-2.6.so
      9  0.0092 busybox
      8  0.0082 libEclipseHms.so
      4  0.0041 libEclipseMmap.so
      2  0.0020 libEclipsePai.so
      1  0.0010 gateway
      1  0.0010 libutil-2.6.so

Am I using the correct commands to get profile information from a
module?


Overflow stats not available
CPU: CPU with timer interrupt, speed 0 MHz (estimated)
Profiling through timer interrupt
     TIMER:0|
samples|      %|
------------------
1145 93.6989 no-vmlinux
  26  2.1277 libc-2.6.so
  18  1.4730 EclipseMSW.elf.NOV8
  15  1.2275 ld-2.6.so
  10  0.8183 busybox
   4  0.3273 dropbearmulti
   4  0.3273 libpthread-2.6.so


As you can see, I am getting no information regarding driver.ko.

I did specify the path where the driver.ko file is.  How do I get
information regarding driver.ko?


--
View this message in context: http://old.nabble.com/Trouble-profiling-kernel-module-tp26289063p26289063.html
Sent from the oprofile-list mailing list archive at Nabble.com.


---
---
---
---
------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and
focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
oprofile-list mailing list
oprofile-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oprofile-list
---
---
---
---------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports
2008 30-Day
trial. Simplify your report design, integration and deployment -
and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
oprofile-list mailing list
oprofile-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oprofile-list



=