diff options
| author | Michael Brown | 2014-05-03 13:29:08 +0200 |
|---|---|---|
| committer | Michael Brown | 2014-05-03 19:52:12 +0200 |
| commit | be7f35d9c02550512e4d9cb49ff64b97a04b902a (patch) | |
| tree | 727dade9794d72ee0d7bbd5aee95440d82643890 /src | |
| parent | [profile] Provide methods for profiling individual stages of operations (diff) | |
| download | ipxe-be7f35d9c02550512e4d9cb49ff64b97a04b902a.tar.gz ipxe-be7f35d9c02550512e4d9cb49ff64b97a04b902a.tar.xz ipxe-be7f35d9c02550512e4d9cb49ff64b97a04b902a.zip | |
[librm] Add profiling self-tests for complete real_call and prot_call cycles
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/i386/transitions/librm_test.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/arch/i386/transitions/librm_test.c b/src/arch/i386/transitions/librm_test.c index 8f5be4229..e07cfccdd 100644 --- a/src/arch/i386/transitions/librm_test.c +++ b/src/arch/i386/transitions/librm_test.c @@ -45,6 +45,19 @@ static struct profiler p2r_profiler __profiler = { .name = "p2r" }; /** Real-to-protected mode transition profiler */ static struct profiler r2p_profiler __profiler = { .name = "r2p" }; +/** Real-mode call profiler */ +static struct profiler real_call_profiler __profiler = { .name = "real_call" }; + +/** Protected-mode call profiler */ +static struct profiler prot_call_profiler __profiler = { .name = "prot_call" }; + +/** + * Dummy protected-mode function + */ +static void librm_test_prot_call ( void ) { + /* Do nothing */ +} + /** * Perform real mode transition self-tests * @@ -52,6 +65,8 @@ static struct profiler r2p_profiler __profiler = { .name = "r2p" }; static void librm_test_exec ( void ) { unsigned int i; unsigned long timestamp; + unsigned long started; + unsigned long stopped; unsigned int discard_d; /* Profile mode transitions. We want to profile each @@ -68,6 +83,29 @@ static void librm_test_exec ( void ) { profile_stop ( &r2p_profiler ); profile_stop_at ( &p2r_profiler, timestamp ); } + + /* Profile complete real-mode call cycle */ + for ( i = 0 ; i < PROFILE_COUNT ; i++ ) { + profile_start ( &real_call_profiler ); + __asm__ __volatile__ ( REAL_CODE ( "" ) : : ); + profile_stop ( &real_call_profiler ); + } + + /* Profile complete protected-mode call cycle */ + for ( i = 0 ; i < PROFILE_COUNT ; i++ ) { + __asm__ __volatile__ ( REAL_CODE ( "rdtsc\n\t" + "movl %0, %2\n\t" + "pushl %3\n\t" + "pushw %%cs\n\t" + "call prot_call\n\t" + "addw $4, %%sp\n\t" + "rdtsc\n\t" ) + : "=a" ( stopped ), "=d" ( discard_d ), + "=r" ( started ) + : "i" ( librm_test_prot_call ) ); + profile_start_at ( &prot_call_profiler, started ); + profile_stop_at ( &prot_call_profiler, stopped ); + } } /** Real mode transition self-test */ |
