Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure kernelflinger boot time #91

Open
wants to merge 1 commit into
base: celadon/s/mr0/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/android.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define BOOT_ARGS_SIZE 512
#define BOOT_EXTRA_ARGS_SIZE 1024

extern UINT64 start_tsc;

struct boot_img_hdr
{
Expand Down
1 change: 1 addition & 0 deletions include/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum TM_POINT {
TM_POINT_LAST
};

uint64_t __attribute__((unused,always_inline)) __RDTSC (void);
uint32_t get_cpu_freq(void);
uint32_t boottime_in_msec(void);
void set_boottime_stamp(int num);
Expand Down
1 change: 1 addition & 0 deletions kernelflinger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table)
VBDATA *vb_data = NULL;

set_boottime_stamp(TM_EFI_MAIN);
start_tsc = __RDTSC();
/* gnu-efi initialization */
InitializeLib(image, sys_table);

Expand Down
7 changes: 7 additions & 0 deletions libkernelflinger/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ typedef struct {
} __attribute__((packed)) dt_addr_t;

static dt_addr_t *gdt;
UINT64 start_tsc;

typedef void(*kernel_func)(void *, struct boot_params *);

Expand Down Expand Up @@ -1601,6 +1602,7 @@ static EFI_STATUS handover_kernel(CHAR8 *bootimage, EFI_HANDLE parent_image)
UINT32 koffset;
size_t setup_header_size;
size_t setup_header_end;
UINT64 end_tsc;

aosp_header = (struct boot_img_hdr *)bootimage;
buf = get_boot_param_hdr(bootimage);
Expand Down Expand Up @@ -1677,6 +1679,11 @@ static EFI_STATUS handover_kernel(CHAR8 *bootimage, EFI_HANDLE parent_image)
goto out;
boot_params->hdr.code32_start = (UINT32)((UINT64)kernel_start);

end_tsc = __RDTSC();
log(L"start tsc = %llx\n", start_tsc);
log(L"end tsc = %llx\n", end_tsc);
log(L"total tsc consumed by kernelflinger = %llx\n", end_tsc - start_tsc);

ret = handover_jump(parent_image, boot_params, kernel_start);
/* Shouldn't get here */
efi_perror(ret, L"handover to Linux kernel has failed");
Expand Down
2 changes: 1 addition & 1 deletion libkernelflinger/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ __RDMSR (unsigned idx)
return msr.val;
}

static uint64_t __attribute__((unused,always_inline))
uint64_t __attribute__((unused,always_inline))
__RDTSC (void)
{
uint32_t lo, hi;
Expand Down
Loading