From: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: akpm@linux-foundation.org, riel@redhat.com,
linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH 6/6] Mlock: make mlock error return Posixly Correct
Date: Wed, 20 Aug 2008 12:24:01 -0400 [thread overview]
Message-ID: <1219249441.6075.14.camel@lts-notebook> (raw)
In-Reply-To: <20080820163559.12D9.KOSAKI.MOTOHIRO@jp.fujitsu.com>
On Wed, 2008-08-20 at 17:35 +0900, KOSAKI Motohiro wrote:
> > From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> >
> > Against: 2.6.27-rc3-mmotm-080816-0202
> >
> > Rework Posix error return for mlock().
> >
> > Translate get_user_pages() error to posix specified error codes.
> >
> > Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> > Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
> >
> > mm/memory.c | 2 +-
> > mm/mlock.c | 27 ++++++++++++++++++++++++---
> > 2 files changed, 25 insertions(+), 4 deletions(-)
> >
> > Index: linux-2.6.27-rc3-mmotm/mm/mlock.c
> > ===================================================================
> > --- linux-2.6.27-rc3-mmotm.orig/mm/mlock.c 2008-08-18 15:57:11.000000000 -0400
> > +++ linux-2.6.27-rc3-mmotm/mm/mlock.c 2008-08-18 15:57:39.000000000 -0400
> > @@ -143,6 +143,18 @@ static void munlock_vma_page(struct page
> > }
> > }
> >
> > +/*
> > + * convert get_user_pages() return value to posix mlock() error
> > + */
> > +static int __mlock_posix_error_return(long retval)
> > +{
> > + if (retval == -EFAULT)
> > + retval = -ENOMEM;
> > + else if (retval == -ENOMEM)
> > + retval = -EAGAIN;
> > + return retval;
> > +}
> > +
> > /**
> > * __mlock_vma_pages_range() - mlock/munlock a range of pages in the vma.
> > * @vma: target vma
> > @@ -209,8 +221,13 @@ static long __mlock_vma_pages_range(stru
> > * or for addresses that map beyond end of a file.
> > * We'll mlock the the pages if/when they get faulted in.
> > */
> > - if (ret < 0)
> > + if (ret < 0) {
> > + if (vma->vm_flags & VM_NONLINEAR)
> > + ret = 0;
> > + else
> > + ret = __mlock_posix_error_return(ret);
> > break;
> > + }
> > if (ret == 0) {
> > /*
> > * We know the vma is there, so the only time
>
> __mlock_vma_pages_range is used by mmap() and mlock().
>
> mlock case
>
> sys_mlock
> do_mlock
> mlock_fixup
> __mlock_vma_pages_range
>
> mmap case
>
> do_mmap_pgoff
> mmap_region
> mlock_vma_pages_range
> __mlock_vma_pages_range
>
>
> mlock() need error code if vma permission failure happend.
> but mmap() (and remap_pages_range(), etc..) should ignore it.
>
> So, mlock_vma_pages_range() should ignore __mlock_vma_pages_range()'s error code.
Well, I don't know whether we can trigger a vma permission failure
during mmap(MAP_LOCKED) or a remap within a VM_LOCKED vma, either of
which will end up calling mlock_vma_pages_range(). However, [after
rereading the man page] looks like we DO want to return any ENOMEM w/o
translating to EAGAIN. Guess that means I should do the translation
from within for mlock() from within mlock_fixup(). remap_pages_range()
probably wants to explicitly ignore any error from the mlock callout.
Will resend.
Thanks,
Lee
--
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>
next prev parent reply other threads:[~2008-08-20 16:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-19 21:05 [Patch 0/6] Mlock: doc, patch grouping and error return cleanups Lee Schermerhorn
2008-08-19 21:05 ` [PATCH 1/6] Mlock: fix __mlock_vma_pages_range comment block Lee Schermerhorn, KOSAKI Motohiro
2008-08-19 21:05 ` [PATCH 2/6] Mlock: backout locked_vm adjustment during mmap() Lee Schermerhorn, KOSAKI Motohiro
2008-08-19 21:05 ` [PATCH 3/6] Mlock: resubmit locked_vm adjustment as separate patch Lee Schermerhorn, Lee Schermerhorn
2008-08-19 21:05 ` [PATCH 4/6] Mlock: fix return value for munmap/mlock vma race Lee Schermerhorn, KOSAKI Motohiro
2008-08-20 8:31 ` KOSAKI Motohiro
2008-08-19 21:05 ` [PATCH 5/6] Mlock: revert mainline handling of mlock error return Lee Schermerhorn, Lee Schermerhorn
2008-08-20 7:20 ` KOSAKI Motohiro
2008-08-20 7:24 ` KOSAKI Motohiro
2008-08-19 21:05 ` [PATCH 6/6] Mlock: make mlock error return Posixly Correct Lee Schermerhorn, KOSAKI Motohiro
2008-08-20 8:35 ` KOSAKI Motohiro
2008-08-20 16:24 ` Lee Schermerhorn [this message]
2008-08-20 17:58 ` KOSAKI Motohiro
2008-08-20 19:04 ` Lee Schermerhorn
2008-08-22 20:48 ` Lee Schermerhorn
2008-08-20 10:17 ` Pekka Enberg
2008-08-20 16:26 ` Lee Schermerhorn
2008-08-20 7:21 ` [Patch 0/6] Mlock: doc, patch grouping and error return cleanups KOSAKI Motohiro
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=1219249441.6075.14.camel@lts-notebook \
--to=lee.schermerhorn@hp.com \
--cc=akpm@linux-foundation.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=riel@redhat.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