Linux-kernel mailing list archive 2000-15,: newbie question (how to measure time)

# newbie question (how to measure time)

dLux (dlux@kapu.hu)
Tue, 11 Apr 2000 18:05:44 +0200

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Alexander Viro: "[STOP IT] procfs stuff"
- Previous message: Richard Gooch: "Re: Suggested dual human/binary interface for proc/devfs"
- Next in thread: Jan-Simon Pendry: "Re: newbie question (how to measure time)"
- Reply: Jan-Simon Pendry: "Re: newbie question (how to measure time)"
- Reply: Alejandro Conty: "Re: newbie question (how to measure time)"

Hello!

I need to measure the time spent in one process, and I need to do
it as exact as possible (about 1us). 2.2.x kernel series, Pentium II
proc.

My first and not-yet-working solution:
I declared 3 variables in the arch/i386/kernel/process.c:

static pid_t ProcID;
static unsigned long long int RunStart;
static unsigned long long int Elapsed;

ProcID is the process id, which needs to be profiled. Elapsed is
the time commulated in the process running, RunStart is a temporary
variable.

I put some additional code to the beginning of the __switch_to in
the arch/i386/kernel/process.c:

if (prev->pid == ProcID) {
Elapsed += rdtsc_return()-RunStart;
} else if (next->pid == ProcID) {
RunStart = rdtsc_return();
};

rdtsc_return() is a function, which returns the Pentium clock in
long long int format.

These code checks if the process we want to measure is on the
schedule or not.
After it I wanted to write a kernel module, which registered a
file in the /proc, and it can set the ProcID via it, and get the
"Elapsed" value from it.
The problem is that I don't know how I use that variables.

I tried this:

extern pid_t ProcID;
extern long long int Elapsed;

But when I want to use my module, it prints:

or2:/projects/boomerang/timer# insmod timermod.o
timermod.o: unresolved symbol ProcID
timermod.o: unresolved symbol Elapsed

(The timermod.c originally based on the procfs.c file, which is
included in some kernel howto.)

The System.map file in the /usr/src/linux-2.2.13 contains that
symbols:

c021c8c0 b ProcID
c021c8cc b Elapsed

I copied the System.map into /boot/System.map-2.2.13,
/lib/modules/2.2.13, but it doesn't help. Do you know how I can
access those variables?

Another question:
-----------------
Do you know a better and faster way to access that variables? May I
make a device driver for it? Make a syscall? Please refer me to the
URL when I can study these materials.

Thanks for any help in advance,

dLux

    --
                  God save the screen!

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

- Next message: Alexander Viro: "[STOP IT] procfs stuff"
- Previous message: Richard Gooch: "Re: Suggested dual human/binary interface for proc/devfs"
- Next in thread: Jan-Simon Pendry: "Re: newbie question (how to measure time)"
- Reply: Jan-Simon Pendry: "Re: newbie question (how to measure time)"
- Reply: Alejandro Conty: "Re: newbie question (how to measure time)"