mirror of
https://github.com/ipxe/ipxe
synced 2025-12-26 01:22:37 +03:00
[profile] Allow interrupts to be excluded from profiling results
Interrupt processing adds noise to profiling results. Allow interrupts (from within protected mode) to be profiled separately, with time spent within the interrupt handler being excluded from any other profiling currently in progress. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -240,12 +240,12 @@ int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
|
||||
"D" ( __from_data16 ( &pxeparent_params ) )
|
||||
: "ecx", "esi" );
|
||||
profile_stop ( &profiler->total );
|
||||
profile_start_at ( &profiler->p2r, profiler->total.started );
|
||||
profile_start_at ( &profiler->p2r, profile_started ( &profiler->total));
|
||||
profile_stop_at ( &profiler->p2r, started );
|
||||
profile_start_at ( &profiler->ext, started );
|
||||
profile_stop_at ( &profiler->ext, stopped );
|
||||
profile_start_at ( &profiler->r2p, stopped );
|
||||
profile_stop_at ( &profiler->r2p, profiler->total.stopped );
|
||||
profile_stop_at ( &profiler->r2p, profile_stopped ( &profiler->total ));
|
||||
|
||||
/* Determine return status code based on PXENV_EXIT and
|
||||
* PXENV_STATUS
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ipxe/profile.h>
|
||||
#include <realmode.h>
|
||||
#include <pic8259.h>
|
||||
|
||||
@@ -30,6 +31,12 @@ struct idtr idtr = {
|
||||
.limit = ( sizeof ( idt ) - 1 ),
|
||||
};
|
||||
|
||||
/** Timer interrupt profiler */
|
||||
static struct profiler timer_irq_profiler __profiler = { .name = "irq.timer" };
|
||||
|
||||
/** Other interrupt profiler */
|
||||
static struct profiler other_irq_profiler __profiler = { .name = "irq.other" };
|
||||
|
||||
/**
|
||||
* Allocate space on the real-mode stack and copy data there from a
|
||||
* user buffer
|
||||
@@ -103,19 +110,39 @@ void init_idt ( void ) {
|
||||
idtr.base = virt_to_phys ( idt );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine interrupt profiler (for debugging)
|
||||
*
|
||||
* @v intr Interrupt number
|
||||
* @ret profiler Profiler
|
||||
*/
|
||||
static struct profiler * interrupt_profiler ( int intr ) {
|
||||
|
||||
switch ( intr ) {
|
||||
case IRQ_INT ( 0 ) :
|
||||
return &timer_irq_profiler;
|
||||
default:
|
||||
return &other_irq_profiler;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupt handler
|
||||
*
|
||||
* @v irq Interrupt number
|
||||
* @v intr Interrupt number
|
||||
*/
|
||||
void __attribute__ (( cdecl, regparm ( 1 ) )) interrupt ( int irq ) {
|
||||
void __attribute__ (( cdecl, regparm ( 1 ) )) interrupt ( int intr ) {
|
||||
struct profiler *profiler = interrupt_profiler ( intr );
|
||||
uint32_t discard_eax;
|
||||
|
||||
/* Reissue interrupt in real mode */
|
||||
profile_start ( profiler );
|
||||
__asm__ __volatile__ ( REAL_CODE ( "movb %%al, %%cs:(1f + 1)\n\t"
|
||||
"\n1:\n\t"
|
||||
"int $0x00\n\t" )
|
||||
: "=a" ( discard_eax ) : "0" ( irq ) );
|
||||
: "=a" ( discard_eax ) : "0" ( intr ) );
|
||||
profile_stop ( profiler );
|
||||
profile_exclude ( profiler );
|
||||
}
|
||||
|
||||
PROVIDE_UACCESS_INLINE ( librm, phys_to_user );
|
||||
|
||||
Reference in New Issue
Block a user