All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zachary Amsden <zach@vmware.com>
To: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: akpm@osdl.org, virtualization@lists.osdl.org,
	frankeh@watson.ibm.com, rhim@cc.gateh.edu,
	nickpiggin@yahoo.com.au, linux-kernel@vger.kernel.org
Subject: Re: [patch 5/9] Guest page hinting: mlocked pages.
Date: Wed, 13 Sep 2006 18:22:01 -0700	[thread overview]
Message-ID: <4508AEB9.4080409@vmware.com> (raw)
In-Reply-To: <20060901111022.GF15684@skybase>

Martin Schwidefsky wrote:
> diff -urpN linux-2.6/mm/memory.c linux-2.6-patched/mm/memory.c
> --- linux-2.6/mm/memory.c	2006-09-01 12:50:24.000000000 +0200
> +++ linux-2.6-patched/mm/memory.c	2006-09-01 12:50:24.000000000 +0200
> @@ -2523,6 +2523,31 @@ int make_pages_present(unsigned long add
>  	BUG_ON(addr >= end);
>  	BUG_ON(end > vma->vm_end);
>  	len = (end+PAGE_SIZE-1)/PAGE_SIZE-addr/PAGE_SIZE;
> +
> +	if (page_host_discards() && (vma->vm_flags & VM_LOCKED)) {
> +		int rlen = len;
> +		ret = 0;
> +		while (rlen > 0) {
> +			struct page *page_refs[32];
> +			int chunk, cret, i;
> +
> +			chunk = rlen < 32 ? rlen : 32;
> +			cret = get_user_pages(current, current->mm, addr,
> +					      chunk, write, 0,
> +					      page_refs, NULL);
> +			if (cret > 0) {
> +				for (i = 0; i < cret; i++)
> +					page_cache_release(page_refs[i]);
> +				ret += cret;
> +			}
> +			if (cret < chunk)
> +				return ret ? : cret;
> +			addr += 32*PAGE_SIZE;
> +			rlen -= 32;
> +		}
> +		return ret == len ? 0 : -1;
> +	}
> +
>  	ret = get_user_pages(current, current->mm, addr,
>  			len, write, 0, NULL, NULL);
>  	if (ret < 0)
>   

This seems like a bit of unneeded complexity.  Since you've already 
changed get_user_pages, why not add a follow flag to release the page 
cache, and simply pass it to get_user_pages, instead of trying to fetch 
the page list back.  In particular, write and force arguments to 
get_user_pages look very ripe for combining into a flags field.  Sure, 
get_user_pages now has a bit more work to do, but it is already a 
monster, and I think it would keep make_page_present much cleaner.

Zach

Zach

WARNING: multiple messages have this Message-ID (diff)
From: Zachary Amsden <zach@vmware.com>
To: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: linux-kernel@vger.kernel.org, virtualization@lists.osdl.org,
	akpm@osdl.org, nickpiggin@yahoo.com.au, frankeh@watson.ibm.com,
	rhim@cc.gateh.edu
Subject: Re: [patch 5/9] Guest page hinting: mlocked pages.
Date: Wed, 13 Sep 2006 18:22:01 -0700	[thread overview]
Message-ID: <4508AEB9.4080409@vmware.com> (raw)
In-Reply-To: <20060901111022.GF15684@skybase>

Martin Schwidefsky wrote:
> diff -urpN linux-2.6/mm/memory.c linux-2.6-patched/mm/memory.c
> --- linux-2.6/mm/memory.c	2006-09-01 12:50:24.000000000 +0200
> +++ linux-2.6-patched/mm/memory.c	2006-09-01 12:50:24.000000000 +0200
> @@ -2523,6 +2523,31 @@ int make_pages_present(unsigned long add
>  	BUG_ON(addr >= end);
>  	BUG_ON(end > vma->vm_end);
>  	len = (end+PAGE_SIZE-1)/PAGE_SIZE-addr/PAGE_SIZE;
> +
> +	if (page_host_discards() && (vma->vm_flags & VM_LOCKED)) {
> +		int rlen = len;
> +		ret = 0;
> +		while (rlen > 0) {
> +			struct page *page_refs[32];
> +			int chunk, cret, i;
> +
> +			chunk = rlen < 32 ? rlen : 32;
> +			cret = get_user_pages(current, current->mm, addr,
> +					      chunk, write, 0,
> +					      page_refs, NULL);
> +			if (cret > 0) {
> +				for (i = 0; i < cret; i++)
> +					page_cache_release(page_refs[i]);
> +				ret += cret;
> +			}
> +			if (cret < chunk)
> +				return ret ? : cret;
> +			addr += 32*PAGE_SIZE;
> +			rlen -= 32;
> +		}
> +		return ret == len ? 0 : -1;
> +	}
> +
>  	ret = get_user_pages(current, current->mm, addr,
>  			len, write, 0, NULL, NULL);
>  	if (ret < 0)
>   

This seems like a bit of unneeded complexity.  Since you've already 
changed get_user_pages, why not add a follow flag to release the page 
cache, and simply pass it to get_user_pages, instead of trying to fetch 
the page list back.  In particular, write and force arguments to 
get_user_pages look very ripe for combining into a flags field.  Sure, 
get_user_pages now has a bit more work to do, but it is already a 
monster, and I think it would keep make_page_present much cleaner.

Zach

Zach

  reply	other threads:[~2006-09-14  1:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-01 11:10 [patch 5/9] Guest page hinting: mlocked pages Martin Schwidefsky
2006-09-14  1:22 ` Zachary Amsden [this message]
2006-09-14  1:22   ` Zachary Amsden
2006-09-14  8:59   ` Martin Schwidefsky
2006-09-14  8:59     ` Martin Schwidefsky
  -- strict thread matches above, loose matches on Subject: below --
2006-08-24 14:30 Martin Schwidefsky, Martin Schwidefsky, Hubertus Franke, Himanshu Raj

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=4508AEB9.4080409@vmware.com \
    --to=zach@vmware.com \
    --cc=akpm@osdl.org \
    --cc=frankeh@watson.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    --cc=rhim@cc.gateh.edu \
    --cc=schwidefsky@de.ibm.com \
    --cc=virtualization@lists.osdl.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.