flat assembler
Message board for the users of flat assembler.
Index
> OS Construction > Flush sticky global page |
Author |
|
Feryno 09 Feb 2021, 20:51
most OS-es flush all global pages by toggling the PGE bit, it is very fast, especially if the OS uses a lot of global pages
if you have only a few global pages then invlpg in a loop is fast too you can increase any loop performance by aligning the beginning of the loop at 4 (32 bit OS) or at 16 (64 bit OS) Code: align 4 ; I assume you are using 32 bit OS as you reference virtual memory by 32 bit register EAX _flush_tlb_mannual_loop: invlpg [eax] add eax, _PAGE_FRAME_SIZE loop _flush_tlb_mannual_loop ret you can also perform 2 invalidations (or even 4, 8, etc) in 1 loop and eventually at the end perform the last one invalidation Code: mov edx,ecx shr ecx,1 align 4 @@: invlpg [eax] invlpg [eax+_PAGE_FRAME_SIZE] add eax,2*_PAGE_FRAME_SIZE loop @b test dl,1 jz @f invlpg [eax] @@: ret you can easily measure the perfomance by reading timestamp counter (TSC) using the RDTSC instruction before and after and compare the 2 values reported by the instruction (ideally with disabled interrupts so nothing interrupts you and not only once but more times and calculate an average value from more iterations) |
|||
09 Feb 2021, 20:51 |
|
MaoKo 10 Feb 2021, 14:12
Thank you Feryno for the tips. I've done some test and disabling PGE in cr4 seem faster than updating an MTRR.
I've not thinking about the loop unrolling technique, thank. |
|||
10 Feb 2021, 14:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.