All of lore.kernel.org
 help / color / mirror / Atom feed
From: Izik Eidus <ieidus@redhat.com>
To: Brian Jackson <iggy@theiggy.com>
Cc: kvm@vger.kernel.org
Subject: Re: kvm userspace: ksm support
Date: Mon, 03 Aug 2009 22:04:15 +0300	[thread overview]
Message-ID: <4A7734AF.3060505@redhat.com> (raw)
In-Reply-To: <200908031337.55323.iggy@theiggy.com>

Brian Jackson wrote:
> On Monday 03 August 2009 01:09:38 pm Izik Eidus wrote:
>   
>> Brian Jackson wrote:
>>     
>>> If someone wanted to play around with ksm in qemu-kvm-0.x.x would it be
>>> as simple as adding the below additions to kvm_setup_guest_memory in
>>> kvm-all.c
>>>       
>> qemu-kvm-0.x.x doesnt tell me much, but if it is the function that
>> register the memory than yes...
>>
>> (I just remember that qemu used to have something called phys_ram_base,
>> in that case it would be just making madvise on phys_ram_base with the
>> same of phys_ram_size....)
>>     
>
> Sorry, I'm using qemu-kvm-0.10.6
>
>
> This is what qemu_ram_alloc looks like:
>
>
>
> /* XXX: better than nothing */
> ram_addr_t qemu_ram_alloc(ram_addr_t size)
> {
>     ram_addr_t addr;
>     if ((phys_ram_alloc_offset + size) > phys_ram_size) {
>         fprintf(stderr, "Not enough memory (requested_size = %" PRIu64 ", max memory = %" PRIu64 ")\n",
>                 (uint64_t)size, (uint64_t)phys_ram_size);
>         abort();
>     }
>     addr = phys_ram_alloc_offset;
>     phys_ram_alloc_offset = TARGET_PAGE_ALIGN(phys_ram_alloc_offset + size);
>
>     if (kvm_enabled())
>         kvm_setup_guest_memory(phys_ram_base + addr, size);
>
>     return addr;
> }
>
>
> And this is what my new kvm_setup_guest_memory looks like:
>
>
> void kvm_setup_guest_memory(void *start, size_t size)
> {
>     if (!kvm_has_sync_mmu()) {
> #ifdef MADV_DONTFORK
>         int ret = madvise(start, size, MADV_DONTFORK);
>
>         if (ret) {
>             perror("madvice");
>             exit(1);
>         }
> #else
>         fprintf(stderr,
>                 "Need MADV_DONTFORK in absence of synchronous KVM MMU\n");
>         exit(1);
> #endif
>     }
> #ifdef MADV_MERGEABLE
>         madvise(start, size, MADV_MERGEABLE);
> #endif
> }
>
>
>
> Look okay?
>
>
>   

Yes.

  reply	other threads:[~2009-08-03 19:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-28 16:39 kvm userspace: ksm support Izik Eidus
2009-07-28 16:41 ` Anthony Liguori
2009-07-28 16:50   ` Izik Eidus
2009-07-29  1:27     ` Anthony Liguori
2009-07-29  8:51       ` Jan Kiszka
2009-07-29  9:30       ` Avi Kivity
2009-08-03 18:08 ` Brian Jackson
2009-08-03 18:09   ` Izik Eidus
2009-08-03 18:37     ` Brian Jackson
2009-08-03 19:04       ` Izik Eidus [this message]
2009-08-05 18:38         ` Brian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A7734AF.3060505@redhat.com \
    --to=ieidus@redhat.com \
    --cc=iggy@theiggy.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.