From: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: linux-mm <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
Rik van Riel <riel@redhat.com>
Subject: Re: [RFC PATCH for -mm 5/5] fix mlock return value for mm
Date: Tue, 12 Aug 2008 16:30:14 -0400 [thread overview]
Message-ID: <1218573014.6360.131.camel@lts-notebook> (raw)
In-Reply-To: <20080811163121.9468.KOSAKI.MOTOHIRO@jp.fujitsu.com>
On Mon, 2008-08-11 at 16:43 +0900, KOSAKI Motohiro wrote:
> > Now, __mlock_vma_pages_range() ignore return value of __get_user_pages().
> > We shouldn't do that.
>
> Oops, sorry.
> I sent older version, I resend it.
>
> Definitly, I should learn an correct operation of quilt ;)
>
>
> --------------------------------------------------------------
> Now, __mlock_vma_pages_range() ignore return value of __get_user_pages().
> We shouldn't do that.
Could you explain, in comments or patch description, why, after patching
__mlock_vma_pages_range() top return mlock() appropriate values for
__get_user_pages() failures, you then ignore the return value of
__mlock_vma_pages_range() in mlock_vma_pages_range() [last 4 hunks]? Is
it because mlock_vma_pages_range() is called from mmap(), mremap(), etc,
and not from mlock()?
Lee
>
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>
> ---
> mm/mlock.c | 32 ++++++++++++++++++++++++--------
> 1 file changed, 24 insertions(+), 8 deletions(-)
>
> Index: b/mm/mlock.c
> ===================================================================
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -165,8 +165,9 @@ static int __mlock_vma_pages_range(struc
> unsigned long addr = start;
> struct page *pages[16]; /* 16 gives a reasonable batch */
> int nr_pages = (end - start) / PAGE_SIZE;
> - int ret;
> + int ret = 0;
> int gup_flags = 0;
> + int ret2 = 0;
>
> VM_BUG_ON(start & ~PAGE_MASK);
> VM_BUG_ON(end & ~PAGE_MASK);
> @@ -249,9 +250,23 @@ static int __mlock_vma_pages_range(struc
> }
> }
>
> + /*
> + SUSv3 require following return value to mlock
> + - invalid addr generate to ENOMEM.
> + - out of memory generate EAGAIN.
> + */
> + if (ret < 0) {
> + if (ret == -EFAULT)
> + ret2 = -ENOMEM;
> + else if (ret == -ENOMEM)
> + ret2 = -EAGAIN;
> + else
> + ret2 = ret;
> + }
> +
> lru_add_drain_all(); /* to update stats */
>
> - return 0; /* count entire vma as locked_vm */
> + return ret2; /* count entire vma as locked_vm */
> }
>
> #else /* CONFIG_UNEVICTABLE_LRU */
> @@ -263,9 +278,11 @@ static int __mlock_vma_pages_range(struc
> unsigned long start, unsigned long end,
> int mlock)
> {
> + int ret = 0;
> +
> if (mlock && (vma->vm_flags & VM_LOCKED))
> - make_pages_present(start, end);
> - return 0;
> + ret = make_pages_present(start, end);
> + return ret;
> }
> #endif /* CONFIG_UNEVICTABLE_LRU */
>
> @@ -276,7 +293,6 @@ int mlock_vma_pages_range(struct vm_area
> unsigned long start, unsigned long end)
> {
> struct mm_struct *mm = vma->vm_mm;
> - int error = 0;
> BUG_ON(!(vma->vm_flags & VM_LOCKED));
>
> /*
> @@ -289,7 +305,7 @@ int mlock_vma_pages_range(struct vm_area
> is_vm_hugetlb_page(vma) ||
> vma == get_gate_vma(current))) {
> downgrade_write(&mm->mmap_sem);
> - error = __mlock_vma_pages_range(vma, start, end, 1);
> + __mlock_vma_pages_range(vma, start, end, 1);
> up_read(&mm->mmap_sem);
> /* vma can change or disappear */
> down_write(&mm->mmap_sem);
> @@ -297,7 +313,7 @@ int mlock_vma_pages_range(struct vm_area
> /* non-NULL vma must contain @start, but need to check @end */
> if (!vma || end > vma->vm_end)
> return -ENOMEM;
> - return error;
> + return 0;
> }
>
> /*
> @@ -309,7 +325,7 @@ int mlock_vma_pages_range(struct vm_area
>
> no_mlock:
> vma->vm_flags &= ~VM_LOCKED; /* and don't come back! */
> - return error; /* pages NOT mlocked */
> + return 0; /* pages NOT mlocked */
> }
>
>
>
>
>
--
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-12 20:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-11 7:01 [RFC PATCH for -mm 0/5] mlock return value rework KOSAKI Motohiro
2008-08-11 7:04 ` [RFC PATCH for -mm 1/5] mlock() fix return values for mainline KOSAKI Motohiro
2008-08-12 20:39 ` Lee Schermerhorn
2008-08-13 8:03 ` KOSAKI Motohiro
2008-08-11 7:05 ` [RFC PATCH for -mm 2/5] related function comment fixes (optional) KOSAKI Motohiro
2008-08-12 19:02 ` Lee Schermerhorn
2008-08-13 8:37 ` KOSAKI Motohiro
2008-08-11 7:06 ` [RFC PATCH for -mm 3/5] kill unnecessary locked_vm adjustment KOSAKI Motohiro
2008-08-12 19:55 ` Lee Schermerhorn
2008-08-13 9:37 ` KOSAKI Motohiro
2008-08-15 13:54 ` Lee Schermerhorn
2008-08-18 9:23 ` KOSAKI Motohiro
2008-08-18 20:56 ` Lee Schermerhorn
2008-08-11 7:07 ` [RFC PATCH for -mm 4/5] fix mlock return value at munmap race KOSAKI Motohiro
2008-08-12 20:19 ` Lee Schermerhorn
2008-08-11 7:08 ` [RFC PATCH for -mm 5/5] fix mlock return value for mm KOSAKI Motohiro
2008-08-11 7:43 ` KOSAKI Motohiro
2008-08-12 20:30 ` Lee Schermerhorn [this message]
2008-08-13 8:36 ` 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=1218573014.6360.131.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