From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: linux-mm <linux-mm@kvack.org>,
Andrew Morton <akpm@linux-foundation.org>,
Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
Rik van Riel <riel@redhat.com>
Cc: kosaki.motohiro@jp.fujitsu.com
Subject: [RFC PATCH for -mm 3/5] kill unnecessary locked_vm adjustment
Date: Mon, 11 Aug 2008 16:06:37 +0900 [thread overview]
Message-ID: <20080811160542.945F.KOSAKI.MOTOHIRO@jp.fujitsu.com> (raw)
In-Reply-To: <20080811151313.9456.KOSAKI.MOTOHIRO@jp.fujitsu.com>
Now, __mlock_vma_pages_range never return positive value.
So, locked_vm adjustment code is unnecessary.
also, related comment fixed.
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
mm/mlock.c | 18 +++++-------------
mm/mmap.c | 10 +++++-----
2 files changed, 10 insertions(+), 18 deletions(-)
Index: b/mm/mlock.c
===================================================================
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -276,7 +276,7 @@ int mlock_vma_pages_range(struct vm_area
unsigned long start, unsigned long end)
{
struct mm_struct *mm = vma->vm_mm;
- int nr_pages = (end - start) / PAGE_SIZE;
+ int error = 0;
BUG_ON(!(vma->vm_flags & VM_LOCKED));
/*
@@ -289,8 +289,7 @@ int mlock_vma_pages_range(struct vm_area
is_vm_hugetlb_page(vma) ||
vma == get_gate_vma(current))) {
downgrade_write(&mm->mmap_sem);
- nr_pages = __mlock_vma_pages_range(vma, start, end, 1);
-
+ error = __mlock_vma_pages_range(vma, start, end, 1);
up_read(&mm->mmap_sem);
/* vma can change or disappear */
down_write(&mm->mmap_sem);
@@ -298,22 +297,19 @@ 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 -EAGAIN;
- return nr_pages;
+ return error;
}
/*
* User mapped kernel pages or huge pages:
* make these pages present to populate the ptes, but
- * fall thru' to reset VM_LOCKED--no need to unlock, and
- * return nr_pages so these don't get counted against task's
- * locked limit. huge pages are already counted against
- * locked vm limit.
+ * fall thru' to reset VM_LOCKED--no need to unlock.
*/
make_pages_present(start, end);
no_mlock:
vma->vm_flags &= ~VM_LOCKED; /* and don't come back! */
- return nr_pages; /* pages NOT mlocked */
+ return error; /* pages NOT mlocked */
}
@@ -402,10 +398,6 @@ success:
downgrade_write(&mm->mmap_sem);
ret = __mlock_vma_pages_range(vma, start, end, 1);
- if (ret > 0) {
- mm->locked_vm -= ret;
- ret = 0;
- }
/*
* Need to reacquire mmap sem in write mode, as our callers
* expect this. We have no support for atomically upgrading
Index: b/mm/mmap.c
===================================================================
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1229,10 +1229,10 @@ out:
/*
* makes pages present; downgrades, drops, reacquires mmap_sem
*/
- int nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
- if (nr_pages < 0)
- return nr_pages; /* vma gone! */
- mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
+ int error = mlock_vma_pages_range(vma, addr, addr + len);
+ if (error < 0)
+ return error; /* vma gone! */
+ mm->locked_vm += (len >> PAGE_SHIFT);
} else if ((flags & MAP_POPULATE) && !(flags & MAP_NONBLOCK))
make_pages_present(addr, addr + len);
return addr;
@@ -2087,7 +2087,7 @@ out:
if (flags & VM_LOCKED) {
int nr_pages = mlock_vma_pages_range(vma, addr, addr + len);
if (nr_pages >= 0)
- mm->locked_vm += (len >> PAGE_SHIFT) - nr_pages;
+ mm->locked_vm += (len >> PAGE_SHIFT);
}
return addr;
undo_charge:
--
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-11 7:06 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 ` KOSAKI Motohiro [this message]
2008-08-12 19:55 ` [RFC PATCH for -mm 3/5] kill unnecessary locked_vm adjustment 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
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=20080811160542.945F.KOSAKI.MOTOHIRO@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=Lee.Schermerhorn@hp.com \
--cc=akpm@linux-foundation.org \
--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