linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mel@csn.ul.ie>
To: Alexey Korolev <akorolex@gmail.com>
Cc: linux-mm@kvack.org, greg@kroah.com, vijaykumar@bravegnu.org
Subject: Re: Inconsistency (bug) of vm_insert_page with high order allocations
Date: Tue, 2 Jun 2009 09:38:52 +0100	[thread overview]
Message-ID: <20090602083852.GC5960@csn.ul.ie> (raw)
In-Reply-To: <202cde0e0905292227tc619a17h41df83d22bc922fa@mail.gmail.com>

On Sat, May 30, 2009 at 05:27:15PM +1200, Alexey Korolev wrote:
> Hi,
> >> To allocate memory I use standard function alloc_apges(gfp_mask,
> >> order) which asks buddy allocator to give a chunk of memory of given
> >> "order".
> >> Allocator returns page and also sets page count to 1 but for page of
> >> high order. I.e. pages 2,3 etc inside high order allocation will have
> >> page->_count==0.
> >> If I try to mmap allocated area to user space vm_insert_page will
> >> return error as pages 2,3, etc are not refcounted.
> >>
> >
> > page = alloc_pages(high_order);
> > split_page(page, high_order);
> >
> > That will fix up the ref-counting of each of the individual pages. You are
> > then responsible for freeing them individually. As you are inserting these
> > into userspace, I suspect that's ok.
> 
> It seems it is the only way I have now. It is not so elegant - but should work.
> Thanks for good advise.
> 
> BTW: Just out of curiosity what limits mapping high ordered pages into
> user space. I tried to find any except the check in vm_insert but
> failed. Is this checks caused by possible swapping?
> 

Nothing limits it as such other than it's usually not required. There is
nothing really that special about high-order pages other than they are
physically contiguous. The expectation is normally that userspace does
not care about physical contiguity.

There is expected to be a 1 to 1 mapping of PTE to ref-counted pages so that
they get freed at the right times so it's not just about swapping.

-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-06-03 16:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-28  5:07 Alexey Korolev
     [not found] ` <20090528143524.e8a2cde7.kamezawa.hiroyu@jp.fujitsu.com>
2009-05-28  7:02   ` Alexey Korolev
     [not found]     ` <20090528162108.a6adcc36.kamezawa.hiroyu@jp.fujitsu.com>
2009-05-30  5:42       ` Alexey Korolev
2009-06-01 23:53         ` KAMEZAWA Hiroyuki
2009-05-28  9:59 ` Mel Gorman
2009-05-30  5:27   ` Alexey Korolev
2009-06-02  8:38     ` Mel Gorman [this message]
2009-06-03  5:58       ` Alexey Korolev

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=20090602083852.GC5960@csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=akorolex@gmail.com \
    --cc=greg@kroah.com \
    --cc=linux-mm@kvack.org \
    --cc=vijaykumar@bravegnu.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