public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Lai Jiangshan <laijs@cn.fujitsu.com>, Nick Piggin <npiggin@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [PATCH 6/6] kvm, faster and simpler version of get_user_page_and_protection()
Date: Sun, 18 Jul 2010 17:18:04 +0300	[thread overview]
Message-ID: <4C430D1C.3060203@redhat.com> (raw)
In-Reply-To: <4C3FC03A.9040504@cn.fujitsu.com>

On 07/16/2010 05:13 AM, Lai Jiangshan wrote:
> a light weight version of get_user_page_and_protection()
>
>
> @@ -375,3 +374,83 @@ slow_irqon:
>   		return ret;
>   	}
>   }
> +
> +/*
> + * get a current mapped page fast, and test whether the page is writable.
> + * equivalent version(but slower):
> + * {
> + *	struct page *page[1];
> + *
> + *	if (__get_user_pages_fast(addr, 1, 1, page) == 1) {
> + *		*writable = 1;
> + *		return page[0];
> + *	}
> + *	if (__get_user_pages_fast(addr, 1, 0, page) == 1) {
> + *		*writable = 0;
> + *		return page[0];
> + *	}
> + *	return NULL;
> + * }
> + */
> +struct page *get_user_page_and_protection(unsigned long addr, int *writable)
> +{
>
>    

<snip lots of code>

> +}
> +EXPORT_SYMBOL_GPL(get_user_page_and_protection);
> +
>    

This a duplication of __get_user_pages_fast(), no?

I think a better way is to have a __get_user_pages_ptes(..., struct page 
*pages, pte_t *ptes, ...), and write __get_user_pages_fast() in terms of 
that.  There's lots of useful info from the pte we can use:

- writeable bit (used here)
- page size (we can stick it in some user bits, speeds up 
host_mapping_level())
- dirty bit (if set, we can set it for speculative sptes and save the 
CPU a RMW)
- page attribute (for device assignment, when snooping is not available)

Nick, is __get_user_pages_ptes() fine with you?

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


      parent reply	other threads:[~2010-07-18 14:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-16  2:13 [PATCH 6/6] kvm, faster and simpler version of get_user_page_and_protection() Lai Jiangshan
2010-07-16 23:48 ` Marcelo Tosatti
2010-07-18 14:18 ` Avi Kivity [this message]

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=4C430D1C.3060203@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=npiggin@suse.de \
    /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