xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Keir Fraser <keir@xen.org>
To: James Harper <james.harper@bendigoit.com.au>,
	Tim Deegan <Tim.Deegan@citrix.com>
Cc: xen-devel@lists.xensource.com,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Subject: Re: slow xp hibernation revisited
Date: Sat, 04 Jun 2011 09:33:01 +0100	[thread overview]
Message-ID: <CA0FAC4D.2E4AB%keir@xen.org> (raw)
In-Reply-To: <AEC6C66638C05B468B556EA548C1A77D01D57761@trantor>

On 04/06/2011 09:05, "James Harper" <james.harper@bendigoit.com.au> wrote:

>> 
>> On 04/06/2011 08:38, "James Harper" <james.harper@bendigoit.com.au>
> wrote:
>> 
>>> Looking past the test_bit call, the next statement does another test
> and
>>> sets last_address_index to 0 and returns NULL. Is this just to
> ensure
>>> that the next access isn't just trivially accepted?
>> 
>> Yes, first test is on a potentially stale bucket. Second test is on a
> fresh
>> bucket.
>> 
> 
> How about the following patch? Is munmap the correct way to unmap or is
> an IOCTL required too?

By the way, depending on how this patch performs for you, another
alternative I thought of would be to fail this function if the address
passed in is the same as the address in a io-request we are currently
processing from Xen. After all, if Xen punted the memory access to qemu,
obviously there is no RAM there!

Could be an uglier patch than what you have below however, and maybe below
patch is good enough.

 -- Keir

> The exit condition is what would happen anyway after the remap is done
> and the page is still invalid.
> 
> diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
> index d02e23f..1ff80bb 100644
> --- a/hw/xen_machine_fv.c
> +++ b/hw/xen_machine_fv.c
> @@ -151,6 +151,24 @@ uint8_t *qemu_map_cache(target_phys_addr_t
> phys_addr, uint8_t lock)
>          pentry->next = entry;
>          qemu_remap_bucket(entry, address_index);
>      } else if (!entry->lock) {
> +        if (entry->vaddr_base && entry->paddr_index == address_index &&
> !test_bit(address_offset>>XC_PAGE_SHIFT, entry->valid_mapping))
> +        {
> +            /* The page was invalid previously. Test if it is valid now
> and only remap if so */
> +            xen_pfn_t pfn;
> +            int err;
> +            void *tmp_vaddr;
> +
> +            pfn = phys_addr >> XC_PAGE_SHIFT;
> +            tmp_vaddr = xc_map_foreign_bulk(xc_handle, domid,
> PROT_READ|PROT_WRITE, &pfn, &err, 1);
> +            if (tmp_vaddr)
> +                munmap(tmp_vaddr, PAGE_SIZE);
> +
> +            if (!tmp_vaddr || err)
> +            {
> +                last_address_index = ~0UL;
> +                return NULL;
> +            }
> +        }
>          if (!entry->vaddr_base || entry->paddr_index != address_index
> || !test_bit(address_offset>>XC_PAGE_SHIFT, entry->valid_mapping))
>              qemu_remap_bucket(entry, address_index);
>      }
> 

  parent reply	other threads:[~2011-06-04  8:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 15:34 slow xp hibernation revisited James Harper
2011-06-03 15:43 ` Tim Deegan
2011-06-04  3:16   ` James Harper
2011-06-04  4:46   ` James Harper
2011-06-04  4:54     ` James Harper
2011-06-04  6:39       ` Keir Fraser
2011-06-04  7:38         ` James Harper
2011-06-04  7:51           ` Keir Fraser
2011-06-04  8:05             ` James Harper
2011-06-04  8:30               ` Keir Fraser
2011-06-06 13:58                 ` Stefano Stabellini
2011-06-21 17:05                   ` Ian Jackson
2011-06-21 18:00                     ` Stefano Stabellini
2011-06-04  8:33               ` Keir Fraser [this message]
2011-06-06 13:09               ` Stefano Stabellini
2011-06-06 13:26                 ` James Harper
2011-06-06 13:29                   ` James Harper
2011-06-06 13:38                     ` Stefano Stabellini
2011-06-06 13:35                   ` Stefano Stabellini

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=CA0FAC4D.2E4AB%keir@xen.org \
    --to=keir@xen.org \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=Tim.Deegan@citrix.com \
    --cc=james.harper@bendigoit.com.au \
    --cc=xen-devel@lists.xensource.com \
    /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;
as well as URLs for NNTP newsgroup(s).