Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1181762
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 1/3] mm: introduce vma_is_anonymous(vma) helper |
| Date | 2015-07-10 19:00 +0200 |
| Message-ID | <pKJOA-8s9-45@gated-at.bofh.it> (permalink) |
| References | <pKJOy-8s9-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Preparation. Add the new simple helper, vma_is_anonymous(vma), and
change handle_pte_fault() to use it. It will have more users.
The name is not accurate, say a hpet_mmap()'ed vma is not anonymous.
Perhaps it should be named vma_has_fault() instead. But it matches
the logic in mmap.c/memory.c (see next changes). "True" just means
that a page fault will use do_anonymous_page().
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
include/linux/mm.h | 5 +++++
mm/memory.c | 8 ++++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0755b9f..0207ffa 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1225,6 +1225,11 @@ static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
}
+static inline bool vma_is_anonymous(struct vm_area_struct *vma)
+{
+ return !vma->vm_ops;
+}
+
static inline int stack_guard_page_start(struct vm_area_struct *vma,
unsigned long addr)
{
diff --git a/mm/memory.c b/mm/memory.c
index 2a9e098..87c9285 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3249,12 +3249,12 @@ static int handle_pte_fault(struct mm_struct *mm,
barrier();
if (!pte_present(entry)) {
if (pte_none(entry)) {
- if (vma->vm_ops)
+ if (vma_is_anonymous(vma))
+ return do_anonymous_page(mm, vma, address,
+ pte, pmd, flags);
+ else
return do_fault(mm, vma, address, pte, pmd,
flags, entry);
-
- return do_anonymous_page(mm, vma, address, pte, pmd,
- flags);
}
return do_swap_page(mm, vma, address,
pte, pmd, flags, entry);
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/3] special_mapping_fault() is broken Oleg Nesterov <oleg@redhat.com> - 2015-07-10 19:00 +0200 [PATCH v2 2/3] mmap: fix the usage of ->vm_pgoff in special_mapping paths Oleg Nesterov <oleg@redhat.com> - 2015-07-10 19:00 +0200 [PATCH v2 3/3] mremap: fix the wrong !vma->vm_file check in copy_vma() Oleg Nesterov <oleg@redhat.com> - 2015-07-10 19:00 +0200 [PATCH v2 1/3] mm: introduce vma_is_anonymous(vma) helper Oleg Nesterov <oleg@redhat.com> - 2015-07-10 19:00 +0200 Re: [PATCH v2 0/3] special_mapping_fault() is broken "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-07-10 19:10 +0200
csiph-web