From 9e4d76d8408ebd39704c96e11ae8b64de754d98d Mon Sep 17 00:00:00 2001 From: guanglei Date: Tue, 29 Aug 2006 04:57:10 +0000 Subject: add another two kinds of timing mechanisms for LKET, i.e. get_cycles() and sched_clock() --- runtime/ChangeLog | 7 ++++ runtime/lket/b2a/lket_b2a.c | 84 +++++++++++++++++++++++++++++++++++++++++---- runtime/lket/b2a/lket_b2a.h | 4 +++ 3 files changed, 89 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/ChangeLog b/runtime/ChangeLog index a1f6d869..d830d1a7 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,10 @@ +2006-08-29 Li Guanglei + + From Gui Jian + * lket/b2a/lket_b2a.c, lket/b2a/lket_b2a.h: + add the support to get_cycles() and sched_clock() timing + mechanism for LKET. + 2006-08-14 Will Cohen PR 3037 diff --git a/runtime/lket/b2a/lket_b2a.c b/runtime/lket/b2a/lket_b2a.c index 98c0b9de..352880f5 100644 --- a/runtime/lket/b2a/lket_b2a.c +++ b/runtime/lket/b2a/lket_b2a.c @@ -18,6 +18,21 @@ #include #include "lket_b2a.h" +#define TIMING_GETCYCLES 0x01 +#define TIMING_GETTIMEOFDAY 0x02 +#define TIMING_SCHEDCLOCK 0x03 + +typedef struct _cpufreq_info { + long timebase; + long long last_cycles; + long long last_time; +} cpufreq_info; + +#define MAX_CPUS 256 +cpufreq_info cpufreq[MAX_CPUS]; + +static long timing_method = TIMING_GETTIMEOFDAY; + static long long start_timestamp; /* Balanced binary search tree to store the @@ -98,17 +113,23 @@ int main(int argc, char *argv[]) } } + // initialize the start cycles + if(timing_method == TIMING_GETCYCLES) { + for(i=0; imicrosecond - start_timestamp; - int sec = usecs/1000000; - int usec = usecs%1000000; + + if(timing_method == TIMING_GETCYCLES) + usecs = (phdr->microsecond - cpufreq[HDR_CpuID(phdr)].last_cycles) + / cpufreq[HDR_CpuID(phdr)].timebase + cpufreq[HDR_CpuID(phdr)].last_time; + else if(timing_method == TIMING_SCHEDCLOCK) + usecs = (phdr->microsecond - start_timestamp) / 1000; + else + usecs = phdr->microsecond - start_timestamp; + + sec = usecs/1000000; + usec = usecs%1000000; fprintf(fp, "\n%d.%d APPNAME: %s PID:%d CPU:%d HOOKGRP:%d HOOKID:%d -- ", sec, usec, diff --git a/runtime/lket/b2a/lket_b2a.h b/runtime/lket/b2a/lket_b2a.h index d9cd4a26..10d26dff 100644 --- a/runtime/lket/b2a/lket_b2a.h +++ b/runtime/lket/b2a/lket_b2a.h @@ -31,6 +31,7 @@ int _GROUP_PAGEFAULT = 7; int _GROUP_NETDEV = 8; int _GROUP_IOSYSCALL = 9; int _GROUP_AIO = 10; +int _GROUP_CPUFREQ = 15; /* hookIDs defined inside each group */ int _HOOKID_REGSYSEVT = 1; @@ -121,6 +122,9 @@ int _HOOKID_AIO_IO_DESTROY_RETURN = 10; int _HOOKID_AIO_IO_CANCEL_ENTRY = 11; int _HOOKID_AIO_IO_CANCEL_RETURN = 12; +int _HOOKID_INIT_CPUFREQ = 1; +int _HOOKID_SWITCH_CPUFREQ = 2; + typedef struct _lket_pkt_header { int16_t total_size; int16_t sys_size; -- cgit