public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
To: Izik Eidus <izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 3/4] Swapping
Date: Sat, 13 Oct 2007 18:35:25 -0500	[thread overview]
Message-ID: <4711563D.8020000@codemonkey.ws> (raw)
In-Reply-To: <4711542F.2060306-atKUWr5tajBWk0Htik3J/w@public.gmane.org>

Izik Eidus wrote:
> Anthony Liguori wrote:
>> Izik Eidus wrote:
>>> Izik Eidus wrote:
>>>> Anthony Liguori wrote:
>>>>> Izik Eidus wrote:
>>>>>>
>>>>>> @@ -1058,8 +1038,27 @@ struct page *gfn_to_page(struct kvm *kvm, 
>>>>>> gfn_t gfn)
>>>>>>  
>>>>>>      gfn = unalias_gfn(kvm, gfn);
>>>>>>      slot = __gfn_to_memslot(kvm, gfn);
>>>>>> -    if (!slot)
>>>>>> +    if (!slot) {
>>>>>> +        get_page(bad_page);
>>>>>>          return bad_page;
>>>>>> +    }
>>>>>> +    if (slot->user_alloc) {
>>>>>> +        struct page *page[1];
>>>>>> +        int npages;
>>>>>> +
>>>>>> +        down_read(&current->mm->mmap_sem);
>>>>>> +        npages = get_user_pages(current, current->mm,
>>>>>> +                    slot->userspace_addr
>>>>>> +                    + (gfn - slot->base_gfn) * PAGE_SIZE, 1,
>>>>>> +                    1, 0, page, NULL);
>>>>>> +        up_read(&current->mm->mmap_sem);
>>>>>> +        if (npages != 1) {
>>>>>> +            get_page(bad_page);
>>>>>> +            return bad_page;
>>>>>> +        }
>>>>>> +        return page[0];
>>>>>>   
>>>>>
>>>>> Wouldn't it be necessary to assign page[0] to slot->phys_mem[gfn - 
>>>>> slot->base_gfn]?
>>>>
>>> sorry, it seems like i missunderstand you in the answer i gave you.
>>> it wouldnt be necessary to assign page[0] to slot->phys_mem[gfn - 
>>> slot->base_gfn], beacuse phys_mem wont have any memory allocate by 
>>> this time.
>>>
>>> with this patch, we are not holding anymore (when using userspace 
>>> allocation) array of all the memory at phys_mem.
>>> beacuse now that the pages are swappable, the physical address 
>>> pointed by the virtual address all the time change (for example when 
>>> swapping happn)
>>> so no one promise us that slot->phys_mem[gfn - slot->base_gfn] will 
>>> really point to page holding the gfn page.
>>>
>>> so what we did, is throw away the phys_mem array (also nice beacuse 
>>> it waste less ram), and at runtime we are getting the pages by using 
>>> the virtual address
>>> beacuse the reference of the page get increased, it promised us that 
>>> untill we release it point to the gfn (release it by doing put_page)
>>>
>>> hope i was more clear this time :)
>>
>> Yes, that makes sense!
>>
>> I wonder if there's a more elegant way dealing with older 
>> userspaces.  For instance, is there any reason why we can allocate a 
>> userspace memory region on behalf of userspace.  That way swap would 
>> even work with older userspaces.
> if we can do that, yes swap will work on older userspace.

I think it's just a matter of calling do_mmap() with the appropriate 
parameters.  It looks likes there's some drivers call do_mmap() directly.

Regards,

Anthony Liguori

>> Regards,
>>
>> Anthony Liguori
>>
>>
>
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

  parent reply	other threads:[~2007-10-13 23:35 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-13  2:10 [PATCH 3/4] Swapping Izik Eidus
     [not found] ` <47102919.6070802-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-13 20:04   ` Anthony Liguori
     [not found]     ` <471124D4.3090901-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-13 20:13       ` Izik Eidus
     [not found]         ` <471126D9.4030204-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-13 20:41           ` Izik Eidus
     [not found]             ` <47112D66.4020500-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-13 23:17               ` Anthony Liguori
     [not found]                 ` <47115207.3090909-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-13 23:26                   ` Izik Eidus
     [not found]                     ` <4711542F.2060306-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-13 23:35                       ` Anthony Liguori [this message]
     [not found]                         ` <4711563D.8020000-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-13 23:38                           ` Izik Eidus
     [not found]                             ` <471156D9.3030700-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-14  0:36                               ` Anthony Liguori
     [not found]                                 ` <47116486.4070609-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-14  6:12                                   ` Izik Eidus
2007-10-15 19:26                                   ` Anthony Liguori
     [not found]                                     ` <4713BED9.7000302-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-15 20:01                                       ` Izik Eidus
     [not found]                                         ` <4713C700.5010304-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-15 20:03                                           ` Izik Eidus
2007-10-14  6:02                           ` Avi Kivity
     [not found]                             ` <4711B101.7070305-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-14  7:46                               ` Avi Kivity
2007-10-14 14:57                               ` Anthony Liguori
     [not found]                                 ` <47122E57.7060308-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-14 16:08                                   ` Avi Kivity
     [not found]                                     ` <47123EFA.1010808-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-14 17:11                                       ` Anthony Liguori
     [not found]                                         ` <47124DBB.9030708-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-14 17:16                                           ` Avi Kivity

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=4711563D.8020000@codemonkey.ws \
    --to=anthony-rdkfgonbjusknkdkm+me6a@public.gmane.org \
    --cc=izike-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox