summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorKonstantin Khlebnikov <koct9i@gmail.com>2016-02-02 16:57:46 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-02-03 08:28:43 -0800
commit30bdbb78009e67767983085e302bec6d97afc679 (patch)
tree8d4084215738d98a6eed66cd7e971e9cca5f279a /mm
parentd977d56ce5b3e8842236f2f9e7483d4914c9592e (diff)
downloadlinux-30bdbb78009e67767983085e302bec6d97afc679.tar.bz2
mm: polish virtual memory accounting
* add VM_STACK as alias for VM_GROWSUP/DOWN depending on architecture * always account VMAs with flag VM_STACK as stack (as it was before) * cleanup classifying helpers * update comments and documentation Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com> Tested-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com> Cc: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/internal.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/mm/internal.h b/mm/internal.h
index 6e976302ddd8..a38a21ebddb4 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -216,20 +216,35 @@ static inline bool is_cow_mapping(vm_flags_t flags)
return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
}
+/*
+ * These three helpers classifies VMAs for virtual memory accounting.
+ */
+
+/*
+ * Executable code area - executable, not writable, not stack
+ */
static inline bool is_exec_mapping(vm_flags_t flags)
{
- return (flags & (VM_EXEC | VM_WRITE)) == VM_EXEC;
+ return (flags & (VM_EXEC | VM_WRITE | VM_STACK)) == VM_EXEC;
}
+/*
+ * Stack area - atomatically grows in one direction
+ *
+ * VM_GROWSUP / VM_GROWSDOWN VMAs are always private anonymous:
+ * do_mmap() forbids all other combinations.
+ */
static inline bool is_stack_mapping(vm_flags_t flags)
{
- return (flags & (VM_STACK_FLAGS & (VM_GROWSUP | VM_GROWSDOWN))) != 0;
+ return (flags & VM_STACK) == VM_STACK;
}
+/*
+ * Data area - private, writable, not stack
+ */
static inline bool is_data_mapping(vm_flags_t flags)
{
- return (flags & ((VM_STACK_FLAGS & (VM_GROWSUP | VM_GROWSDOWN)) |
- VM_WRITE | VM_SHARED)) == VM_WRITE;
+ return (flags & (VM_WRITE | VM_SHARED | VM_STACK)) == VM_WRITE;
}
/* mm/util.c */