From: chengang@emindsoft.com.cn
To: akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com
Cc: kirill.shutemov@linux.intel.com, mingo@kernel.org,
dave.hansen@linux.intel.com, dan.j.williams@intel.com,
hannes@cmpxchg.org, jack@suse.cz, iamjoonsoo.kim@lge.com,
jmarchan@redhat.com, dingel@linux.vnet.ibm.com, oleg@redhat.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Chen Gang <chengang@emindsoft.com.cn>,
Chen Gang <gang.chen.5i5j@gmail.com>
Subject: [PATCH] mm: gup: Re-define follow_page_mask output parameter page_mask usage
Date: Sun, 10 Jul 2016 01:17:05 +0800 [thread overview]
Message-ID: <1468084625-26999-1-git-send-email-chengang@emindsoft.com.cn> (raw)
From: Chen Gang <chengang@emindsoft.com.cn>
For a pure output parameter:
- When callee fails, the caller should not assume the output parameter
is still valid.
- And callee should not assume the pure output parameter must be
provided by caller -- caller has right to pass NULL when caller does
not care about it.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
include/linux/mm.h | 5 ++---
mm/gup.c | 6 +++---
mm/mlock.c | 2 +-
mm/nommu.c | 1 -
4 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index b21e5f3..5c560fd 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2205,10 +2205,9 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
unsigned int *page_mask);
static inline struct page *follow_page(struct vm_area_struct *vma,
- unsigned long address, unsigned int foll_flags)
+ unsigned long address, unsigned int foll_flags)
{
- unsigned int unused_page_mask;
- return follow_page_mask(vma, address, foll_flags, &unused_page_mask);
+ return follow_page_mask(vma, address, foll_flags, NULL);
}
#define FOLL_WRITE 0x01 /* check pte is writable */
diff --git a/mm/gup.c b/mm/gup.c
index 96b2b2f..9684b06 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -222,8 +222,6 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
struct page *page;
struct mm_struct *mm = vma->vm_mm;
- *page_mask = 0;
-
page = follow_huge_addr(mm, address, flags & FOLL_WRITE);
if (!IS_ERR(page)) {
BUG_ON(flags & FOLL_GET);
@@ -298,7 +296,8 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
page = follow_trans_huge_pmd(vma, address, pmd, flags);
spin_unlock(ptl);
- *page_mask = HPAGE_PMD_NR - 1;
+ if (page_mask)
+ *page_mask = HPAGE_PMD_NR - 1;
return page;
}
@@ -574,6 +573,7 @@ retry:
if (unlikely(fatal_signal_pending(current)))
return i ? i : -ERESTARTSYS;
cond_resched();
+ page_mask = 0;
page = follow_page_mask(vma, start, foll_flags, &page_mask);
if (!page) {
int ret;
diff --git a/mm/mlock.c b/mm/mlock.c
index ef8dc9f..626eb58 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -438,7 +438,7 @@ void munlock_vma_pages_range(struct vm_area_struct *vma,
while (start < end) {
struct page *page;
- unsigned int page_mask;
+ unsigned int page_mask = 0;
unsigned long page_increm;
struct pagevec pvec;
struct zone *zone;
diff --git a/mm/nommu.c b/mm/nommu.c
index 95daf81..c1a0a89 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1749,7 +1749,6 @@ struct page *follow_page_mask(struct vm_area_struct *vma,
unsigned long address, unsigned int flags,
unsigned int *page_mask)
{
- *page_mask = 0;
return NULL;
}
--
1.9.3
--
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 reply other threads:[~2016-07-09 17:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-09 17:17 chengang [this message]
2016-07-11 21:17 ` Andrew Morton
2016-07-12 17:03 ` Chen Gang
2016-07-13 7:50 ` Michal Hocko
2016-07-17 0:13 ` Chen Gang
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=1468084625-26999-1-git-send-email-chengang@emindsoft.com.cn \
--to=chengang@emindsoft.com.cn \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dingel@linux.vnet.ibm.com \
--cc=gang.chen.5i5j@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=iamjoonsoo.kim@lge.com \
--cc=jack@suse.cz \
--cc=jmarchan@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=vbabka@suse.cz \
/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