On 05/08/2012 02:24 PM, Gleb Natapov wrote:
> Signed-off-by: Gleb Natapov <[email protected]>

Please describe the regression you're testing for.  We could even link
it to the fix with the commit hash.


>  void vfree(void *mem)
>  {
>      unsigned long size = ((unsigned long *)mem)[-1];
> diff --git a/lib/x86/vm.h b/lib/x86/vm.h
> index 71ab4a8..ff4842f 100644
> --- a/lib/x86/vm.h
> +++ b/lib/x86/vm.h
> @@ -22,6 +22,7 @@ void vfree(void *mem);
>  void *vmap(unsigned long long phys, unsigned long size);
>  void *alloc_vpage(void);
>  void *alloc_vpages(ulong nr);
> +unsigned long virt_to_phys_cr3(void *mem);

uint64_t.

> @@ -0,0 +1,98 @@
> +/*
> + * Async PF test. For the test to actually do anywathing it ineeds to be 
> started
> + * in memory cgroup with 512M of memory and with more then 1G memory 
> provided 
> + * to the guest.
> + */

Please include instructions or a script on how to do that.

Alterative ways of doing this:
- file-backed memory using FUSE to control paging
- add madvise(MADV_DONTNEED) support to testdev, and have the guest
trigger page-in itself.

I'm not asking to change this test, just providing ideas for the future
in case fine-grained control is needed.  It also doesn't thrash the disk.

> +#include "x86/msr.h"
> +#include "x86/processor.h"
> +#include "x86/apic-defs.h"
> +#include "x86/apic.h"
> +#include "x86/desc.h"
> +#include "x86/isr.h"
> +#include "x86/vm.h"
> +
> +#include "libcflat.h"
> +#include <stdint.h>
> +
> +#define KVM_PV_REASON_PAGE_NOT_PRESENT 1
> +#define KVM_PV_REASON_PAGE_READY 2
> +
> +#define MSR_KVM_ASYNC_PF_EN 0x4b564d02
> +
> +#define KVM_ASYNC_PF_ENABLED                    (1 << 0)
> +#define KVM_ASYNC_PF_SEND_ALWAYS                (1 << 1)
> +
> +volatile uint32_t apf_reason __attribute__((aligned(64)));
> +char *buf;
> +volatile uint64_t  i;
> +volatile unsigned long phys;

uint64_t.

> +
> +static void pf_isr(struct ex_regs *r)
> +{
> +     void* virt = (void*)((ulong)(buf+i) & ~4095ul);
> +
> +     switch (get_apf_reason()) {
> +             case 0:

default:

> +                     printf("unexpected #PF at %p\n", read_cr2());
> +                     fail = true;
> +                     break;
> +             case KVM_PV_REASON_PAGE_NOT_PRESENT:
> +                     phys = virt_to_phys_cr3(virt);
> +                     install_pte(phys_to_virt(read_cr3()), 1, virt, phys, 0);
> +                     write_cr3(read_cr3());

What's the point of these?

> +                     printf("Got not present #PF token %x virt addr %p phys 
> addr %p\n", read_cr2(), virt, phys);
> +                     while(phys) {
> +                             irq_enable();
> +                             halt();

Racy... you need safe_halt() here.

> +                             irq_disable();
> +                     }
> +                     break;
> +             case KVM_PV_REASON_PAGE_READY:
> +                     printf("Got present #PF token %x\n", read_cr2());
> +                     if ((uint32_t)read_cr2() == ~0)
> +                             break;
> +                     install_pte(phys_to_virt(read_cr3()), 1, virt, phys | 
> PTE_PRESENT | PTE_WRITE, 0);
> +                     write_cr3(read_cr3());
> +                     phys = 0;
> +                     break;
> +     }
> +}
> +
>

-- 
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to