diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2009-01-28 17:35:02 -0500 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2009-01-30 17:51:44 -0500 |
commit | 41edafdb78feac1d1f8823846209975fde990633 (patch) | |
tree | 00bb95195332962916be365c6119f17a22770758 /arch/x86/kernel/paravirt.c | |
parent | 319f3ba52c71630865b10ac3b99dd020440d681d (diff) |
x86/pvops: add a paravirt_ident functions to allow special patching
Impact: Optimization
Several paravirt ops implementations simply return their arguments,
the most obvious being the make_pte/pte_val class of operations on
native.
On 32-bit, the identity function is literally a no-op, as the calling
convention uses the same registers for the first argument and return.
On 64-bit, it can be implemented with a single "mov".
This patch adds special identity functions for 32 and 64 bit argument,
and machinery to recognize them and replace them with either nops or a
mov as appropriate.
At the moment, the only users for the identity functions are the
pagetable entry conversion functions.
The result is a measureable improvement on pagetable-heavy benchmarks
(2-3%, reducing the pvops overhead from 5 to 2%).
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/kernel/paravirt.c')
-rw-r--r-- | arch/x86/kernel/paravirt.c | 75 |
1 files changed, 66 insertions, 9 deletions
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index 202514be5923..dd25e2b1593b 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c | |||
@@ -44,6 +44,17 @@ void _paravirt_nop(void) | |||
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | /* identity function, which can be inlined */ | ||
48 | u32 _paravirt_ident_32(u32 x) | ||
49 | { | ||
50 | return x; | ||
51 | } | ||
52 | |||
53 | u64 _paravirt_ident_64(u64 x) | ||
54 | { | ||
55 | return x; | ||
56 | } | ||
57 | |||
47 | static void __init default_banner(void) | 58 | static void __init default_banner(void) |
48 | { | 59 | { |
49 | printk(KERN_INFO "Booting paravirtualized kernel on %s\n", | 60 | printk(KERN_INFO "Booting paravirtualized kernel on %s\n", |
@@ -138,9 +149,16 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf, | |||
138 | if (opfunc == NULL) | 149 | if (opfunc == NULL) |
139 | /* If there's no function, patch it with a ud2a (BUG) */ | 150 | /* If there's no function, patch it with a ud2a (BUG) */ |
140 | ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a)); | 151 | ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a)); |
141 | else if (opfunc == paravirt_nop) | 152 | else if (opfunc == _paravirt_nop) |
142 | /* If the operation is a nop, then nop the callsite */ | 153 | /* If the operation is a nop, then nop the callsite */ |
143 | ret = paravirt_patch_nop(); | 154 | ret = paravirt_patch_nop(); |
155 | |||
156 | /* identity functions just return their single argument */ | ||
157 | else if (opfunc == _paravirt_ident_32) | ||
158 | ret = paravirt_patch_ident_32(insnbuf, len); | ||
159 | else if (opfunc == _paravirt_ident_64) | ||
160 | ret = paravirt_patch_ident_64(insnbuf, len); | ||
161 | |||
144 | else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) || | 162 | else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) || |
145 | type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) || | 163 | type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) || |
146 | type == PARAVIRT_PATCH(pv_cpu_ops.usergs_sysret32) || | 164 | type == PARAVIRT_PATCH(pv_cpu_ops.usergs_sysret32) || |
@@ -373,6 +391,45 @@ struct pv_apic_ops pv_apic_ops = { | |||
373 | #endif | 391 | #endif |
374 | }; | 392 | }; |
375 | 393 | ||
394 | typedef pte_t make_pte_t(pteval_t); | ||
395 | typedef pmd_t make_pmd_t(pmdval_t); | ||
396 | typedef pud_t make_pud_t(pudval_t); | ||
397 | typedef pgd_t make_pgd_t(pgdval_t); | ||
398 | |||
399 | typedef pteval_t pte_val_t(pte_t); | ||
400 | typedef pmdval_t pmd_val_t(pmd_t); | ||
401 | typedef pudval_t pud_val_t(pud_t); | ||
402 | typedef pgdval_t pgd_val_t(pgd_t); | ||
403 | |||
404 | |||
405 | #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE) | ||
406 | /* 32-bit pagetable entries */ | ||
407 | #define paravirt_native_make_pte (make_pte_t *)_paravirt_ident_32 | ||
408 | #define paravirt_native_pte_val (pte_val_t *)_paravirt_ident_32 | ||
409 | |||
410 | #define paravirt_native_make_pmd (make_pmd_t *)_paravirt_ident_32 | ||
411 | #define paravirt_native_pmd_val (pmd_val_t *)_paravirt_ident_32 | ||
412 | |||
413 | #define paravirt_native_make_pud (make_pud_t *)_paravirt_ident_32 | ||
414 | #define paravirt_native_pud_val (pud_val_t *)_paravirt_ident_32 | ||
415 | |||
416 | #define paravirt_native_make_pgd (make_pgd_t *)_paravirt_ident_32 | ||
417 | #define paravirt_native_pgd_val (pgd_val_t *)_paravirt_ident_32 | ||
418 | #else | ||
419 | /* 64-bit pagetable entries */ | ||
420 | #define paravirt_native_make_pte (make_pte_t *)_paravirt_ident_64 | ||
421 | #define paravirt_native_pte_val (pte_val_t *)_paravirt_ident_64 | ||
422 | |||
423 | #define paravirt_native_make_pmd (make_pmd_t *)_paravirt_ident_64 | ||
424 | #define paravirt_native_pmd_val (pmd_val_t *)_paravirt_ident_64 | ||
425 | |||
426 | #define paravirt_native_make_pud (make_pud_t *)_paravirt_ident_64 | ||
427 | #define paravirt_native_pud_val (pud_val_t *)_paravirt_ident_64 | ||
428 | |||
429 | #define paravirt_native_make_pgd (make_pgd_t *)_paravirt_ident_64 | ||
430 | #define paravirt_native_pgd_val (pgd_val_t *)_paravirt_ident_64 | ||
431 | #endif | ||
432 | |||
376 | struct pv_mmu_ops pv_mmu_ops = { | 433 | struct pv_mmu_ops pv_mmu_ops = { |
377 | #ifndef CONFIG_X86_64 | 434 | #ifndef CONFIG_X86_64 |
378 | .pagetable_setup_start = native_pagetable_setup_start, | 435 | .pagetable_setup_start = native_pagetable_setup_start, |
@@ -424,21 +481,21 @@ struct pv_mmu_ops pv_mmu_ops = { | |||
424 | .pmd_clear = native_pmd_clear, | 481 | .pmd_clear = native_pmd_clear, |
425 | #endif | 482 | #endif |
426 | .set_pud = native_set_pud, | 483 | .set_pud = native_set_pud, |
427 | .pmd_val = native_pmd_val, | 484 | .pmd_val = paravirt_native_pmd_val, |
428 | .make_pmd = native_make_pmd, | 485 | .make_pmd = paravirt_native_make_pmd, |
429 | 486 | ||
430 | #if PAGETABLE_LEVELS == 4 | 487 | #if PAGETABLE_LEVELS == 4 |
431 | .pud_val = native_pud_val, | 488 | .pud_val = paravirt_native_pud_val, |
432 | .make_pud = native_make_pud, | 489 | .make_pud = paravirt_native_make_pud, |
433 | .set_pgd = native_set_pgd, | 490 | .set_pgd = native_set_pgd, |
434 | #endif | 491 | #endif |
435 | #endif /* PAGETABLE_LEVELS >= 3 */ | 492 | #endif /* PAGETABLE_LEVELS >= 3 */ |
436 | 493 | ||
437 | .pte_val = native_pte_val, | 494 | .pte_val = paravirt_native_pte_val, |
438 | .pgd_val = native_pgd_val, | 495 | .pgd_val = paravirt_native_pgd_val, |
439 | 496 | ||
440 | .make_pte = native_make_pte, | 497 | .make_pte = paravirt_native_make_pte, |
441 | .make_pgd = native_make_pgd, | 498 | .make_pgd = paravirt_native_make_pgd, |
442 | 499 | ||
443 | .dup_mmap = paravirt_nop, | 500 | .dup_mmap = paravirt_nop, |
444 | .exit_mmap = paravirt_nop, | 501 | .exit_mmap = paravirt_nop, |