All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-21  6:56 ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel

There is good old tradition: every year somebody submit patches for extending
vma->vm_flags upto 64-bits, because there no free bits left on 32-bit systems.

previous attempts:
https://lkml.org/lkml/2011/4/12/24	(KOSAKI Motohiro)
https://lkml.org/lkml/2010/4/27/23	(Benjamin Herrenschmidt)
https://lkml.org/lkml/2009/10/1/202	(Hugh Dickins)

Here already exist special type for this: vm_flags_t, but not all code uses it.
So, before switching vm_flags_t from unsinged long to u64 we must spread
vm_flags_t everywhere and fix all possible type-casting problems.

There is no functional changes in this patch set,
it only prepares code for vma->vm_flags converting.

---

Konstantin Khlebnikov (16):
      mm: introduce NR_VMA_FLAGS
      mm: use vm_flags_t for vma flags
      mm/shmem: use vm_flags_t for vma flags
      mm/nommu: use vm_flags_t for vma flags
      mm/drivers: use vm_flags_t for vma flags
      mm/x86: use vm_flags_t for vma flags
      mm/arm: use vm_flags_t for vma flags
      mm/unicore32: use vm_flags_t for vma flags
      mm/ia64: use vm_flags_t for vma flags
      mm/powerpc: use vm_flags_t for vma flags
      mm/s390: use vm_flags_t for vma flags
      mm/mips: use vm_flags_t for vma flags
      mm/parisc: use vm_flags_t for vma flags
      mm/score: use vm_flags_t for vma flags
      mm: cast vm_flags_t to u64 before printing
      mm: vm_flags_t strict type checking


 arch/arm/include/asm/cacheflush.h                |    5 -
 arch/arm/kernel/asm-offsets.c                    |    6 +
 arch/arm/mm/fault.c                              |    2 
 arch/ia64/mm/fault.c                             |    9 +
 arch/mips/mm/c-r3k.c                             |    2 
 arch/mips/mm/c-r4k.c                             |    6 -
 arch/mips/mm/c-tx39.c                            |    2 
 arch/parisc/mm/fault.c                           |    4 -
 arch/powerpc/include/asm/mman.h                  |    2 
 arch/s390/mm/fault.c                             |    8 +
 arch/score/mm/cache.c                            |    6 -
 arch/sh/mm/tlbflush_64.c                         |    2 
 arch/unicore32/kernel/asm-offsets.c              |    6 +
 arch/unicore32/mm/fault.c                        |    2 
 arch/x86/mm/hugetlbpage.c                        |    4 -
 drivers/char/mem.c                               |    2 
 drivers/infiniband/hw/ipath/ipath_file_ops.c     |    6 +
 drivers/infiniband/hw/qib/qib_file_ops.c         |    6 +
 drivers/media/video/omap3isp/ispqueue.h          |    2 
 drivers/staging/android/ashmem.c                 |    2 
 drivers/staging/android/binder.c                 |   15 +-
 drivers/staging/tidspbridge/core/tiomap3430.c    |   13 +-
 drivers/staging/tidspbridge/rmgr/drv_interface.c |    4 -
 fs/binfmt_elf.c                                  |    2 
 fs/binfmt_elf_fdpic.c                            |   24 ++-
 fs/exec.c                                        |    2 
 fs/proc/nommu.c                                  |    3 
 fs/proc/task_nommu.c                             |   14 +-
 include/linux/backing-dev.h                      |    7 -
 include/linux/huge_mm.h                          |    4 -
 include/linux/ksm.h                              |    8 +
 include/linux/mm.h                               |  163 +++++++++++++++-------
 include/linux/mm_types.h                         |   11 +
 include/linux/mman.h                             |    4 -
 include/linux/rmap.h                             |    8 +
 include/linux/shmem_fs.h                         |    5 -
 kernel/bounds.c                                  |    2 
 kernel/events/core.c                             |    4 -
 kernel/fork.c                                    |    2 
 kernel/sys.c                                     |    4 -
 mm/backing-dev.c                                 |    4 +
 mm/huge_memory.c                                 |    2 
 mm/ksm.c                                         |    4 -
 mm/madvise.c                                     |    2 
 mm/memory.c                                      |    9 +
 mm/mlock.c                                       |    2 
 mm/mmap.c                                        |   36 ++---
 mm/mprotect.c                                    |    9 +
 mm/mremap.c                                      |    2 
 mm/nommu.c                                       |   19 +--
 mm/rmap.c                                        |   16 +-
 mm/shmem.c                                       |   54 ++++---
 mm/vmscan.c                                      |    4 -
 53 files changed, 322 insertions(+), 224 deletions(-)

-- 
Signature

^ permalink raw reply	[flat|nested] 104+ messages in thread

* [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-21  6:56 ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel

There is good old tradition: every year somebody submit patches for extending
vma->vm_flags upto 64-bits, because there no free bits left on 32-bit systems.

previous attempts:
https://lkml.org/lkml/2011/4/12/24	(KOSAKI Motohiro)
https://lkml.org/lkml/2010/4/27/23	(Benjamin Herrenschmidt)
https://lkml.org/lkml/2009/10/1/202	(Hugh Dickins)

Here already exist special type for this: vm_flags_t, but not all code uses it.
So, before switching vm_flags_t from unsinged long to u64 we must spread
vm_flags_t everywhere and fix all possible type-casting problems.

There is no functional changes in this patch set,
it only prepares code for vma->vm_flags converting.

---

Konstantin Khlebnikov (16):
      mm: introduce NR_VMA_FLAGS
      mm: use vm_flags_t for vma flags
      mm/shmem: use vm_flags_t for vma flags
      mm/nommu: use vm_flags_t for vma flags
      mm/drivers: use vm_flags_t for vma flags
      mm/x86: use vm_flags_t for vma flags
      mm/arm: use vm_flags_t for vma flags
      mm/unicore32: use vm_flags_t for vma flags
      mm/ia64: use vm_flags_t for vma flags
      mm/powerpc: use vm_flags_t for vma flags
      mm/s390: use vm_flags_t for vma flags
      mm/mips: use vm_flags_t for vma flags
      mm/parisc: use vm_flags_t for vma flags
      mm/score: use vm_flags_t for vma flags
      mm: cast vm_flags_t to u64 before printing
      mm: vm_flags_t strict type checking


 arch/arm/include/asm/cacheflush.h                |    5 -
 arch/arm/kernel/asm-offsets.c                    |    6 +
 arch/arm/mm/fault.c                              |    2 
 arch/ia64/mm/fault.c                             |    9 +
 arch/mips/mm/c-r3k.c                             |    2 
 arch/mips/mm/c-r4k.c                             |    6 -
 arch/mips/mm/c-tx39.c                            |    2 
 arch/parisc/mm/fault.c                           |    4 -
 arch/powerpc/include/asm/mman.h                  |    2 
 arch/s390/mm/fault.c                             |    8 +
 arch/score/mm/cache.c                            |    6 -
 arch/sh/mm/tlbflush_64.c                         |    2 
 arch/unicore32/kernel/asm-offsets.c              |    6 +
 arch/unicore32/mm/fault.c                        |    2 
 arch/x86/mm/hugetlbpage.c                        |    4 -
 drivers/char/mem.c                               |    2 
 drivers/infiniband/hw/ipath/ipath_file_ops.c     |    6 +
 drivers/infiniband/hw/qib/qib_file_ops.c         |    6 +
 drivers/media/video/omap3isp/ispqueue.h          |    2 
 drivers/staging/android/ashmem.c                 |    2 
 drivers/staging/android/binder.c                 |   15 +-
 drivers/staging/tidspbridge/core/tiomap3430.c    |   13 +-
 drivers/staging/tidspbridge/rmgr/drv_interface.c |    4 -
 fs/binfmt_elf.c                                  |    2 
 fs/binfmt_elf_fdpic.c                            |   24 ++-
 fs/exec.c                                        |    2 
 fs/proc/nommu.c                                  |    3 
 fs/proc/task_nommu.c                             |   14 +-
 include/linux/backing-dev.h                      |    7 -
 include/linux/huge_mm.h                          |    4 -
 include/linux/ksm.h                              |    8 +
 include/linux/mm.h                               |  163 +++++++++++++++-------
 include/linux/mm_types.h                         |   11 +
 include/linux/mman.h                             |    4 -
 include/linux/rmap.h                             |    8 +
 include/linux/shmem_fs.h                         |    5 -
 kernel/bounds.c                                  |    2 
 kernel/events/core.c                             |    4 -
 kernel/fork.c                                    |    2 
 kernel/sys.c                                     |    4 -
 mm/backing-dev.c                                 |    4 +
 mm/huge_memory.c                                 |    2 
 mm/ksm.c                                         |    4 -
 mm/madvise.c                                     |    2 
 mm/memory.c                                      |    9 +
 mm/mlock.c                                       |    2 
 mm/mmap.c                                        |   36 ++---
 mm/mprotect.c                                    |    9 +
 mm/mremap.c                                      |    2 
 mm/nommu.c                                       |   19 +--
 mm/rmap.c                                        |   16 +-
 mm/shmem.c                                       |   54 ++++---
 mm/vmscan.c                                      |    4 -
 53 files changed, 322 insertions(+), 224 deletions(-)

-- 
Signature

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* [PATCH 01/16] mm: introduce NR_VMA_FLAGS
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Hugh Dickins, linux-kernel, KOSAKI Motohiro,
	Benjamin Herrenschmidt

This patch adds NR_VMA_FLAGS constant into generated/bounds.h
and switch type of vm_flags_t depending on it.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h       |    8 ++++++++
 include/linux/mm_types.h |    5 +++++
 kernel/bounds.c          |    2 ++
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5b29b4f..69915a2 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4,6 +4,7 @@
 #include <linux/errno.h>
 
 #ifdef __KERNEL__
+#ifndef __GENERATING_BOUNDS_H
 
 #include <linux/gfp.h>
 #include <linux/bug.h>
@@ -67,6 +68,8 @@ extern struct rw_semaphore nommu_region_sem;
 extern unsigned int kobjsize(const void *objp);
 #endif
 
+#endif /* __GENERATING_BOUNDS_H */
+
 /*
  * vm_flags in vm_area_struct, see mm_types.h.
  */
@@ -120,6 +123,10 @@ extern unsigned int kobjsize(const void *objp);
 #define VM_PFN_AT_MMAP	0x40000000	/* PFNMAP vma that is fully mapped at mmap time */
 #define VM_MERGEABLE	0x80000000	/* KSM may merge identical pages */
 
+#define __NR_VMA_FLAGS	32
+
+#ifndef __GENERATING_BOUNDS_H
+
 /* Bits set in the VMA until the stack is in its final location */
 #define VM_STACK_INCOMPLETE_SETUP	(VM_RAND_READ | VM_SEQ_READ)
 
@@ -1642,5 +1649,6 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
 static inline bool page_is_guard(struct page *page) { return false; }
 #endif /* CONFIG_DEBUG_PAGEALLOC */
 
+#endif /* __GENERATING_BOUNDS_H */
 #endif /* __KERNEL__ */
 #endif /* _LINUX_MM_H */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 76bbdaf..3aeb8f6 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -12,6 +12,7 @@
 #include <linux/completion.h>
 #include <linux/cpumask.h>
 #include <linux/page-debug-flags.h>
+#include <generated/bounds.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
 
@@ -170,7 +171,11 @@ struct page_frag {
 #endif
 };
 
+#if (NR_VMA_FLAGS > 32)
+typedef unsigned long long __nocast vm_flags_t;
+#else
 typedef unsigned long __nocast vm_flags_t;
+#endif
 
 /*
  * A region containing a mapping of a non-memory backed file under NOMMU
diff --git a/kernel/bounds.c b/kernel/bounds.c
index 0c9b862..6d2732f 100644
--- a/kernel/bounds.c
+++ b/kernel/bounds.c
@@ -7,6 +7,7 @@
 #define __GENERATING_BOUNDS_H
 /* Include headers that define the enum constants of interest */
 #include <linux/page-flags.h>
+#include <linux/mm.h>
 #include <linux/mmzone.h>
 #include <linux/kbuild.h>
 #include <linux/page_cgroup.h>
@@ -15,6 +16,7 @@ void foo(void)
 {
 	/* The enum constants to put into include/generated/bounds.h */
 	DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS);
+	DEFINE(NR_VMA_FLAGS, __NR_VMA_FLAGS);
 	DEFINE(MAX_NR_ZONES, __MAX_NR_ZONES);
 	DEFINE(NR_PCG_FLAGS, __NR_PCG_FLAGS);
 	/* End of constants */


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 01/16] mm: introduce NR_VMA_FLAGS
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Hugh Dickins, linux-kernel, KOSAKI Motohiro,
	Benjamin Herrenschmidt

This patch adds NR_VMA_FLAGS constant into generated/bounds.h
and switch type of vm_flags_t depending on it.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h       |    8 ++++++++
 include/linux/mm_types.h |    5 +++++
 kernel/bounds.c          |    2 ++
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 5b29b4f..69915a2 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -4,6 +4,7 @@
 #include <linux/errno.h>
 
 #ifdef __KERNEL__
+#ifndef __GENERATING_BOUNDS_H
 
 #include <linux/gfp.h>
 #include <linux/bug.h>
@@ -67,6 +68,8 @@ extern struct rw_semaphore nommu_region_sem;
 extern unsigned int kobjsize(const void *objp);
 #endif
 
+#endif /* __GENERATING_BOUNDS_H */
+
 /*
  * vm_flags in vm_area_struct, see mm_types.h.
  */
@@ -120,6 +123,10 @@ extern unsigned int kobjsize(const void *objp);
 #define VM_PFN_AT_MMAP	0x40000000	/* PFNMAP vma that is fully mapped at mmap time */
 #define VM_MERGEABLE	0x80000000	/* KSM may merge identical pages */
 
+#define __NR_VMA_FLAGS	32
+
+#ifndef __GENERATING_BOUNDS_H
+
 /* Bits set in the VMA until the stack is in its final location */
 #define VM_STACK_INCOMPLETE_SETUP	(VM_RAND_READ | VM_SEQ_READ)
 
@@ -1642,5 +1649,6 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
 static inline bool page_is_guard(struct page *page) { return false; }
 #endif /* CONFIG_DEBUG_PAGEALLOC */
 
+#endif /* __GENERATING_BOUNDS_H */
 #endif /* __KERNEL__ */
 #endif /* _LINUX_MM_H */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 76bbdaf..3aeb8f6 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -12,6 +12,7 @@
 #include <linux/completion.h>
 #include <linux/cpumask.h>
 #include <linux/page-debug-flags.h>
+#include <generated/bounds.h>
 #include <asm/page.h>
 #include <asm/mmu.h>
 
@@ -170,7 +171,11 @@ struct page_frag {
 #endif
 };
 
+#if (NR_VMA_FLAGS > 32)
+typedef unsigned long long __nocast vm_flags_t;
+#else
 typedef unsigned long __nocast vm_flags_t;
+#endif
 
 /*
  * A region containing a mapping of a non-memory backed file under NOMMU
diff --git a/kernel/bounds.c b/kernel/bounds.c
index 0c9b862..6d2732f 100644
--- a/kernel/bounds.c
+++ b/kernel/bounds.c
@@ -7,6 +7,7 @@
 #define __GENERATING_BOUNDS_H
 /* Include headers that define the enum constants of interest */
 #include <linux/page-flags.h>
+#include <linux/mm.h>
 #include <linux/mmzone.h>
 #include <linux/kbuild.h>
 #include <linux/page_cgroup.h>
@@ -15,6 +16,7 @@ void foo(void)
 {
 	/* The enum constants to put into include/generated/bounds.h */
 	DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS);
+	DEFINE(NR_VMA_FLAGS, __NR_VMA_FLAGS);
 	DEFINE(MAX_NR_ZONES, __MAX_NR_ZONES);
 	DEFINE(NR_PCG_FLAGS, __NR_PCG_FLAGS);
 	/* End of constants */

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 02/16] mm: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Hugh Dickins, linux-kernel, KOSAKI Motohiro,
	Benjamin Herrenschmidt

* switch type of vma->vm_flags and mm->def_flags to vm_flags_t
* introduce new constant "VM_NONE", as equivalent of zero vm_flags state
* spread vm_flags_t in the generic mm code
* fix dangerous type-casts (like int exec = vma->vm_flags & VM_EXEC)
* convert BDI_CAP_*_MAP consistency checks into BUILD_BUG_ON()

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
---
 drivers/char/mem.c          |    2 +-
 fs/binfmt_elf.c             |    2 +-
 fs/exec.c                   |    2 +-
 include/linux/backing-dev.h |    7 -------
 include/linux/huge_mm.h     |    4 ++--
 include/linux/ksm.h         |    8 ++++----
 include/linux/mm.h          |   23 +++++++++++++----------
 include/linux/mm_types.h    |    4 ++--
 include/linux/mman.h        |    4 ++--
 include/linux/rmap.h        |    8 ++++----
 kernel/events/core.c        |    4 ++--
 kernel/fork.c               |    2 +-
 kernel/sys.c                |    4 ++--
 mm/backing-dev.c            |    4 ++++
 mm/huge_memory.c            |    2 +-
 mm/ksm.c                    |    4 ++--
 mm/madvise.c                |    2 +-
 mm/memory.c                 |    4 ++--
 mm/mlock.c                  |    2 +-
 mm/mmap.c                   |   36 ++++++++++++++++++------------------
 mm/mprotect.c               |    9 +++++----
 mm/mremap.c                 |    2 +-
 mm/rmap.c                   |   16 +++++++---------
 mm/vmscan.c                 |    4 ++--
 24 files changed, 79 insertions(+), 80 deletions(-)

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index d6e9d08..60a6e34 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -280,7 +280,7 @@ static unsigned long get_unmapped_area_mem(struct file *file,
 /* can't do an in-place private mapping if there's no MMU */
 static inline int private_mapping_ok(struct vm_area_struct *vma)
 {
-	return vma->vm_flags & VM_MAYSHARE;
+	return (vma->vm_flags & VM_MAYSHARE) != VM_NONE;
 }
 #else
 #define get_unmapped_area_mem	NULL
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 2be0d74..dce9c93 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -572,7 +572,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
 	unsigned long start_code, end_code, start_data, end_data;
 	unsigned long reloc_func_desc __maybe_unused = 0;
 	int executable_stack = EXSTACK_DEFAULT;
-	unsigned long def_flags = 0;
+	vm_flags_t def_flags = VM_NONE;
 	struct {
 		struct elfhdr elf_ex;
 		struct elfhdr interp_elf_ex;
diff --git a/fs/exec.c b/fs/exec.c
index 4b142c5..c01aac5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -660,7 +660,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma = bprm->vma;
 	struct vm_area_struct *prev = NULL;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	unsigned long stack_base;
 	unsigned long stack_size;
 	unsigned long stack_expand;
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index b1038bd..1fc0249 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -260,13 +260,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
 #define BDI_CAP_NO_ACCT_AND_WRITEBACK \
 	(BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
 
-#if defined(VM_MAYREAD) && \
-	(BDI_CAP_READ_MAP != VM_MAYREAD || \
-	 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \
-	 BDI_CAP_EXEC_MAP != VM_MAYEXEC)
-#error please change backing_dev_info::capabilities flags
-#endif
-
 extern struct backing_dev_info default_backing_dev_info;
 extern struct backing_dev_info noop_backing_dev_info;
 
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index f56cacb..7343ed1 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -108,7 +108,7 @@ extern void __split_huge_page_pmd(struct mm_struct *mm, pmd_t *pmd);
 #error "hugepages can't be allocated by the buddy allocator"
 #endif
 extern int hugepage_madvise(struct vm_area_struct *vma,
-			    unsigned long *vm_flags, int advice);
+			    vm_flags_t *vm_flags, int advice);
 extern void __vma_adjust_trans_huge(struct vm_area_struct *vma,
 				    unsigned long start,
 				    unsigned long end,
@@ -177,7 +177,7 @@ static inline int split_huge_page(struct page *page)
 	do { } while (0)
 #define compound_trans_head(page) compound_head(page)
 static inline int hugepage_madvise(struct vm_area_struct *vma,
-				   unsigned long *vm_flags, int advice)
+				   vm_flags_t *vm_flags, int advice)
 {
 	BUG();
 	return 0;
diff --git a/include/linux/ksm.h b/include/linux/ksm.h
index 3319a69..5de0c3d 100644
--- a/include/linux/ksm.h
+++ b/include/linux/ksm.h
@@ -21,7 +21,7 @@ struct page *ksm_does_need_to_copy(struct page *page,
 
 #ifdef CONFIG_KSM
 int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
-		unsigned long end, int advice, unsigned long *vm_flags);
+		unsigned long end, int advice, vm_flags_t *vm_flags);
 int __ksm_enter(struct mm_struct *mm);
 void __ksm_exit(struct mm_struct *mm);
 
@@ -84,7 +84,7 @@ static inline int ksm_might_need_to_copy(struct page *page,
 }
 
 int page_referenced_ksm(struct page *page,
-			struct mem_cgroup *memcg, unsigned long *vm_flags);
+			struct mem_cgroup *memcg, vm_flags_t *vm_flags);
 int try_to_unmap_ksm(struct page *page, enum ttu_flags flags);
 int rmap_walk_ksm(struct page *page, int (*rmap_one)(struct page *,
 		  struct vm_area_struct *, unsigned long, void *), void *arg);
@@ -108,7 +108,7 @@ static inline int PageKsm(struct page *page)
 
 #ifdef CONFIG_MMU
 static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
-		unsigned long end, int advice, unsigned long *vm_flags)
+		unsigned long end, int advice, vm_flags_t *vm_flags)
 {
 	return 0;
 }
@@ -120,7 +120,7 @@ static inline int ksm_might_need_to_copy(struct page *page,
 }
 
 static inline int page_referenced_ksm(struct page *page,
-			struct mem_cgroup *memcg, unsigned long *vm_flags)
+			struct mem_cgroup *memcg, vm_flags_t *vm_flags)
 {
 	return 0;
 }
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 69915a2..96f335c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -73,6 +73,9 @@ extern unsigned int kobjsize(const void *objp);
 /*
  * vm_flags in vm_area_struct, see mm_types.h.
  */
+
+#define VM_NONE		0x00000000
+
 #define VM_READ		0x00000001	/* currently active flags */
 #define VM_WRITE	0x00000002
 #define VM_EXEC		0x00000004
@@ -143,8 +146,8 @@ extern unsigned int kobjsize(const void *objp);
 #define VM_READHINTMASK			(VM_SEQ_READ | VM_RAND_READ)
 #define VM_ClearReadHint(v)		(v)->vm_flags &= ~VM_READHINTMASK
 #define VM_NormalReadHint(v)		(!((v)->vm_flags & VM_READHINTMASK))
-#define VM_SequentialReadHint(v)	((v)->vm_flags & VM_SEQ_READ)
-#define VM_RandomReadHint(v)		((v)->vm_flags & VM_RAND_READ)
+#define VM_SequentialReadHint(v)	(!!((v)->vm_flags & VM_SEQ_READ))
+#define VM_RandomReadHint(v)		(!!((v)->vm_flags & VM_RAND_READ))
 
 /*
  * Special vmas that are non-mergable, non-mlock()able.
@@ -1059,7 +1062,7 @@ extern unsigned long do_mremap(unsigned long addr,
 			       unsigned long flags, unsigned long new_addr);
 extern int mprotect_fixup(struct vm_area_struct *vma,
 			  struct vm_area_struct **pprev, unsigned long start,
-			  unsigned long end, unsigned long newflags);
+			  unsigned long end, vm_flags_t newflags);
 
 /*
  * doesn't attempt to fault and will return short.
@@ -1371,7 +1374,7 @@ extern int vma_adjust(struct vm_area_struct *vma, unsigned long start,
 	unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert);
 extern struct vm_area_struct *vma_merge(struct mm_struct *,
 	struct vm_area_struct *prev, unsigned long addr, unsigned long end,
-	unsigned long vm_flags, struct anon_vma *, struct file *, pgoff_t,
+	vm_flags_t vm_flags, struct anon_vma *, struct file *, pgoff_t,
 	struct mempolicy *);
 extern struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *);
 extern int split_vma(struct mm_struct *,
@@ -1396,7 +1399,7 @@ extern struct file *get_mm_exe_file(struct mm_struct *mm);
 extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
 extern int install_special_mapping(struct mm_struct *mm,
 				   unsigned long addr, unsigned long len,
-				   unsigned long flags, struct page **pages);
+				   vm_flags_t vm_flags, struct page **pages);
 
 extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 
@@ -1467,7 +1470,7 @@ extern int expand_stack(struct vm_area_struct *vma, unsigned long address);
 /* CONFIG_STACK_GROWSUP still needs to to grow downwards at some places */
 extern int expand_downwards(struct vm_area_struct *vma,
 		unsigned long address);
-#if VM_GROWSUP
+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
 extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
 #else
   #define expand_upwards(vma, address) do { } while (0)
@@ -1507,9 +1510,9 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
 }
 
 #ifdef CONFIG_MMU
-pgprot_t vm_get_page_prot(unsigned long vm_flags);
+pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
 #else
-static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
+static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
 {
 	return __pgprot(0);
 }
@@ -1543,10 +1546,10 @@ extern int apply_to_page_range(struct mm_struct *mm, unsigned long address,
 			       unsigned long size, pte_fn_t fn, void *data);
 
 #ifdef CONFIG_PROC_FS
-void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
+void vm_stat_account(struct mm_struct *, vm_flags_t, struct file *, long);
 #else
 static inline void vm_stat_account(struct mm_struct *mm,
-			unsigned long flags, struct file *file, long pages)
+			vm_flags_t vm_flags, struct file *file, long pages)
 {
 }
 #endif /* CONFIG_PROC_FS */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 3aeb8f6..d57e764 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -212,7 +212,7 @@ struct vm_area_struct {
 	struct vm_area_struct *vm_next, *vm_prev;
 
 	pgprot_t vm_page_prot;		/* Access permissions of this VMA. */
-	unsigned long vm_flags;		/* Flags, see mm.h. */
+	vm_flags_t vm_flags;		/* Flags, see mm.h. */
 
 	struct rb_node vm_rb;
 
@@ -328,7 +328,7 @@ struct mm_struct {
 	unsigned long exec_vm;		/* VM_EXEC & ~VM_WRITE */
 	unsigned long stack_vm;		/* VM_GROWSUP/DOWN */
 	unsigned long reserved_vm;	/* VM_RESERVED|VM_IO pages */
-	unsigned long def_flags;
+	vm_flags_t def_flags;
 	unsigned long nr_ptes;		/* Page table pages */
 	unsigned long start_code, end_code, start_data, end_data;
 	unsigned long start_brk, brk, start_stack;
diff --git a/include/linux/mman.h b/include/linux/mman.h
index 8b74e9b..3b11ea2 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -69,7 +69,7 @@ static inline int arch_validate_prot(unsigned long prot)
 /*
  * Combine the mmap "prot" argument into "vm_flags" used internally.
  */
-static inline unsigned long
+static inline vm_flags_t
 calc_vm_prot_bits(unsigned long prot)
 {
 	return _calc_vm_trans(prot, PROT_READ,  VM_READ ) |
@@ -81,7 +81,7 @@ calc_vm_prot_bits(unsigned long prot)
 /*
  * Combine the mmap "flags" argument into "vm_flags" used internally.
  */
-static inline unsigned long
+static inline vm_flags_t
 calc_vm_flag_bits(unsigned long flags)
 {
 	return _calc_vm_trans(flags, MAP_GROWSDOWN,  VM_GROWSDOWN ) |
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 1cdd62a..cb460be 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -158,9 +158,9 @@ static inline void page_dup_rmap(struct page *page)
  * Called from mm/vmscan.c to handle paging out
  */
 int page_referenced(struct page *, int is_locked,
-			struct mem_cgroup *memcg, unsigned long *vm_flags);
+			struct mem_cgroup *memcg, vm_flags_t *vm_flags);
 int page_referenced_one(struct page *, struct vm_area_struct *,
-	unsigned long address, unsigned int *mapcount, unsigned long *vm_flags);
+	unsigned long address, unsigned int *mapcount, vm_flags_t *vm_flags);
 
 enum ttu_flags {
 	TTU_UNMAP = 0,			/* unmap mode */
@@ -237,9 +237,9 @@ int rmap_walk(struct page *page, int (*rmap_one)(struct page *,
 
 static inline int page_referenced(struct page *page, int is_locked,
 				  struct mem_cgroup *memcg,
-				  unsigned long *vm_flags)
+				  vm_flags_t *vm_flags)
 {
-	*vm_flags = 0;
+	*vm_flags = VM_NONE;
 	return 0;
 }
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4b50357..73b1063 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4559,7 +4559,7 @@ got_name:
 		if (cpuctx->active_pmu != pmu)
 			goto next;
 		perf_event_mmap_ctx(&cpuctx->ctx, mmap_event,
-					vma->vm_flags & VM_EXEC);
+					(vma->vm_flags & VM_EXEC) != VM_NONE);
 
 		ctxn = pmu->task_ctx_nr;
 		if (ctxn < 0)
@@ -4568,7 +4568,7 @@ got_name:
 		ctx = rcu_dereference(current->perf_event_ctxp[ctxn]);
 		if (ctx) {
 			perf_event_mmap_ctx(ctx, mmap_event,
-					vma->vm_flags & VM_EXEC);
+					(vma->vm_flags & VM_EXEC) != VM_NONE);
 		}
 next:
 		put_cpu_ptr(pmu->pmu_cpu_context);
diff --git a/kernel/fork.c b/kernel/fork.c
index 48675fb..f14cde8 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -504,7 +504,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)
 	mm_init_owner(mm, p);
 
 	if (likely(!mm_alloc_pgd(mm))) {
-		mm->def_flags = 0;
+		mm->def_flags = VM_NONE;
 		mmu_notifier_mm_init(mm);
 		return mm;
 	}
diff --git a/kernel/sys.c b/kernel/sys.c
index ef7e275..3080842 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1703,8 +1703,8 @@ SYSCALL_DEFINE1(umask, int, mask)
 
 #ifdef CONFIG_CHECKPOINT_RESTORE
 static bool vma_flags_mismatch(struct vm_area_struct *vma,
-			       unsigned long required,
-			       unsigned long banned)
+			       vm_flags_t required,
+			       vm_flags_t banned)
 {
 	return (vma->vm_flags & required) != required ||
 		(vma->vm_flags & banned);
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index dd8e2aa..1380e07 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -758,6 +758,10 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
 	char tmp[32];
 	int err;
 
+	BUILD_BUG_ON(BDI_CAP_READ_MAP != VM_MAYREAD);
+	BUILD_BUG_ON(BDI_CAP_WRITE_MAP != VM_MAYWRITE);
+	BUILD_BUG_ON(BDI_CAP_EXEC_MAP != VM_MAYEXEC);
+
 	bdi->name = name;
 	bdi->capabilities = cap;
 	err = bdi_init(bdi);
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f0e5306..813138d 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1486,7 +1486,7 @@ out:
 		   VM_HUGETLB|VM_SHARED|VM_MAYSHARE)
 
 int hugepage_madvise(struct vm_area_struct *vma,
-		     unsigned long *vm_flags, int advice)
+		     vm_flags_t *vm_flags, int advice)
 {
 	switch (advice) {
 	case MADV_HUGEPAGE:
diff --git a/mm/ksm.c b/mm/ksm.c
index f23a24d..963ee37 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1446,7 +1446,7 @@ static int ksm_scan_thread(void *nothing)
 }
 
 int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
-		unsigned long end, int advice, unsigned long *vm_flags)
+		unsigned long end, int advice, vm_flags_t *vm_flags)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	int err;
@@ -1581,7 +1581,7 @@ struct page *ksm_does_need_to_copy(struct page *page,
 }
 
 int page_referenced_ksm(struct page *page, struct mem_cgroup *memcg,
-			unsigned long *vm_flags)
+			vm_flags_t *vm_flags)
 {
 	struct stable_node *stable_node;
 	struct rmap_item *rmap_item;
diff --git a/mm/madvise.c b/mm/madvise.c
index f5ab745..7a67ea5 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -43,7 +43,7 @@ static long madvise_behavior(struct vm_area_struct * vma,
 	struct mm_struct * mm = vma->vm_mm;
 	int error = 0;
 	pgoff_t pgoff;
-	unsigned long new_flags = vma->vm_flags;
+	vm_flags_t new_flags = vma->vm_flags;
 
 	switch (behavior) {
 	case MADV_NORMAL:
diff --git a/mm/memory.c b/mm/memory.c
index 4c09ecb..b1c7c98 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -845,7 +845,7 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 		pte_t *dst_pte, pte_t *src_pte, struct vm_area_struct *vma,
 		unsigned long addr, int *rss)
 {
-	unsigned long vm_flags = vma->vm_flags;
+	vm_flags_t vm_flags = vma->vm_flags;
 	pte_t pte = *src_pte;
 	struct page *page;
 
@@ -1635,7 +1635,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 		     int *nonblocking)
 {
 	int i;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 
 	if (nr_pages <= 0)
 		return 0;
diff --git a/mm/mlock.c b/mm/mlock.c
index ef726e8..c555e7d 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -524,7 +524,7 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
 static int do_mlockall(int flags)
 {
 	struct vm_area_struct * vma, * prev = NULL;
-	unsigned int def_flags = 0;
+	vm_flags_t def_flags = VM_NONE;
 
 	if (flags & MCL_FUTURE)
 		def_flags = VM_LOCKED;
diff --git a/mm/mmap.c b/mm/mmap.c
index ae12bb8..0b6e869 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -77,7 +77,7 @@ pgprot_t protection_map[16] = {
 	__S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
 };
 
-pgprot_t vm_get_page_prot(unsigned long vm_flags)
+pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
 {
 	return __pgprot(pgprot_val(protection_map[vm_flags &
 				(VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
@@ -658,7 +658,7 @@ again:			remove_next = 1 + (end > next->vm_end);
  * per-vma resources, so we don't attempt to merge those.
  */
 static inline int is_mergeable_vma(struct vm_area_struct *vma,
-			struct file *file, unsigned long vm_flags)
+			struct file *file, vm_flags_t vm_flags)
 {
 	/* VM_CAN_NONLINEAR may get set later by f_op->mmap() */
 	if ((vma->vm_flags ^ vm_flags) & ~VM_CAN_NONLINEAR)
@@ -696,7 +696,7 @@ static inline int is_mergeable_anon_vma(struct anon_vma *anon_vma1,
  * wrap, nor mmaps which cover the final page at index -1UL.
  */
 static int
-can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
+can_vma_merge_before(struct vm_area_struct *vma, vm_flags_t vm_flags,
 	struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
 {
 	if (is_mergeable_vma(vma, file, vm_flags) &&
@@ -715,7 +715,7 @@ can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
  * anon_vmas, nor if same anon_vma is assigned but offsets incompatible.
  */
 static int
-can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
+can_vma_merge_after(struct vm_area_struct *vma, vm_flags_t vm_flags,
 	struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
 {
 	if (is_mergeable_vma(vma, file, vm_flags) &&
@@ -759,7 +759,7 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
  */
 struct vm_area_struct *vma_merge(struct mm_struct *mm,
 			struct vm_area_struct *prev, unsigned long addr,
-			unsigned long end, unsigned long vm_flags,
+			unsigned long end, vm_flags_t vm_flags,
 		     	struct anon_vma *anon_vma, struct file *file,
 			pgoff_t pgoff, struct mempolicy *policy)
 {
@@ -928,19 +928,19 @@ none:
 }
 
 #ifdef CONFIG_PROC_FS
-void vm_stat_account(struct mm_struct *mm, unsigned long flags,
-						struct file *file, long pages)
+void vm_stat_account(struct mm_struct *mm, vm_flags_t vm_flags,
+		     struct file *file, long pages)
 {
-	const unsigned long stack_flags
+	const vm_flags_t stack_flags
 		= VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
 
 	if (file) {
 		mm->shared_vm += pages;
-		if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
+		if ((vm_flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
 			mm->exec_vm += pages;
-	} else if (flags & stack_flags)
+	} else if (vm_flags & stack_flags)
 		mm->stack_vm += pages;
-	if (flags & (VM_RESERVED|VM_IO))
+	if (vm_flags & (VM_RESERVED|VM_IO))
 		mm->reserved_vm += pages;
 }
 #endif /* CONFIG_PROC_FS */
@@ -2156,7 +2156,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
 {
 	struct mm_struct * mm = current->mm;
 	struct vm_area_struct * vma, * prev;
-	unsigned long flags;
+	vm_flags_t vm_flags;
 	struct rb_node ** rb_link, * rb_parent;
 	pgoff_t pgoff = addr >> PAGE_SHIFT;
 	int error;
@@ -2169,7 +2169,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
 	if (error)
 		return error;
 
-	flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
+	vm_flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
 
 	error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
 	if (error & ~PAGE_MASK)
@@ -2216,7 +2216,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
 		return -ENOMEM;
 
 	/* Can we just expand an old private anonymous mapping? */
-	vma = vma_merge(mm, prev, addr, addr + len, flags,
+	vma = vma_merge(mm, prev, addr, addr + len, vm_flags,
 					NULL, NULL, pgoff, NULL);
 	if (vma)
 		goto out;
@@ -2235,13 +2235,13 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
 	vma->vm_start = addr;
 	vma->vm_end = addr + len;
 	vma->vm_pgoff = pgoff;
-	vma->vm_flags = flags;
-	vma->vm_page_prot = vm_get_page_prot(flags);
+	vma->vm_flags = vm_flags;
+	vma->vm_page_prot = vm_get_page_prot(vm_flags);
 	vma_link(mm, vma, prev, rb_link, rb_parent);
 out:
 	perf_event_mmap(vma);
 	mm->total_vm += len >> PAGE_SHIFT;
-	if (flags & VM_LOCKED) {
+	if (vm_flags & VM_LOCKED) {
 		if (!mlock_vma_pages_range(vma, addr, addr + len))
 			mm->locked_vm += (len >> PAGE_SHIFT);
 	}
@@ -2489,7 +2489,7 @@ static const struct vm_operations_struct special_mapping_vmops = {
  */
 int install_special_mapping(struct mm_struct *mm,
 			    unsigned long addr, unsigned long len,
-			    unsigned long vm_flags, struct page **pages)
+			    vm_flags_t vm_flags, struct page **pages)
 {
 	int ret;
 	struct vm_area_struct *vma;
diff --git a/mm/mprotect.c b/mm/mprotect.c
index a409926..0faa389 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -143,10 +143,10 @@ static void change_protection(struct vm_area_struct *vma,
 
 int
 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
-	unsigned long start, unsigned long end, unsigned long newflags)
+	unsigned long start, unsigned long end, vm_flags_t newflags)
 {
 	struct mm_struct *mm = vma->vm_mm;
-	unsigned long oldflags = vma->vm_flags;
+	vm_flags_t oldflags = vma->vm_flags;
 	long nrpages = (end - start) >> PAGE_SHIFT;
 	unsigned long charged = 0;
 	pgoff_t pgoff;
@@ -232,7 +232,8 @@ fail:
 SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
 		unsigned long, prot)
 {
-	unsigned long vm_flags, nstart, end, tmp, reqprot;
+	unsigned long nstart, end, tmp, reqprot;
+	vm_flags_t vm_flags;
 	struct vm_area_struct *vma, *prev;
 	int error = -EINVAL;
 	const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
@@ -289,7 +290,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
 		prev = vma;
 
 	for (nstart = start ; ; ) {
-		unsigned long newflags;
+		vm_flags_t newflags;
 
 		/* Here we know that  vma->vm_start <= nstart < vma->vm_end. */
 
diff --git a/mm/mremap.c b/mm/mremap.c
index db8d983..c94d1db 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -186,7 +186,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
 {
 	struct mm_struct *mm = vma->vm_mm;
 	struct vm_area_struct *new_vma;
-	unsigned long vm_flags = vma->vm_flags;
+	vm_flags_t vm_flags = vma->vm_flags;
 	unsigned long new_pgoff;
 	unsigned long moved_len;
 	unsigned long excess = 0;
diff --git a/mm/rmap.c b/mm/rmap.c
index 36d01a2..88ccaec 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -691,7 +691,7 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma)
  */
 int page_referenced_one(struct page *page, struct vm_area_struct *vma,
 			unsigned long address, unsigned int *mapcount,
-			unsigned long *vm_flags)
+			vm_flags_t *vm_flags)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	int referenced = 0;
@@ -770,7 +770,7 @@ out:
 
 static int page_referenced_anon(struct page *page,
 				struct mem_cgroup *memcg,
-				unsigned long *vm_flags)
+				vm_flags_t *vm_flags)
 {
 	unsigned int mapcount;
 	struct anon_vma *anon_vma;
@@ -819,7 +819,7 @@ static int page_referenced_anon(struct page *page,
  */
 static int page_referenced_file(struct page *page,
 				struct mem_cgroup *memcg,
-				unsigned long *vm_flags)
+				vm_flags_t *vm_flags)
 {
 	unsigned int mapcount;
 	struct address_space *mapping = page->mapping;
@@ -885,12 +885,12 @@ static int page_referenced_file(struct page *page,
 int page_referenced(struct page *page,
 		    int is_locked,
 		    struct mem_cgroup *memcg,
-		    unsigned long *vm_flags)
+		    vm_flags_t *vm_flags)
 {
 	int referenced = 0;
 	int we_locked = 0;
 
-	*vm_flags = 0;
+	*vm_flags = VM_NONE;
 	if (page_mapped(page) && page_rmapping(page)) {
 		if (!is_locked && (!PageAnon(page) || PageKsm(page))) {
 			we_locked = trylock_page(page);
@@ -1415,7 +1415,7 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
 	 * keep the sem while scanning the cluster for mlocking pages.
 	 */
 	if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
-		locked_vma = (vma->vm_flags & VM_LOCKED);
+		locked_vma = (vma->vm_flags & VM_LOCKED) != VM_NONE;
 		if (!locked_vma)
 			up_read(&vma->vm_mm->mmap_sem); /* don't need it */
 	}
@@ -1466,9 +1466,7 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
 
 bool is_vma_temporary_stack(struct vm_area_struct *vma)
 {
-	int maybe_stack = vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP);
-
-	if (!maybe_stack)
+	if ((vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) == VM_NONE)
 		return false;
 
 	if ((vma->vm_flags & VM_STACK_INCOMPLETE_SETUP) ==
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 57d8ef6..9d3441d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -705,7 +705,7 @@ static enum page_references page_check_references(struct page *page,
 						  struct scan_control *sc)
 {
 	int referenced_ptes, referenced_page;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 
 	referenced_ptes = page_referenced(page, 1, mz->mem_cgroup, &vm_flags);
 	referenced_page = TestClearPageReferenced(page);
@@ -1678,7 +1678,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
 {
 	unsigned long nr_taken;
 	unsigned long nr_scanned;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	LIST_HEAD(l_hold);	/* The pages which were snipped off */
 	LIST_HEAD(l_active);
 	LIST_HEAD(l_inactive);


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 02/16] mm: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Hugh Dickins, linux-kernel, KOSAKI Motohiro,
	Benjamin Herrenschmidt

* switch type of vma->vm_flags and mm->def_flags to vm_flags_t
* introduce new constant "VM_NONE", as equivalent of zero vm_flags state
* spread vm_flags_t in the generic mm code
* fix dangerous type-casts (like int exec = vma->vm_flags & VM_EXEC)
* convert BDI_CAP_*_MAP consistency checks into BUILD_BUG_ON()

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
---
 drivers/char/mem.c          |    2 +-
 fs/binfmt_elf.c             |    2 +-
 fs/exec.c                   |    2 +-
 include/linux/backing-dev.h |    7 -------
 include/linux/huge_mm.h     |    4 ++--
 include/linux/ksm.h         |    8 ++++----
 include/linux/mm.h          |   23 +++++++++++++----------
 include/linux/mm_types.h    |    4 ++--
 include/linux/mman.h        |    4 ++--
 include/linux/rmap.h        |    8 ++++----
 kernel/events/core.c        |    4 ++--
 kernel/fork.c               |    2 +-
 kernel/sys.c                |    4 ++--
 mm/backing-dev.c            |    4 ++++
 mm/huge_memory.c            |    2 +-
 mm/ksm.c                    |    4 ++--
 mm/madvise.c                |    2 +-
 mm/memory.c                 |    4 ++--
 mm/mlock.c                  |    2 +-
 mm/mmap.c                   |   36 ++++++++++++++++++------------------
 mm/mprotect.c               |    9 +++++----
 mm/mremap.c                 |    2 +-
 mm/rmap.c                   |   16 +++++++---------
 mm/vmscan.c                 |    4 ++--
 24 files changed, 79 insertions(+), 80 deletions(-)

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index d6e9d08..60a6e34 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -280,7 +280,7 @@ static unsigned long get_unmapped_area_mem(struct file *file,
 /* can't do an in-place private mapping if there's no MMU */
 static inline int private_mapping_ok(struct vm_area_struct *vma)
 {
-	return vma->vm_flags & VM_MAYSHARE;
+	return (vma->vm_flags & VM_MAYSHARE) != VM_NONE;
 }
 #else
 #define get_unmapped_area_mem	NULL
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 2be0d74..dce9c93 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -572,7 +572,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
 	unsigned long start_code, end_code, start_data, end_data;
 	unsigned long reloc_func_desc __maybe_unused = 0;
 	int executable_stack = EXSTACK_DEFAULT;
-	unsigned long def_flags = 0;
+	vm_flags_t def_flags = VM_NONE;
 	struct {
 		struct elfhdr elf_ex;
 		struct elfhdr interp_elf_ex;
diff --git a/fs/exec.c b/fs/exec.c
index 4b142c5..c01aac5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -660,7 +660,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	struct mm_struct *mm = current->mm;
 	struct vm_area_struct *vma = bprm->vma;
 	struct vm_area_struct *prev = NULL;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	unsigned long stack_base;
 	unsigned long stack_size;
 	unsigned long stack_expand;
diff --git a/include/linux/backing-dev.h b/include/linux/backing-dev.h
index b1038bd..1fc0249 100644
--- a/include/linux/backing-dev.h
+++ b/include/linux/backing-dev.h
@@ -260,13 +260,6 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
 #define BDI_CAP_NO_ACCT_AND_WRITEBACK \
 	(BDI_CAP_NO_WRITEBACK | BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_ACCT_WB)
 
-#if defined(VM_MAYREAD) && \
-	(BDI_CAP_READ_MAP != VM_MAYREAD || \
-	 BDI_CAP_WRITE_MAP != VM_MAYWRITE || \
-	 BDI_CAP_EXEC_MAP != VM_MAYEXEC)
-#error please change backing_dev_info::capabilities flags
-#endif
-
 extern struct backing_dev_info default_backing_dev_info;
 extern struct backing_dev_info noop_backing_dev_info;
 
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index f56cacb..7343ed1 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -108,7 +108,7 @@ extern void __split_huge_page_pmd(struct mm_struct *mm, pmd_t *pmd);
 #error "hugepages can't be allocated by the buddy allocator"
 #endif
 extern int hugepage_madvise(struct vm_area_struct *vma,
-			    unsigned long *vm_flags, int advice);
+			    vm_flags_t *vm_flags, int advice);
 extern void __vma_adjust_trans_huge(struct vm_area_struct *vma,
 				    unsigned long start,
 				    unsigned long end,
@@ -177,7 +177,7 @@ static inline int split_huge_page(struct page *page)
 	do { } while (0)
 #define compound_trans_head(page) compound_head(page)
 static inline int hugepage_madvise(struct vm_area_struct *vma,
-				   unsigned long *vm_flags, int advice)
+				   vm_flags_t *vm_flags, int advice)
 {
 	BUG();
 	return 0;
diff --git a/include/linux/ksm.h b/include/linux/ksm.h
index 3319a69..5de0c3d 100644
--- a/include/linux/ksm.h
+++ b/include/linux/ksm.h
@@ -21,7 +21,7 @@ struct page *ksm_does_need_to_copy(struct page *page,
 
 #ifdef CONFIG_KSM
 int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
-		unsigned long end, int advice, unsigned long *vm_flags);
+		unsigned long end, int advice, vm_flags_t *vm_flags);
 int __ksm_enter(struct mm_struct *mm);
 void __ksm_exit(struct mm_struct *mm);
 
@@ -84,7 +84,7 @@ static inline int ksm_might_need_to_copy(struct page *page,
 }
 
 int page_referenced_ksm(struct page *page,
-			struct mem_cgroup *memcg, unsigned long *vm_flags);
+			struct mem_cgroup *memcg, vm_flags_t *vm_flags);
 int try_to_unmap_ksm(struct page *page, enum ttu_flags flags);
 int rmap_walk_ksm(struct page *page, int (*rmap_one)(struct page *,
 		  struct vm_area_struct *, unsigned long, void *), void *arg);
@@ -108,7 +108,7 @@ static inline int PageKsm(struct page *page)
 
 #ifdef CONFIG_MMU
 static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
-		unsigned long end, int advice, unsigned long *vm_flags)
+		unsigned long end, int advice, vm_flags_t *vm_flags)
 {
 	return 0;
 }
@@ -120,7 +120,7 @@ static inline int ksm_might_need_to_copy(struct page *page,
 }
 
 static inline int page_referenced_ksm(struct page *page,
-			struct mem_cgroup *memcg, unsigned long *vm_flags)
+			struct mem_cgroup *memcg, vm_flags_t *vm_flags)
 {
 	return 0;
 }
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 69915a2..96f335c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -73,6 +73,9 @@ extern unsigned int kobjsize(const void *objp);
 /*
  * vm_flags in vm_area_struct, see mm_types.h.
  */
+
+#define VM_NONE		0x00000000
+
 #define VM_READ		0x00000001	/* currently active flags */
 #define VM_WRITE	0x00000002
 #define VM_EXEC		0x00000004
@@ -143,8 +146,8 @@ extern unsigned int kobjsize(const void *objp);
 #define VM_READHINTMASK			(VM_SEQ_READ | VM_RAND_READ)
 #define VM_ClearReadHint(v)		(v)->vm_flags &= ~VM_READHINTMASK
 #define VM_NormalReadHint(v)		(!((v)->vm_flags & VM_READHINTMASK))
-#define VM_SequentialReadHint(v)	((v)->vm_flags & VM_SEQ_READ)
-#define VM_RandomReadHint(v)		((v)->vm_flags & VM_RAND_READ)
+#define VM_SequentialReadHint(v)	(!!((v)->vm_flags & VM_SEQ_READ))
+#define VM_RandomReadHint(v)		(!!((v)->vm_flags & VM_RAND_READ))
 
 /*
  * Special vmas that are non-mergable, non-mlock()able.
@@ -1059,7 +1062,7 @@ extern unsigned long do_mremap(unsigned long addr,
 			       unsigned long flags, unsigned long new_addr);
 extern int mprotect_fixup(struct vm_area_struct *vma,
 			  struct vm_area_struct **pprev, unsigned long start,
-			  unsigned long end, unsigned long newflags);
+			  unsigned long end, vm_flags_t newflags);
 
 /*
  * doesn't attempt to fault and will return short.
@@ -1371,7 +1374,7 @@ extern int vma_adjust(struct vm_area_struct *vma, unsigned long start,
 	unsigned long end, pgoff_t pgoff, struct vm_area_struct *insert);
 extern struct vm_area_struct *vma_merge(struct mm_struct *,
 	struct vm_area_struct *prev, unsigned long addr, unsigned long end,
-	unsigned long vm_flags, struct anon_vma *, struct file *, pgoff_t,
+	vm_flags_t vm_flags, struct anon_vma *, struct file *, pgoff_t,
 	struct mempolicy *);
 extern struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *);
 extern int split_vma(struct mm_struct *,
@@ -1396,7 +1399,7 @@ extern struct file *get_mm_exe_file(struct mm_struct *mm);
 extern int may_expand_vm(struct mm_struct *mm, unsigned long npages);
 extern int install_special_mapping(struct mm_struct *mm,
 				   unsigned long addr, unsigned long len,
-				   unsigned long flags, struct page **pages);
+				   vm_flags_t vm_flags, struct page **pages);
 
 extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 
@@ -1467,7 +1470,7 @@ extern int expand_stack(struct vm_area_struct *vma, unsigned long address);
 /* CONFIG_STACK_GROWSUP still needs to to grow downwards at some places */
 extern int expand_downwards(struct vm_area_struct *vma,
 		unsigned long address);
-#if VM_GROWSUP
+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
 extern int expand_upwards(struct vm_area_struct *vma, unsigned long address);
 #else
   #define expand_upwards(vma, address) do { } while (0)
@@ -1507,9 +1510,9 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
 }
 
 #ifdef CONFIG_MMU
-pgprot_t vm_get_page_prot(unsigned long vm_flags);
+pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
 #else
-static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
+static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
 {
 	return __pgprot(0);
 }
@@ -1543,10 +1546,10 @@ extern int apply_to_page_range(struct mm_struct *mm, unsigned long address,
 			       unsigned long size, pte_fn_t fn, void *data);
 
 #ifdef CONFIG_PROC_FS
-void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
+void vm_stat_account(struct mm_struct *, vm_flags_t, struct file *, long);
 #else
 static inline void vm_stat_account(struct mm_struct *mm,
-			unsigned long flags, struct file *file, long pages)
+			vm_flags_t vm_flags, struct file *file, long pages)
 {
 }
 #endif /* CONFIG_PROC_FS */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 3aeb8f6..d57e764 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -212,7 +212,7 @@ struct vm_area_struct {
 	struct vm_area_struct *vm_next, *vm_prev;
 
 	pgprot_t vm_page_prot;		/* Access permissions of this VMA. */
-	unsigned long vm_flags;		/* Flags, see mm.h. */
+	vm_flags_t vm_flags;		/* Flags, see mm.h. */
 
 	struct rb_node vm_rb;
 
@@ -328,7 +328,7 @@ struct mm_struct {
 	unsigned long exec_vm;		/* VM_EXEC & ~VM_WRITE */
 	unsigned long stack_vm;		/* VM_GROWSUP/DOWN */
 	unsigned long reserved_vm;	/* VM_RESERVED|VM_IO pages */
-	unsigned long def_flags;
+	vm_flags_t def_flags;
 	unsigned long nr_ptes;		/* Page table pages */
 	unsigned long start_code, end_code, start_data, end_data;
 	unsigned long start_brk, brk, start_stack;
diff --git a/include/linux/mman.h b/include/linux/mman.h
index 8b74e9b..3b11ea2 100644
--- a/include/linux/mman.h
+++ b/include/linux/mman.h
@@ -69,7 +69,7 @@ static inline int arch_validate_prot(unsigned long prot)
 /*
  * Combine the mmap "prot" argument into "vm_flags" used internally.
  */
-static inline unsigned long
+static inline vm_flags_t
 calc_vm_prot_bits(unsigned long prot)
 {
 	return _calc_vm_trans(prot, PROT_READ,  VM_READ ) |
@@ -81,7 +81,7 @@ calc_vm_prot_bits(unsigned long prot)
 /*
  * Combine the mmap "flags" argument into "vm_flags" used internally.
  */
-static inline unsigned long
+static inline vm_flags_t
 calc_vm_flag_bits(unsigned long flags)
 {
 	return _calc_vm_trans(flags, MAP_GROWSDOWN,  VM_GROWSDOWN ) |
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 1cdd62a..cb460be 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -158,9 +158,9 @@ static inline void page_dup_rmap(struct page *page)
  * Called from mm/vmscan.c to handle paging out
  */
 int page_referenced(struct page *, int is_locked,
-			struct mem_cgroup *memcg, unsigned long *vm_flags);
+			struct mem_cgroup *memcg, vm_flags_t *vm_flags);
 int page_referenced_one(struct page *, struct vm_area_struct *,
-	unsigned long address, unsigned int *mapcount, unsigned long *vm_flags);
+	unsigned long address, unsigned int *mapcount, vm_flags_t *vm_flags);
 
 enum ttu_flags {
 	TTU_UNMAP = 0,			/* unmap mode */
@@ -237,9 +237,9 @@ int rmap_walk(struct page *page, int (*rmap_one)(struct page *,
 
 static inline int page_referenced(struct page *page, int is_locked,
 				  struct mem_cgroup *memcg,
-				  unsigned long *vm_flags)
+				  vm_flags_t *vm_flags)
 {
-	*vm_flags = 0;
+	*vm_flags = VM_NONE;
 	return 0;
 }
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 4b50357..73b1063 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4559,7 +4559,7 @@ got_name:
 		if (cpuctx->active_pmu != pmu)
 			goto next;
 		perf_event_mmap_ctx(&cpuctx->ctx, mmap_event,
-					vma->vm_flags & VM_EXEC);
+					(vma->vm_flags & VM_EXEC) != VM_NONE);
 
 		ctxn = pmu->task_ctx_nr;
 		if (ctxn < 0)
@@ -4568,7 +4568,7 @@ got_name:
 		ctx = rcu_dereference(current->perf_event_ctxp[ctxn]);
 		if (ctx) {
 			perf_event_mmap_ctx(ctx, mmap_event,
-					vma->vm_flags & VM_EXEC);
+					(vma->vm_flags & VM_EXEC) != VM_NONE);
 		}
 next:
 		put_cpu_ptr(pmu->pmu_cpu_context);
diff --git a/kernel/fork.c b/kernel/fork.c
index 48675fb..f14cde8 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -504,7 +504,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)
 	mm_init_owner(mm, p);
 
 	if (likely(!mm_alloc_pgd(mm))) {
-		mm->def_flags = 0;
+		mm->def_flags = VM_NONE;
 		mmu_notifier_mm_init(mm);
 		return mm;
 	}
diff --git a/kernel/sys.c b/kernel/sys.c
index ef7e275..3080842 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1703,8 +1703,8 @@ SYSCALL_DEFINE1(umask, int, mask)
 
 #ifdef CONFIG_CHECKPOINT_RESTORE
 static bool vma_flags_mismatch(struct vm_area_struct *vma,
-			       unsigned long required,
-			       unsigned long banned)
+			       vm_flags_t required,
+			       vm_flags_t banned)
 {
 	return (vma->vm_flags & required) != required ||
 		(vma->vm_flags & banned);
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index dd8e2aa..1380e07 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -758,6 +758,10 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
 	char tmp[32];
 	int err;
 
+	BUILD_BUG_ON(BDI_CAP_READ_MAP != VM_MAYREAD);
+	BUILD_BUG_ON(BDI_CAP_WRITE_MAP != VM_MAYWRITE);
+	BUILD_BUG_ON(BDI_CAP_EXEC_MAP != VM_MAYEXEC);
+
 	bdi->name = name;
 	bdi->capabilities = cap;
 	err = bdi_init(bdi);
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f0e5306..813138d 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1486,7 +1486,7 @@ out:
 		   VM_HUGETLB|VM_SHARED|VM_MAYSHARE)
 
 int hugepage_madvise(struct vm_area_struct *vma,
-		     unsigned long *vm_flags, int advice)
+		     vm_flags_t *vm_flags, int advice)
 {
 	switch (advice) {
 	case MADV_HUGEPAGE:
diff --git a/mm/ksm.c b/mm/ksm.c
index f23a24d..963ee37 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -1446,7 +1446,7 @@ static int ksm_scan_thread(void *nothing)
 }
 
 int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
-		unsigned long end, int advice, unsigned long *vm_flags)
+		unsigned long end, int advice, vm_flags_t *vm_flags)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	int err;
@@ -1581,7 +1581,7 @@ struct page *ksm_does_need_to_copy(struct page *page,
 }
 
 int page_referenced_ksm(struct page *page, struct mem_cgroup *memcg,
-			unsigned long *vm_flags)
+			vm_flags_t *vm_flags)
 {
 	struct stable_node *stable_node;
 	struct rmap_item *rmap_item;
diff --git a/mm/madvise.c b/mm/madvise.c
index f5ab745..7a67ea5 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -43,7 +43,7 @@ static long madvise_behavior(struct vm_area_struct * vma,
 	struct mm_struct * mm = vma->vm_mm;
 	int error = 0;
 	pgoff_t pgoff;
-	unsigned long new_flags = vma->vm_flags;
+	vm_flags_t new_flags = vma->vm_flags;
 
 	switch (behavior) {
 	case MADV_NORMAL:
diff --git a/mm/memory.c b/mm/memory.c
index 4c09ecb..b1c7c98 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -845,7 +845,7 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 		pte_t *dst_pte, pte_t *src_pte, struct vm_area_struct *vma,
 		unsigned long addr, int *rss)
 {
-	unsigned long vm_flags = vma->vm_flags;
+	vm_flags_t vm_flags = vma->vm_flags;
 	pte_t pte = *src_pte;
 	struct page *page;
 
@@ -1635,7 +1635,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 		     int *nonblocking)
 {
 	int i;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 
 	if (nr_pages <= 0)
 		return 0;
diff --git a/mm/mlock.c b/mm/mlock.c
index ef726e8..c555e7d 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -524,7 +524,7 @@ SYSCALL_DEFINE2(munlock, unsigned long, start, size_t, len)
 static int do_mlockall(int flags)
 {
 	struct vm_area_struct * vma, * prev = NULL;
-	unsigned int def_flags = 0;
+	vm_flags_t def_flags = VM_NONE;
 
 	if (flags & MCL_FUTURE)
 		def_flags = VM_LOCKED;
diff --git a/mm/mmap.c b/mm/mmap.c
index ae12bb8..0b6e869 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -77,7 +77,7 @@ pgprot_t protection_map[16] = {
 	__S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
 };
 
-pgprot_t vm_get_page_prot(unsigned long vm_flags)
+pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
 {
 	return __pgprot(pgprot_val(protection_map[vm_flags &
 				(VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
@@ -658,7 +658,7 @@ again:			remove_next = 1 + (end > next->vm_end);
  * per-vma resources, so we don't attempt to merge those.
  */
 static inline int is_mergeable_vma(struct vm_area_struct *vma,
-			struct file *file, unsigned long vm_flags)
+			struct file *file, vm_flags_t vm_flags)
 {
 	/* VM_CAN_NONLINEAR may get set later by f_op->mmap() */
 	if ((vma->vm_flags ^ vm_flags) & ~VM_CAN_NONLINEAR)
@@ -696,7 +696,7 @@ static inline int is_mergeable_anon_vma(struct anon_vma *anon_vma1,
  * wrap, nor mmaps which cover the final page at index -1UL.
  */
 static int
-can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
+can_vma_merge_before(struct vm_area_struct *vma, vm_flags_t vm_flags,
 	struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
 {
 	if (is_mergeable_vma(vma, file, vm_flags) &&
@@ -715,7 +715,7 @@ can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
  * anon_vmas, nor if same anon_vma is assigned but offsets incompatible.
  */
 static int
-can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
+can_vma_merge_after(struct vm_area_struct *vma, vm_flags_t vm_flags,
 	struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
 {
 	if (is_mergeable_vma(vma, file, vm_flags) &&
@@ -759,7 +759,7 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
  */
 struct vm_area_struct *vma_merge(struct mm_struct *mm,
 			struct vm_area_struct *prev, unsigned long addr,
-			unsigned long end, unsigned long vm_flags,
+			unsigned long end, vm_flags_t vm_flags,
 		     	struct anon_vma *anon_vma, struct file *file,
 			pgoff_t pgoff, struct mempolicy *policy)
 {
@@ -928,19 +928,19 @@ none:
 }
 
 #ifdef CONFIG_PROC_FS
-void vm_stat_account(struct mm_struct *mm, unsigned long flags,
-						struct file *file, long pages)
+void vm_stat_account(struct mm_struct *mm, vm_flags_t vm_flags,
+		     struct file *file, long pages)
 {
-	const unsigned long stack_flags
+	const vm_flags_t stack_flags
 		= VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
 
 	if (file) {
 		mm->shared_vm += pages;
-		if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
+		if ((vm_flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
 			mm->exec_vm += pages;
-	} else if (flags & stack_flags)
+	} else if (vm_flags & stack_flags)
 		mm->stack_vm += pages;
-	if (flags & (VM_RESERVED|VM_IO))
+	if (vm_flags & (VM_RESERVED|VM_IO))
 		mm->reserved_vm += pages;
 }
 #endif /* CONFIG_PROC_FS */
@@ -2156,7 +2156,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
 {
 	struct mm_struct * mm = current->mm;
 	struct vm_area_struct * vma, * prev;
-	unsigned long flags;
+	vm_flags_t vm_flags;
 	struct rb_node ** rb_link, * rb_parent;
 	pgoff_t pgoff = addr >> PAGE_SHIFT;
 	int error;
@@ -2169,7 +2169,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
 	if (error)
 		return error;
 
-	flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
+	vm_flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
 
 	error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
 	if (error & ~PAGE_MASK)
@@ -2216,7 +2216,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
 		return -ENOMEM;
 
 	/* Can we just expand an old private anonymous mapping? */
-	vma = vma_merge(mm, prev, addr, addr + len, flags,
+	vma = vma_merge(mm, prev, addr, addr + len, vm_flags,
 					NULL, NULL, pgoff, NULL);
 	if (vma)
 		goto out;
@@ -2235,13 +2235,13 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
 	vma->vm_start = addr;
 	vma->vm_end = addr + len;
 	vma->vm_pgoff = pgoff;
-	vma->vm_flags = flags;
-	vma->vm_page_prot = vm_get_page_prot(flags);
+	vma->vm_flags = vm_flags;
+	vma->vm_page_prot = vm_get_page_prot(vm_flags);
 	vma_link(mm, vma, prev, rb_link, rb_parent);
 out:
 	perf_event_mmap(vma);
 	mm->total_vm += len >> PAGE_SHIFT;
-	if (flags & VM_LOCKED) {
+	if (vm_flags & VM_LOCKED) {
 		if (!mlock_vma_pages_range(vma, addr, addr + len))
 			mm->locked_vm += (len >> PAGE_SHIFT);
 	}
@@ -2489,7 +2489,7 @@ static const struct vm_operations_struct special_mapping_vmops = {
  */
 int install_special_mapping(struct mm_struct *mm,
 			    unsigned long addr, unsigned long len,
-			    unsigned long vm_flags, struct page **pages)
+			    vm_flags_t vm_flags, struct page **pages)
 {
 	int ret;
 	struct vm_area_struct *vma;
diff --git a/mm/mprotect.c b/mm/mprotect.c
index a409926..0faa389 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -143,10 +143,10 @@ static void change_protection(struct vm_area_struct *vma,
 
 int
 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
-	unsigned long start, unsigned long end, unsigned long newflags)
+	unsigned long start, unsigned long end, vm_flags_t newflags)
 {
 	struct mm_struct *mm = vma->vm_mm;
-	unsigned long oldflags = vma->vm_flags;
+	vm_flags_t oldflags = vma->vm_flags;
 	long nrpages = (end - start) >> PAGE_SHIFT;
 	unsigned long charged = 0;
 	pgoff_t pgoff;
@@ -232,7 +232,8 @@ fail:
 SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
 		unsigned long, prot)
 {
-	unsigned long vm_flags, nstart, end, tmp, reqprot;
+	unsigned long nstart, end, tmp, reqprot;
+	vm_flags_t vm_flags;
 	struct vm_area_struct *vma, *prev;
 	int error = -EINVAL;
 	const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
@@ -289,7 +290,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
 		prev = vma;
 
 	for (nstart = start ; ; ) {
-		unsigned long newflags;
+		vm_flags_t newflags;
 
 		/* Here we know that  vma->vm_start <= nstart < vma->vm_end. */
 
diff --git a/mm/mremap.c b/mm/mremap.c
index db8d983..c94d1db 100644
--- a/mm/mremap.c
+++ b/mm/mremap.c
@@ -186,7 +186,7 @@ static unsigned long move_vma(struct vm_area_struct *vma,
 {
 	struct mm_struct *mm = vma->vm_mm;
 	struct vm_area_struct *new_vma;
-	unsigned long vm_flags = vma->vm_flags;
+	vm_flags_t vm_flags = vma->vm_flags;
 	unsigned long new_pgoff;
 	unsigned long moved_len;
 	unsigned long excess = 0;
diff --git a/mm/rmap.c b/mm/rmap.c
index 36d01a2..88ccaec 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -691,7 +691,7 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma)
  */
 int page_referenced_one(struct page *page, struct vm_area_struct *vma,
 			unsigned long address, unsigned int *mapcount,
-			unsigned long *vm_flags)
+			vm_flags_t *vm_flags)
 {
 	struct mm_struct *mm = vma->vm_mm;
 	int referenced = 0;
@@ -770,7 +770,7 @@ out:
 
 static int page_referenced_anon(struct page *page,
 				struct mem_cgroup *memcg,
-				unsigned long *vm_flags)
+				vm_flags_t *vm_flags)
 {
 	unsigned int mapcount;
 	struct anon_vma *anon_vma;
@@ -819,7 +819,7 @@ static int page_referenced_anon(struct page *page,
  */
 static int page_referenced_file(struct page *page,
 				struct mem_cgroup *memcg,
-				unsigned long *vm_flags)
+				vm_flags_t *vm_flags)
 {
 	unsigned int mapcount;
 	struct address_space *mapping = page->mapping;
@@ -885,12 +885,12 @@ static int page_referenced_file(struct page *page,
 int page_referenced(struct page *page,
 		    int is_locked,
 		    struct mem_cgroup *memcg,
-		    unsigned long *vm_flags)
+		    vm_flags_t *vm_flags)
 {
 	int referenced = 0;
 	int we_locked = 0;
 
-	*vm_flags = 0;
+	*vm_flags = VM_NONE;
 	if (page_mapped(page) && page_rmapping(page)) {
 		if (!is_locked && (!PageAnon(page) || PageKsm(page))) {
 			we_locked = trylock_page(page);
@@ -1415,7 +1415,7 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
 	 * keep the sem while scanning the cluster for mlocking pages.
 	 */
 	if (down_read_trylock(&vma->vm_mm->mmap_sem)) {
-		locked_vma = (vma->vm_flags & VM_LOCKED);
+		locked_vma = (vma->vm_flags & VM_LOCKED) != VM_NONE;
 		if (!locked_vma)
 			up_read(&vma->vm_mm->mmap_sem); /* don't need it */
 	}
@@ -1466,9 +1466,7 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
 
 bool is_vma_temporary_stack(struct vm_area_struct *vma)
 {
-	int maybe_stack = vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP);
-
-	if (!maybe_stack)
+	if ((vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) == VM_NONE)
 		return false;
 
 	if ((vma->vm_flags & VM_STACK_INCOMPLETE_SETUP) ==
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 57d8ef6..9d3441d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -705,7 +705,7 @@ static enum page_references page_check_references(struct page *page,
 						  struct scan_control *sc)
 {
 	int referenced_ptes, referenced_page;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 
 	referenced_ptes = page_referenced(page, 1, mz->mem_cgroup, &vm_flags);
 	referenced_page = TestClearPageReferenced(page);
@@ -1678,7 +1678,7 @@ static void shrink_active_list(unsigned long nr_to_scan,
 {
 	unsigned long nr_taken;
 	unsigned long nr_scanned;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	LIST_HEAD(l_hold);	/* The pages which were snipped off */
 	LIST_HEAD(l_active);
 	LIST_HEAD(l_inactive);

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 03/16] mm/shmem: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Hugh Dickins, linux-kernel

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h       |    2 +-
 include/linux/shmem_fs.h |    5 ++--
 mm/shmem.c               |   54 +++++++++++++++++++++++++---------------------
 3 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 96f335c..be35c2f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -882,7 +882,7 @@ extern void show_free_areas(unsigned int flags);
 extern bool skip_free_areas_node(unsigned int flags, int nid);
 
 int shmem_lock(struct file *file, int lock, struct user_struct *user);
-struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags);
+struct file *shmem_file_setup(const char *name, loff_t size, vm_flags_t);
 int shmem_zero_setup(struct vm_area_struct *);
 
 extern int can_do_mlock(void);
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 79ab255..db46104 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -10,7 +10,7 @@
 
 struct shmem_inode_info {
 	spinlock_t		lock;
-	unsigned long		flags;
+	vm_flags_t		vm_flags;
 	unsigned long		alloced;	/* data pages alloced to file */
 	union {
 		unsigned long	swapped;	/* subtotal assigned to swap */
@@ -44,8 +44,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
  */
 extern int shmem_init(void);
 extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
-extern struct file *shmem_file_setup(const char *name,
-					loff_t size, unsigned long flags);
+extern struct file *shmem_file_setup(const char *name, loff_t size, vm_flags_t);
 extern int shmem_zero_setup(struct vm_area_struct *);
 extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
 extern void shmem_unlock_mapping(struct address_space *mapping);
diff --git a/mm/shmem.c b/mm/shmem.c
index f99ff3e..38a3d7a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -124,15 +124,15 @@ static inline struct shmem_sb_info *SHMEM_SB(struct super_block *sb)
  * (unless MAP_NORESERVE and sysctl_overcommit_memory <= 1),
  * consistent with the pre-accounting of private mappings ...
  */
-static inline int shmem_acct_size(unsigned long flags, loff_t size)
+static inline int shmem_acct_size(vm_flags_t vm_flags, loff_t size)
 {
-	return (flags & VM_NORESERVE) ?
+	return (vm_flags & VM_NORESERVE) ?
 		0 : security_vm_enough_memory_mm(current->mm, VM_ACCT(size));
 }
 
-static inline void shmem_unacct_size(unsigned long flags, loff_t size)
+static inline void shmem_unacct_size(vm_flags_t vm_flags, loff_t size)
 {
-	if (!(flags & VM_NORESERVE))
+	if (!(vm_flags & VM_NORESERVE))
 		vm_unacct_memory(VM_ACCT(size));
 }
 
@@ -142,15 +142,15 @@ static inline void shmem_unacct_size(unsigned long flags, loff_t size)
  * shmem_getpage reports shmem_acct_block failure as -ENOSPC not -ENOMEM,
  * so that a failure on a sparse tmpfs mapping will give SIGBUS not OOM.
  */
-static inline int shmem_acct_block(unsigned long flags)
+static inline int shmem_acct_block(vm_flags_t vm_flags)
 {
-	return (flags & VM_NORESERVE) ?
+	return (vm_flags & VM_NORESERVE) ?
 		security_vm_enough_memory_mm(current->mm, VM_ACCT(PAGE_CACHE_SIZE)) : 0;
 }
 
-static inline void shmem_unacct_blocks(unsigned long flags, long pages)
+static inline void shmem_unacct_blocks(vm_flags_t vm_flags, long pages)
 {
-	if (flags & VM_NORESERVE)
+	if (vm_flags & VM_NORESERVE)
 		vm_unacct_memory(pages * VM_ACCT(PAGE_CACHE_SIZE));
 }
 
@@ -219,7 +219,7 @@ static void shmem_recalc_inode(struct inode *inode)
 			percpu_counter_add(&sbinfo->used_blocks, -freed);
 		info->alloced -= freed;
 		inode->i_blocks -= freed * BLOCKS_PER_PAGE;
-		shmem_unacct_blocks(info->flags, freed);
+		shmem_unacct_blocks(info->vm_flags, freed);
 	}
 }
 
@@ -580,7 +580,7 @@ static void shmem_evict_inode(struct inode *inode)
 	struct shmem_xattr *xattr, *nxattr;
 
 	if (inode->i_mapping->a_ops == &shmem_aops) {
-		shmem_unacct_size(info->flags, inode->i_size);
+		shmem_unacct_size(info->vm_flags, inode->i_size);
 		inode->i_size = 0;
 		shmem_truncate_range(inode, 0, (loff_t)-1);
 		if (!list_empty(&info->swaplist)) {
@@ -711,7 +711,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
 	index = page->index;
 	inode = mapping->host;
 	info = SHMEM_I(inode);
-	if (info->flags & VM_LOCKED)
+	if (info->vm_flags & VM_LOCKED)
 		goto redirty;
 	if (!total_swap_pages)
 		goto redirty;
@@ -956,7 +956,7 @@ repeat:
 		swap_free(swap);
 
 	} else {
-		if (shmem_acct_block(info->flags)) {
+		if (shmem_acct_block(info->vm_flags)) {
 			error = -ENOSPC;
 			goto failed;
 		}
@@ -1022,7 +1022,7 @@ decused:
 	if (sbinfo->max_blocks)
 		percpu_counter_add(&sbinfo->used_blocks, -1);
 unacct:
-	shmem_unacct_blocks(info->flags, 1);
+	shmem_unacct_blocks(info->vm_flags, 1);
 failed:
 	if (swap.val && error != -EINVAL) {
 		struct page *test = find_get_page(mapping, index);
@@ -1090,15 +1090,15 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user)
 	int retval = -ENOMEM;
 
 	spin_lock(&info->lock);
-	if (lock && !(info->flags & VM_LOCKED)) {
+	if (lock && !(info->vm_flags & VM_LOCKED)) {
 		if (!user_shm_lock(inode->i_size, user))
 			goto out_nomem;
-		info->flags |= VM_LOCKED;
+		info->vm_flags |= VM_LOCKED;
 		mapping_set_unevictable(file->f_mapping);
 	}
-	if (!lock && (info->flags & VM_LOCKED) && user) {
+	if (!lock && (info->vm_flags & VM_LOCKED) && user) {
 		user_shm_unlock(inode->i_size, user);
-		info->flags &= ~VM_LOCKED;
+		info->vm_flags &= ~VM_LOCKED;
 		mapping_clear_unevictable(file->f_mapping);
 	}
 	retval = 0;
@@ -1116,8 +1116,9 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
 	return 0;
 }
 
-static struct inode *shmem_get_inode(struct super_block *sb, const struct inode *dir,
-				     umode_t mode, dev_t dev, unsigned long flags)
+static struct inode *
+shmem_get_inode(struct super_block *sb, const struct inode *dir,
+		umode_t mode, dev_t dev, vm_flags_t vm_flags)
 {
 	struct inode *inode;
 	struct shmem_inode_info *info;
@@ -1137,7 +1138,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
 		info = SHMEM_I(inode);
 		memset(info, 0, (char *)inode - (char *)info);
 		spin_lock_init(&info->lock);
-		info->flags = flags & VM_NORESERVE;
+		info->vm_flags = vm_flags & VM_NORESERVE;
 		INIT_LIST_HEAD(&info->swaplist);
 		INIT_LIST_HEAD(&info->xattr_list);
 		cache_no_acl(inode);
@@ -2534,7 +2535,8 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
 
 #define shmem_vm_ops				generic_file_vm_ops
 #define shmem_file_operations			ramfs_file_operations
-#define shmem_get_inode(sb, dir, mode, dev, flags)	ramfs_get_inode(sb, dir, mode, dev)
+#define shmem_get_inode(sb, dir, mode, dev, vm_flags)	\
+	ramfs_get_inode(sb, dir, mode, dev)
 #define shmem_acct_size(flags, size)		0
 #define shmem_unacct_size(flags, size)		do {} while (0)
 
@@ -2548,7 +2550,8 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
  * @size: size to be set for the file
  * @flags: VM_NORESERVE suppresses pre-accounting of the entire object size
  */
-struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags)
+struct file *
+shmem_file_setup(const char *name, loff_t size, vm_flags_t vm_flags)
 {
 	int error;
 	struct file *file;
@@ -2563,7 +2566,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
 	if (size < 0 || size > MAX_LFS_FILESIZE)
 		return ERR_PTR(-EINVAL);
 
-	if (shmem_acct_size(flags, size))
+	if (shmem_acct_size(vm_flags, size))
 		return ERR_PTR(-ENOMEM);
 
 	error = -ENOMEM;
@@ -2577,7 +2580,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
 	path.mnt = mntget(shm_mnt);
 
 	error = -ENOSPC;
-	inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
+	inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO,
+				0, vm_flags);
 	if (!inode)
 		goto put_dentry;
 
@@ -2601,7 +2605,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
 put_dentry:
 	path_put(&path);
 put_memory:
-	shmem_unacct_size(flags, size);
+	shmem_unacct_size(vm_flags, size);
 	return ERR_PTR(error);
 }
 EXPORT_SYMBOL_GPL(shmem_file_setup);


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 03/16] mm/shmem: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Hugh Dickins, linux-kernel

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h       |    2 +-
 include/linux/shmem_fs.h |    5 ++--
 mm/shmem.c               |   54 +++++++++++++++++++++++++---------------------
 3 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 96f335c..be35c2f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -882,7 +882,7 @@ extern void show_free_areas(unsigned int flags);
 extern bool skip_free_areas_node(unsigned int flags, int nid);
 
 int shmem_lock(struct file *file, int lock, struct user_struct *user);
-struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags);
+struct file *shmem_file_setup(const char *name, loff_t size, vm_flags_t);
 int shmem_zero_setup(struct vm_area_struct *);
 
 extern int can_do_mlock(void);
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 79ab255..db46104 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -10,7 +10,7 @@
 
 struct shmem_inode_info {
 	spinlock_t		lock;
-	unsigned long		flags;
+	vm_flags_t		vm_flags;
 	unsigned long		alloced;	/* data pages alloced to file */
 	union {
 		unsigned long	swapped;	/* subtotal assigned to swap */
@@ -44,8 +44,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
  */
 extern int shmem_init(void);
 extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
-extern struct file *shmem_file_setup(const char *name,
-					loff_t size, unsigned long flags);
+extern struct file *shmem_file_setup(const char *name, loff_t size, vm_flags_t);
 extern int shmem_zero_setup(struct vm_area_struct *);
 extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
 extern void shmem_unlock_mapping(struct address_space *mapping);
diff --git a/mm/shmem.c b/mm/shmem.c
index f99ff3e..38a3d7a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -124,15 +124,15 @@ static inline struct shmem_sb_info *SHMEM_SB(struct super_block *sb)
  * (unless MAP_NORESERVE and sysctl_overcommit_memory <= 1),
  * consistent with the pre-accounting of private mappings ...
  */
-static inline int shmem_acct_size(unsigned long flags, loff_t size)
+static inline int shmem_acct_size(vm_flags_t vm_flags, loff_t size)
 {
-	return (flags & VM_NORESERVE) ?
+	return (vm_flags & VM_NORESERVE) ?
 		0 : security_vm_enough_memory_mm(current->mm, VM_ACCT(size));
 }
 
-static inline void shmem_unacct_size(unsigned long flags, loff_t size)
+static inline void shmem_unacct_size(vm_flags_t vm_flags, loff_t size)
 {
-	if (!(flags & VM_NORESERVE))
+	if (!(vm_flags & VM_NORESERVE))
 		vm_unacct_memory(VM_ACCT(size));
 }
 
@@ -142,15 +142,15 @@ static inline void shmem_unacct_size(unsigned long flags, loff_t size)
  * shmem_getpage reports shmem_acct_block failure as -ENOSPC not -ENOMEM,
  * so that a failure on a sparse tmpfs mapping will give SIGBUS not OOM.
  */
-static inline int shmem_acct_block(unsigned long flags)
+static inline int shmem_acct_block(vm_flags_t vm_flags)
 {
-	return (flags & VM_NORESERVE) ?
+	return (vm_flags & VM_NORESERVE) ?
 		security_vm_enough_memory_mm(current->mm, VM_ACCT(PAGE_CACHE_SIZE)) : 0;
 }
 
-static inline void shmem_unacct_blocks(unsigned long flags, long pages)
+static inline void shmem_unacct_blocks(vm_flags_t vm_flags, long pages)
 {
-	if (flags & VM_NORESERVE)
+	if (vm_flags & VM_NORESERVE)
 		vm_unacct_memory(pages * VM_ACCT(PAGE_CACHE_SIZE));
 }
 
@@ -219,7 +219,7 @@ static void shmem_recalc_inode(struct inode *inode)
 			percpu_counter_add(&sbinfo->used_blocks, -freed);
 		info->alloced -= freed;
 		inode->i_blocks -= freed * BLOCKS_PER_PAGE;
-		shmem_unacct_blocks(info->flags, freed);
+		shmem_unacct_blocks(info->vm_flags, freed);
 	}
 }
 
@@ -580,7 +580,7 @@ static void shmem_evict_inode(struct inode *inode)
 	struct shmem_xattr *xattr, *nxattr;
 
 	if (inode->i_mapping->a_ops == &shmem_aops) {
-		shmem_unacct_size(info->flags, inode->i_size);
+		shmem_unacct_size(info->vm_flags, inode->i_size);
 		inode->i_size = 0;
 		shmem_truncate_range(inode, 0, (loff_t)-1);
 		if (!list_empty(&info->swaplist)) {
@@ -711,7 +711,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc)
 	index = page->index;
 	inode = mapping->host;
 	info = SHMEM_I(inode);
-	if (info->flags & VM_LOCKED)
+	if (info->vm_flags & VM_LOCKED)
 		goto redirty;
 	if (!total_swap_pages)
 		goto redirty;
@@ -956,7 +956,7 @@ repeat:
 		swap_free(swap);
 
 	} else {
-		if (shmem_acct_block(info->flags)) {
+		if (shmem_acct_block(info->vm_flags)) {
 			error = -ENOSPC;
 			goto failed;
 		}
@@ -1022,7 +1022,7 @@ decused:
 	if (sbinfo->max_blocks)
 		percpu_counter_add(&sbinfo->used_blocks, -1);
 unacct:
-	shmem_unacct_blocks(info->flags, 1);
+	shmem_unacct_blocks(info->vm_flags, 1);
 failed:
 	if (swap.val && error != -EINVAL) {
 		struct page *test = find_get_page(mapping, index);
@@ -1090,15 +1090,15 @@ int shmem_lock(struct file *file, int lock, struct user_struct *user)
 	int retval = -ENOMEM;
 
 	spin_lock(&info->lock);
-	if (lock && !(info->flags & VM_LOCKED)) {
+	if (lock && !(info->vm_flags & VM_LOCKED)) {
 		if (!user_shm_lock(inode->i_size, user))
 			goto out_nomem;
-		info->flags |= VM_LOCKED;
+		info->vm_flags |= VM_LOCKED;
 		mapping_set_unevictable(file->f_mapping);
 	}
-	if (!lock && (info->flags & VM_LOCKED) && user) {
+	if (!lock && (info->vm_flags & VM_LOCKED) && user) {
 		user_shm_unlock(inode->i_size, user);
-		info->flags &= ~VM_LOCKED;
+		info->vm_flags &= ~VM_LOCKED;
 		mapping_clear_unevictable(file->f_mapping);
 	}
 	retval = 0;
@@ -1116,8 +1116,9 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
 	return 0;
 }
 
-static struct inode *shmem_get_inode(struct super_block *sb, const struct inode *dir,
-				     umode_t mode, dev_t dev, unsigned long flags)
+static struct inode *
+shmem_get_inode(struct super_block *sb, const struct inode *dir,
+		umode_t mode, dev_t dev, vm_flags_t vm_flags)
 {
 	struct inode *inode;
 	struct shmem_inode_info *info;
@@ -1137,7 +1138,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
 		info = SHMEM_I(inode);
 		memset(info, 0, (char *)inode - (char *)info);
 		spin_lock_init(&info->lock);
-		info->flags = flags & VM_NORESERVE;
+		info->vm_flags = vm_flags & VM_NORESERVE;
 		INIT_LIST_HEAD(&info->swaplist);
 		INIT_LIST_HEAD(&info->xattr_list);
 		cache_no_acl(inode);
@@ -2534,7 +2535,8 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
 
 #define shmem_vm_ops				generic_file_vm_ops
 #define shmem_file_operations			ramfs_file_operations
-#define shmem_get_inode(sb, dir, mode, dev, flags)	ramfs_get_inode(sb, dir, mode, dev)
+#define shmem_get_inode(sb, dir, mode, dev, vm_flags)	\
+	ramfs_get_inode(sb, dir, mode, dev)
 #define shmem_acct_size(flags, size)		0
 #define shmem_unacct_size(flags, size)		do {} while (0)
 
@@ -2548,7 +2550,8 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
  * @size: size to be set for the file
  * @flags: VM_NORESERVE suppresses pre-accounting of the entire object size
  */
-struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags)
+struct file *
+shmem_file_setup(const char *name, loff_t size, vm_flags_t vm_flags)
 {
 	int error;
 	struct file *file;
@@ -2563,7 +2566,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
 	if (size < 0 || size > MAX_LFS_FILESIZE)
 		return ERR_PTR(-EINVAL);
 
-	if (shmem_acct_size(flags, size))
+	if (shmem_acct_size(vm_flags, size))
 		return ERR_PTR(-ENOMEM);
 
 	error = -ENOMEM;
@@ -2577,7 +2580,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
 	path.mnt = mntget(shm_mnt);
 
 	error = -ENOSPC;
-	inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
+	inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO,
+				0, vm_flags);
 	if (!inode)
 		goto put_dentry;
 
@@ -2601,7 +2605,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
 put_dentry:
 	path_put(&path);
 put_memory:
-	shmem_unacct_size(flags, size);
+	shmem_unacct_size(vm_flags, size);
 	return ERR_PTR(error);
 }
 EXPORT_SYMBOL_GPL(shmem_file_setup);

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 04/16] mm/nommu: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Howells, linux-mm, linux-kernel, Greg Ungerer

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Greg Ungerer <gerg@uclinux.org>
---
 fs/proc/nommu.c      |    3 ++-
 fs/proc/task_nommu.c |   14 ++++++++------
 mm/nommu.c           |   19 ++++++++++---------
 3 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index b1822dd..cadc798 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -39,7 +39,8 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
-	int flags, len;
+	int len;
+	vm_flags_t vm_flags;
 
 	flags = region->vm_flags;
 	file = region->vm_file;
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 8aaba8c..9abbc66 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
-	int flags, len;
+	int len;
+	vm_flags_t vm_flags;
 	unsigned long long pgoff = 0;
 
-	flags = vma->vm_flags;
+	vm_flags = vma->vm_flags;
 	file = vma->vm_file;
 
 	if (file) {
@@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
 		   vma->vm_start,
 		   vma->vm_end,
-		   flags & VM_READ ? 'r' : '-',
-		   flags & VM_WRITE ? 'w' : '-',
-		   flags & VM_EXEC ? 'x' : '-',
-		   flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
+		   vm_flags & VM_READ ? 'r' : '-',
+		   vm_flags & VM_WRITE ? 'w' : '-',
+		   vm_flags & VM_EXEC ? 'x' : '-',
+		   vm_flags & VM_MAYSHARE ?
+			vm_flags & VM_SHARED ? 'S' : 's' : 'p',
 		   pgoff,
 		   MAJOR(dev), MINOR(dev), ino, &len);
 
diff --git a/mm/nommu.c b/mm/nommu.c
index f59e170..33d0ab7 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 		     int *retry)
 {
 	struct vm_area_struct *vma;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	int i;
 
 	/* calculate required read or write permissions.
@@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
 /*
  * update protection on a vma
  */
-static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
+static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
 {
 #ifdef CONFIG_MPU
 	struct mm_struct *mm = vma->vm_mm;
 	long start = vma->vm_start & PAGE_MASK;
 	while (start < vma->vm_end) {
-		protect_page(mm, start, flags);
+		protect_page(mm, start, vm_flags);
 		start += PAGE_SIZE;
 	}
 	update_protections(mm);
@@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
  * we've determined that we can make the mapping, now translate what we
  * now know into VMA flags
  */
-static unsigned long determine_vm_flags(struct file *file,
-					unsigned long prot,
-					unsigned long flags,
-					unsigned long capabilities)
+static vm_flags_t determine_vm_flags(struct file *file,
+				     unsigned long prot,
+				     unsigned long flags,
+				     unsigned long capabilities)
 {
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 
 	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
 	/* vm_flags |= mm->def_flags; */
@@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
 	struct vm_area_struct *vma;
 	struct vm_region *region;
 	struct rb_node *rb;
-	unsigned long capabilities, vm_flags, result;
+	unsigned long capabilities, result;
+	vm_flags_t vm_flags;
 	int ret;
 
 	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 04/16] mm/nommu: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Howells, linux-mm, linux-kernel, Greg Ungerer

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Greg Ungerer <gerg@uclinux.org>
---
 fs/proc/nommu.c      |    3 ++-
 fs/proc/task_nommu.c |   14 ++++++++------
 mm/nommu.c           |   19 ++++++++++---------
 3 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index b1822dd..cadc798 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -39,7 +39,8 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
-	int flags, len;
+	int len;
+	vm_flags_t vm_flags;
 
 	flags = region->vm_flags;
 	file = region->vm_file;
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 8aaba8c..9abbc66 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
-	int flags, len;
+	int len;
+	vm_flags_t vm_flags;
 	unsigned long long pgoff = 0;
 
-	flags = vma->vm_flags;
+	vm_flags = vma->vm_flags;
 	file = vma->vm_file;
 
 	if (file) {
@@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
 		   vma->vm_start,
 		   vma->vm_end,
-		   flags & VM_READ ? 'r' : '-',
-		   flags & VM_WRITE ? 'w' : '-',
-		   flags & VM_EXEC ? 'x' : '-',
-		   flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
+		   vm_flags & VM_READ ? 'r' : '-',
+		   vm_flags & VM_WRITE ? 'w' : '-',
+		   vm_flags & VM_EXEC ? 'x' : '-',
+		   vm_flags & VM_MAYSHARE ?
+			vm_flags & VM_SHARED ? 'S' : 's' : 'p',
 		   pgoff,
 		   MAJOR(dev), MINOR(dev), ino, &len);
 
diff --git a/mm/nommu.c b/mm/nommu.c
index f59e170..33d0ab7 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 		     int *retry)
 {
 	struct vm_area_struct *vma;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	int i;
 
 	/* calculate required read or write permissions.
@@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
 /*
  * update protection on a vma
  */
-static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
+static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
 {
 #ifdef CONFIG_MPU
 	struct mm_struct *mm = vma->vm_mm;
 	long start = vma->vm_start & PAGE_MASK;
 	while (start < vma->vm_end) {
-		protect_page(mm, start, flags);
+		protect_page(mm, start, vm_flags);
 		start += PAGE_SIZE;
 	}
 	update_protections(mm);
@@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
  * we've determined that we can make the mapping, now translate what we
  * now know into VMA flags
  */
-static unsigned long determine_vm_flags(struct file *file,
-					unsigned long prot,
-					unsigned long flags,
-					unsigned long capabilities)
+static vm_flags_t determine_vm_flags(struct file *file,
+				     unsigned long prot,
+				     unsigned long flags,
+				     unsigned long capabilities)
 {
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 
 	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
 	/* vm_flags |= mm->def_flags; */
@@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
 	struct vm_area_struct *vma;
 	struct vm_region *region;
 	struct rb_node *rb;
-	unsigned long capabilities, vm_flags, result;
+	unsigned long capabilities, result;
+	vm_flags_t vm_flags;
 	int ret;
 
 	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 05/16] mm/drivers: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: devel, Greg Kroah-Hartman, linux-kernel, Mauro Carvalho Chehab,
	linux-mm, Arve Hjønnevåg, John Stultz,
	Laurent Pinchart, linux-media

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: linux-media@vger.kernel.org
Cc: devel@driverdev.osuosl.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: "Arve Hjønnevåg" <arve@android.com>
---
 drivers/media/video/omap3isp/ispqueue.h |    2 +-
 drivers/staging/android/ashmem.c        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/omap3isp/ispqueue.h b/drivers/media/video/omap3isp/ispqueue.h
index 92c5a12..908dfd7 100644
--- a/drivers/media/video/omap3isp/ispqueue.h
+++ b/drivers/media/video/omap3isp/ispqueue.h
@@ -90,7 +90,7 @@ struct isp_video_buffer {
 	void *vaddr;
 
 	/* For userspace buffers. */
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	unsigned long offset;
 	unsigned int npages;
 	struct page **pages;
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 9f1f27e..4511420 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -269,7 +269,7 @@ out:
 	return ret;
 }
 
-static inline unsigned long calc_vm_may_flags(unsigned long prot)
+static inline vm_flags_t calc_vm_may_flags(unsigned long prot)
 {
 	return _calc_vm_trans(prot, PROT_READ,  VM_MAYREAD) |
 	       _calc_vm_trans(prot, PROT_WRITE, VM_MAYWRITE) |


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 05/16] mm/drivers: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: devel, Greg Kroah-Hartman, linux-kernel, Mauro Carvalho Chehab,
	linux-mm, Arve Hjønnevåg, John Stultz,
	Laurent Pinchart, linux-media

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: linux-media@vger.kernel.org
Cc: devel@driverdev.osuosl.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: John Stultz <john.stultz@linaro.org>
Cc: "Arve HjA,nnevAJPYg" <arve@android.com>
---
 drivers/media/video/omap3isp/ispqueue.h |    2 +-
 drivers/staging/android/ashmem.c        |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/omap3isp/ispqueue.h b/drivers/media/video/omap3isp/ispqueue.h
index 92c5a12..908dfd7 100644
--- a/drivers/media/video/omap3isp/ispqueue.h
+++ b/drivers/media/video/omap3isp/ispqueue.h
@@ -90,7 +90,7 @@ struct isp_video_buffer {
 	void *vaddr;
 
 	/* For userspace buffers. */
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	unsigned long offset;
 	unsigned int npages;
 	struct page **pages;
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 9f1f27e..4511420 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -269,7 +269,7 @@ out:
 	return ret;
 }
 
-static inline unsigned long calc_vm_may_flags(unsigned long prot)
+static inline vm_flags_t calc_vm_may_flags(unsigned long prot)
 {
 	return _calc_vm_trans(prot, PROT_READ,  VM_MAYREAD) |
 	       _calc_vm_trans(prot, PROT_WRITE, VM_MAYWRITE) |

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 06/16] mm/x86: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: x86, linux-kernel, linux-mm, Ingo Molnar, H. Peter Anvin,
	Thomas Gleixner

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/mm/hugetlbpage.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index 6b52d81..b25e9bd 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -26,8 +26,8 @@ static unsigned long page_table_shareable(struct vm_area_struct *svma,
 	unsigned long s_end = sbase + PUD_SIZE;
 
 	/* Allow segments to share if only one is marked locked */
-	unsigned long vm_flags = vma->vm_flags & ~VM_LOCKED;
-	unsigned long svm_flags = svma->vm_flags & ~VM_LOCKED;
+	vm_flags_t vm_flags = vma->vm_flags & ~VM_LOCKED;
+	vm_flags_t svm_flags = svma->vm_flags & ~VM_LOCKED;
 
 	/*
 	 * match the virtual addresses, permission and the alignment of the


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 06/16] mm/x86: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: x86, linux-kernel, linux-mm, Ingo Molnar, H. Peter Anvin,
	Thomas Gleixner

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/mm/hugetlbpage.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
index 6b52d81..b25e9bd 100644
--- a/arch/x86/mm/hugetlbpage.c
+++ b/arch/x86/mm/hugetlbpage.c
@@ -26,8 +26,8 @@ static unsigned long page_table_shareable(struct vm_area_struct *svma,
 	unsigned long s_end = sbase + PUD_SIZE;
 
 	/* Allow segments to share if only one is marked locked */
-	unsigned long vm_flags = vma->vm_flags & ~VM_LOCKED;
-	unsigned long svm_flags = svma->vm_flags & ~VM_LOCKED;
+	vm_flags_t vm_flags = vma->vm_flags & ~VM_LOCKED;
+	vm_flags_t svm_flags = svma->vm_flags & ~VM_LOCKED;
 
 	/*
 	 * match the virtual addresses, permission and the alignment of the

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 07/16] mm/arm: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
  (?)
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Russell King, linux-kernel, linux-arm-kernel

Cast vm_flags to unsigned int for __cpuc_flush_user_range(),
because its vm_flags argument declared as unsigned int.
Asssembler code wants to test VM_EXEC bit on vma->vm_flags,
but for big-endian we should get upper word for this.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/include/asm/cacheflush.h |    5 +++--
 arch/arm/kernel/asm-offsets.c     |    6 +++++-
 arch/arm/mm/fault.c               |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index d5d8d5c..5aab2c4 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -217,7 +217,7 @@ vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
 {
 	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm)))
 		__cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
-					vma->vm_flags);
+					(__force unsigned int)vma->vm_flags);
 }
 
 static inline void
@@ -225,7 +225,8 @@ vivt_flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsig
 {
 	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) {
 		unsigned long addr = user_addr & PAGE_MASK;
-		__cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
+		__cpuc_flush_user_range(addr, addr + PAGE_SIZE,
+					(__force unsigned int)vma->vm_flags);
 	}
 }
 
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 1429d89..8150c7e 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -109,9 +109,13 @@ int main(void)
   BLANK();
 #endif
   DEFINE(VMA_VM_MM,		offsetof(struct vm_area_struct, vm_mm));
+#if defined(CONFIG_CPU_BIG_ENDIAN) && (NR_VMA_FLAGS > 32)
+  DEFINE(VMA_VM_FLAGS,		offsetof(struct vm_area_struct, vm_flags) + 4);
+#else
   DEFINE(VMA_VM_FLAGS,		offsetof(struct vm_area_struct, vm_flags));
+#endif
   BLANK();
-  DEFINE(VM_EXEC,	       	VM_EXEC);
+  DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);
   BLANK();
   DEFINE(PAGE_SZ,	       	PAGE_SIZE);
   BLANK();
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 40c43a9..371ad65 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -209,7 +209,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  */
 static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
 {
-	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
+	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
 
 	if (fsr & FSR_WRITE)
 		mask = VM_WRITE;


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 07/16] mm/arm: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Russell King, linux-kernel, linux-arm-kernel

Cast vm_flags to unsigned int for __cpuc_flush_user_range(),
because its vm_flags argument declared as unsigned int.
Asssembler code wants to test VM_EXEC bit on vma->vm_flags,
but for big-endian we should get upper word for this.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/include/asm/cacheflush.h |    5 +++--
 arch/arm/kernel/asm-offsets.c     |    6 +++++-
 arch/arm/mm/fault.c               |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index d5d8d5c..5aab2c4 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -217,7 +217,7 @@ vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
 {
 	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm)))
 		__cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
-					vma->vm_flags);
+					(__force unsigned int)vma->vm_flags);
 }
 
 static inline void
@@ -225,7 +225,8 @@ vivt_flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsig
 {
 	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) {
 		unsigned long addr = user_addr & PAGE_MASK;
-		__cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
+		__cpuc_flush_user_range(addr, addr + PAGE_SIZE,
+					(__force unsigned int)vma->vm_flags);
 	}
 }
 
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 1429d89..8150c7e 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -109,9 +109,13 @@ int main(void)
   BLANK();
 #endif
   DEFINE(VMA_VM_MM,		offsetof(struct vm_area_struct, vm_mm));
+#if defined(CONFIG_CPU_BIG_ENDIAN) && (NR_VMA_FLAGS > 32)
+  DEFINE(VMA_VM_FLAGS,		offsetof(struct vm_area_struct, vm_flags) + 4);
+#else
   DEFINE(VMA_VM_FLAGS,		offsetof(struct vm_area_struct, vm_flags));
+#endif
   BLANK();
-  DEFINE(VM_EXEC,	       	VM_EXEC);
+  DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);
   BLANK();
   DEFINE(PAGE_SZ,	       	PAGE_SIZE);
   BLANK();
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 40c43a9..371ad65 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -209,7 +209,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  */
 static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
 {
-	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
+	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
 
 	if (fsr & FSR_WRITE)
 		mask = VM_WRITE;

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 07/16] mm/arm: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

Cast vm_flags to unsigned int for __cpuc_flush_user_range(),
because its vm_flags argument declared as unsigned int.
Asssembler code wants to test VM_EXEC bit on vma->vm_flags,
but for big-endian we should get upper word for this.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
---
 arch/arm/include/asm/cacheflush.h |    5 +++--
 arch/arm/kernel/asm-offsets.c     |    6 +++++-
 arch/arm/mm/fault.c               |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
index d5d8d5c..5aab2c4 100644
--- a/arch/arm/include/asm/cacheflush.h
+++ b/arch/arm/include/asm/cacheflush.h
@@ -217,7 +217,7 @@ vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
 {
 	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm)))
 		__cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
-					vma->vm_flags);
+					(__force unsigned int)vma->vm_flags);
 }
 
 static inline void
@@ -225,7 +225,8 @@ vivt_flush_cache_page(struct vm_area_struct *vma, unsigned long user_addr, unsig
 {
 	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm))) {
 		unsigned long addr = user_addr & PAGE_MASK;
-		__cpuc_flush_user_range(addr, addr + PAGE_SIZE, vma->vm_flags);
+		__cpuc_flush_user_range(addr, addr + PAGE_SIZE,
+					(__force unsigned int)vma->vm_flags);
 	}
 }
 
diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c
index 1429d89..8150c7e 100644
--- a/arch/arm/kernel/asm-offsets.c
+++ b/arch/arm/kernel/asm-offsets.c
@@ -109,9 +109,13 @@ int main(void)
   BLANK();
 #endif
   DEFINE(VMA_VM_MM,		offsetof(struct vm_area_struct, vm_mm));
+#if defined(CONFIG_CPU_BIG_ENDIAN) && (NR_VMA_FLAGS > 32)
+  DEFINE(VMA_VM_FLAGS,		offsetof(struct vm_area_struct, vm_flags) + 4);
+#else
   DEFINE(VMA_VM_FLAGS,		offsetof(struct vm_area_struct, vm_flags));
+#endif
   BLANK();
-  DEFINE(VM_EXEC,	       	VM_EXEC);
+  DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);
   BLANK();
   DEFINE(PAGE_SZ,	       	PAGE_SIZE);
   BLANK();
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 40c43a9..371ad65 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -209,7 +209,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  */
 static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
 {
-	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
+	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
 
 	if (fsr & FSR_WRITE)
 		mask = VM_WRITE;

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 08/16] mm/unicore32: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Guan Xuetao, linux-kernel

The same magic like in arm: assembler code wants to test VM_EXEC,
but for big-endian we should get upper word for this.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
 arch/unicore32/kernel/asm-offsets.c |    6 +++++-
 arch/unicore32/mm/fault.c           |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/unicore32/kernel/asm-offsets.c b/arch/unicore32/kernel/asm-offsets.c
index ffcbe75..e3199b5 100644
--- a/arch/unicore32/kernel/asm-offsets.c
+++ b/arch/unicore32/kernel/asm-offsets.c
@@ -87,9 +87,13 @@ int main(void)
 	DEFINE(S_FRAME_SIZE,	sizeof(struct pt_regs));
 	BLANK();
 	DEFINE(VMA_VM_MM,	offsetof(struct vm_area_struct, vm_mm));
+#if defined(CONFIG_CPU_BIG_ENDIAN) && (NR_VMA_FLAGS > 32)
+	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags) + 4);
+#else
 	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags));
+#endif
 	BLANK();
-	DEFINE(VM_EXEC,		VM_EXEC);
+	DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);
 	BLANK();
 	DEFINE(PAGE_SZ,		PAGE_SIZE);
 	BLANK();
diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
index 283aa4b..9137996 100644
--- a/arch/unicore32/mm/fault.c
+++ b/arch/unicore32/mm/fault.c
@@ -158,7 +158,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  */
 static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
 {
-	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
+	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
 
 	if (!(fsr ^ 0x12))	/* write? */
 		mask = VM_WRITE;


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 08/16] mm/unicore32: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Guan Xuetao, linux-kernel

The same magic like in arm: assembler code wants to test VM_EXEC,
but for big-endian we should get upper word for this.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
---
 arch/unicore32/kernel/asm-offsets.c |    6 +++++-
 arch/unicore32/mm/fault.c           |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/unicore32/kernel/asm-offsets.c b/arch/unicore32/kernel/asm-offsets.c
index ffcbe75..e3199b5 100644
--- a/arch/unicore32/kernel/asm-offsets.c
+++ b/arch/unicore32/kernel/asm-offsets.c
@@ -87,9 +87,13 @@ int main(void)
 	DEFINE(S_FRAME_SIZE,	sizeof(struct pt_regs));
 	BLANK();
 	DEFINE(VMA_VM_MM,	offsetof(struct vm_area_struct, vm_mm));
+#if defined(CONFIG_CPU_BIG_ENDIAN) && (NR_VMA_FLAGS > 32)
+	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags) + 4);
+#else
 	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags));
+#endif
 	BLANK();
-	DEFINE(VM_EXEC,		VM_EXEC);
+	DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);
 	BLANK();
 	DEFINE(PAGE_SZ,		PAGE_SIZE);
 	BLANK();
diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
index 283aa4b..9137996 100644
--- a/arch/unicore32/mm/fault.c
+++ b/arch/unicore32/mm/fault.c
@@ -158,7 +158,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  */
 static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
 {
-	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
+	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
 
 	if (!(fsr ^ 0x12))	/* write? */
 		mask = VM_WRITE;

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 09/16] mm/ia64: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
  (?)
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Tony Luck, linux-ia64, linux-kernel, Fenghua Yu

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
---
 arch/ia64/mm/fault.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index 20b3593..e50259d 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -80,7 +80,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
 	struct vm_area_struct *vma, *prev_vma;
 	struct mm_struct *mm = current->mm;
 	struct siginfo si;
-	unsigned long mask;
+	vm_flags_t mask;
 	int fault;
 
 	/* mmap_sem is performance critical.... */
@@ -135,10 +135,9 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
 #	define VM_WRITE_BIT	1
 #	define VM_EXEC_BIT	2
 
-#	if (((1 << VM_READ_BIT) != VM_READ || (1 << VM_WRITE_BIT) != VM_WRITE) \
-	    || (1 << VM_EXEC_BIT) != VM_EXEC)
-#		error File is out of sync with <linux/mm.h>.  Please update.
-#	endif
+	BUILD_BUG_ON((1 << VM_READ_BIT) != VM_READ);
+	BUILD_BUG_ON((1 << VM_WRITE_BIT) != VM_WRITE);
+	BUILD_BUG_ON((1 << VM_EXEC_BIT) != VM_EXEC);
 
 	if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
 		goto bad_area;


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 09/16] mm/ia64: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Tony Luck, linux-ia64, linux-kernel, Fenghua Yu

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
---
 arch/ia64/mm/fault.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index 20b3593..e50259d 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -80,7 +80,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
 	struct vm_area_struct *vma, *prev_vma;
 	struct mm_struct *mm = current->mm;
 	struct siginfo si;
-	unsigned long mask;
+	vm_flags_t mask;
 	int fault;
 
 	/* mmap_sem is performance critical.... */
@@ -135,10 +135,9 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
 #	define VM_WRITE_BIT	1
 #	define VM_EXEC_BIT	2
 
-#	if (((1 << VM_READ_BIT) != VM_READ || (1 << VM_WRITE_BIT) != VM_WRITE) \
-	    || (1 << VM_EXEC_BIT) != VM_EXEC)
-#		error File is out of sync with <linux/mm.h>.  Please update.
-#	endif
+	BUILD_BUG_ON((1 << VM_READ_BIT) != VM_READ);
+	BUILD_BUG_ON((1 << VM_WRITE_BIT) != VM_WRITE);
+	BUILD_BUG_ON((1 << VM_EXEC_BIT) != VM_EXEC);
 
 	if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
 		goto bad_area;

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 09/16] mm/ia64: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, Tony Luck, linux-ia64, linux-kernel, Fenghua Yu

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
---
 arch/ia64/mm/fault.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
index 20b3593..e50259d 100644
--- a/arch/ia64/mm/fault.c
+++ b/arch/ia64/mm/fault.c
@@ -80,7 +80,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
 	struct vm_area_struct *vma, *prev_vma;
 	struct mm_struct *mm = current->mm;
 	struct siginfo si;
-	unsigned long mask;
+	vm_flags_t mask;
 	int fault;
 
 	/* mmap_sem is performance critical.... */
@@ -135,10 +135,9 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
 #	define VM_WRITE_BIT	1
 #	define VM_EXEC_BIT	2
 
-#	if (((1 << VM_READ_BIT) != VM_READ || (1 << VM_WRITE_BIT) != VM_WRITE) \
-	    || (1 << VM_EXEC_BIT) != VM_EXEC)
-#		error File is out of sync with <linux/mm.h>.  Please update.
-#	endif
+	BUILD_BUG_ON((1 << VM_READ_BIT) != VM_READ);
+	BUILD_BUG_ON((1 << VM_WRITE_BIT) != VM_WRITE);
+	BUILD_BUG_ON((1 << VM_EXEC_BIT) != VM_EXEC);
 
 	if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
 		goto bad_area;


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 10/16] mm/powerpc: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
  (?)
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linuxppc-dev, Paul Mackerras, linux-kernel,
	Benjamin Herrenschmidt

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/include/asm/mman.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
index d4a7f64..451de1c 100644
--- a/arch/powerpc/include/asm/mman.h
+++ b/arch/powerpc/include/asm/mman.h
@@ -44,7 +44,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
 }
 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
 
-static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
+static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
 {
 	return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
 }


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 10/16] mm/powerpc: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linuxppc-dev, Paul Mackerras, linux-kernel,
	Benjamin Herrenschmidt

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/include/asm/mman.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
index d4a7f64..451de1c 100644
--- a/arch/powerpc/include/asm/mman.h
+++ b/arch/powerpc/include/asm/mman.h
@@ -44,7 +44,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
 }
 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
 
-static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
+static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
 {
 	return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
 }

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 10/16] mm/powerpc: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linuxppc-dev, linux-kernel, Paul Mackerras

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/include/asm/mman.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
index d4a7f64..451de1c 100644
--- a/arch/powerpc/include/asm/mman.h
+++ b/arch/powerpc/include/asm/mman.h
@@ -44,7 +44,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
 }
 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
 
-static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
+static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
 {
 	return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
 }

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 11/16] mm/s390: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-s390, Heiko Carstens, linux-kernel, linux-mm,
	Martin Schwidefsky, linux390

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
 arch/s390/mm/fault.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index b17c42d..f8909e5 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -260,7 +260,7 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault)
  *   11       Page translation     ->  Not present       (nullification)
  *   3b       Region third trans.  ->  Not present       (nullification)
  */
-static inline int do_exception(struct pt_regs *regs, int access)
+static inline int do_exception(struct pt_regs *regs, vm_flags_t access)
 {
 	struct task_struct *tsk;
 	struct mm_struct *mm;
@@ -399,7 +399,8 @@ void __kprobes do_protection_exception(struct pt_regs *regs)
 
 void __kprobes do_dat_exception(struct pt_regs *regs)
 {
-	int access, fault;
+	int fault;
+	vm_flags_t access;
 
 	access = VM_READ | VM_EXEC | VM_WRITE;
 	fault = do_exception(regs, access);
@@ -441,7 +442,8 @@ no_context:
 int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
 {
 	struct pt_regs regs;
-	int access, fault;
+	int fault;
+	vm_flags_t access;
 
 	regs.psw.mask = psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK;
 	if (!irqs_disabled())


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 11/16] mm/s390: use vm_flags_t for vma flags
@ 2012-03-21  6:56   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:56 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-s390, Heiko Carstens, linux-kernel, linux-mm,
	Martin Schwidefsky, linux390

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
 arch/s390/mm/fault.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c
index b17c42d..f8909e5 100644
--- a/arch/s390/mm/fault.c
+++ b/arch/s390/mm/fault.c
@@ -260,7 +260,7 @@ static noinline void do_fault_error(struct pt_regs *regs, int fault)
  *   11       Page translation     ->  Not present       (nullification)
  *   3b       Region third trans.  ->  Not present       (nullification)
  */
-static inline int do_exception(struct pt_regs *regs, int access)
+static inline int do_exception(struct pt_regs *regs, vm_flags_t access)
 {
 	struct task_struct *tsk;
 	struct mm_struct *mm;
@@ -399,7 +399,8 @@ void __kprobes do_protection_exception(struct pt_regs *regs)
 
 void __kprobes do_dat_exception(struct pt_regs *regs)
 {
-	int access, fault;
+	int fault;
+	vm_flags_t access;
 
 	access = VM_READ | VM_EXEC | VM_WRITE;
 	fault = do_exception(regs, access);
@@ -441,7 +442,8 @@ no_context:
 int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
 {
 	struct pt_regs regs;
-	int access, fault;
+	int fault;
+	vm_flags_t access;
 
 	regs.psw.mask = psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK;
 	if (!irqs_disabled())

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 12/16] mm/mips: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Ralf Baechle, linux-mips

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
---
 arch/mips/mm/c-r3k.c  |    2 +-
 arch/mips/mm/c-r4k.c  |    6 +++---
 arch/mips/mm/c-tx39.c |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/mips/mm/c-r3k.c b/arch/mips/mm/c-r3k.c
index 0765583..0ae0684 100644
--- a/arch/mips/mm/c-r3k.c
+++ b/arch/mips/mm/c-r3k.c
@@ -239,7 +239,7 @@ static void r3k_flush_cache_page(struct vm_area_struct *vma,
 				 unsigned long addr, unsigned long pfn)
 {
 	unsigned long kaddr = KSEG0ADDR(pfn << PAGE_SHIFT);
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	struct mm_struct *mm = vma->vm_mm;
 	pgd_t *pgdp;
 	pud_t *pudp;
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index c97087d..94b2b89 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -394,7 +394,7 @@ static void r4k__flush_cache_vunmap(void)
 static inline void local_r4k_flush_cache_range(void * args)
 {
 	struct vm_area_struct *vma = args;
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 
 	if (!(has_valid_asid(vma->vm_mm)))
 		return;
@@ -407,7 +407,7 @@ static inline void local_r4k_flush_cache_range(void * args)
 static void r4k_flush_cache_range(struct vm_area_struct *vma,
 	unsigned long start, unsigned long end)
 {
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 
 	if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc))
 		r4k_on_each_cpu(local_r4k_flush_cache_range, vma);
@@ -457,7 +457,7 @@ static inline void local_r4k_flush_cache_page(void *args)
 	struct vm_area_struct *vma = fcp_args->vma;
 	unsigned long addr = fcp_args->addr;
 	struct page *page = pfn_to_page(fcp_args->pfn);
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	struct mm_struct *mm = vma->vm_mm;
 	int map_coherent = 0;
 	pgd_t *pgdp;
diff --git a/arch/mips/mm/c-tx39.c b/arch/mips/mm/c-tx39.c
index a43c197c..1227670 100644
--- a/arch/mips/mm/c-tx39.c
+++ b/arch/mips/mm/c-tx39.c
@@ -169,7 +169,7 @@ static void tx39_flush_cache_range(struct vm_area_struct *vma,
 
 static void tx39_flush_cache_page(struct vm_area_struct *vma, unsigned long page, unsigned long pfn)
 {
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	struct mm_struct *mm = vma->vm_mm;
 	pgd_t *pgdp;
 	pud_t *pudp;


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 12/16] mm/mips: use vm_flags_t for vma flags
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Ralf Baechle, linux-mips

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
---
 arch/mips/mm/c-r3k.c  |    2 +-
 arch/mips/mm/c-r4k.c  |    6 +++---
 arch/mips/mm/c-tx39.c |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/mips/mm/c-r3k.c b/arch/mips/mm/c-r3k.c
index 0765583..0ae0684 100644
--- a/arch/mips/mm/c-r3k.c
+++ b/arch/mips/mm/c-r3k.c
@@ -239,7 +239,7 @@ static void r3k_flush_cache_page(struct vm_area_struct *vma,
 				 unsigned long addr, unsigned long pfn)
 {
 	unsigned long kaddr = KSEG0ADDR(pfn << PAGE_SHIFT);
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	struct mm_struct *mm = vma->vm_mm;
 	pgd_t *pgdp;
 	pud_t *pudp;
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index c97087d..94b2b89 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -394,7 +394,7 @@ static void r4k__flush_cache_vunmap(void)
 static inline void local_r4k_flush_cache_range(void * args)
 {
 	struct vm_area_struct *vma = args;
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 
 	if (!(has_valid_asid(vma->vm_mm)))
 		return;
@@ -407,7 +407,7 @@ static inline void local_r4k_flush_cache_range(void * args)
 static void r4k_flush_cache_range(struct vm_area_struct *vma,
 	unsigned long start, unsigned long end)
 {
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 
 	if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc))
 		r4k_on_each_cpu(local_r4k_flush_cache_range, vma);
@@ -457,7 +457,7 @@ static inline void local_r4k_flush_cache_page(void *args)
 	struct vm_area_struct *vma = fcp_args->vma;
 	unsigned long addr = fcp_args->addr;
 	struct page *page = pfn_to_page(fcp_args->pfn);
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	struct mm_struct *mm = vma->vm_mm;
 	int map_coherent = 0;
 	pgd_t *pgdp;
diff --git a/arch/mips/mm/c-tx39.c b/arch/mips/mm/c-tx39.c
index a43c197c..1227670 100644
--- a/arch/mips/mm/c-tx39.c
+++ b/arch/mips/mm/c-tx39.c
@@ -169,7 +169,7 @@ static void tx39_flush_cache_range(struct vm_area_struct *vma,
 
 static void tx39_flush_cache_page(struct vm_area_struct *vma, unsigned long page, unsigned long pfn)
 {
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	struct mm_struct *mm = vma->vm_mm;
 	pgd_t *pgdp;
 	pud_t *pudp;

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 13/16] mm/parisc: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Helge Deller, linux-kernel, linux-parisc, James E.J. Bottomley

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-parisc@vger.kernel.org
---
 arch/parisc/mm/fault.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index 18162ce..0d3680a 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -49,7 +49,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
  *   VM_WRITE if write operation
  *   VM_EXEC  if execute operation
  */
-static unsigned long
+static vm_flags_t
 parisc_acctyp(unsigned long code, unsigned int inst)
 {
 	if (code == 6 || code == 16)
@@ -173,7 +173,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
 	struct vm_area_struct *vma, *prev_vma;
 	struct task_struct *tsk = current;
 	struct mm_struct *mm = tsk->mm;
-	unsigned long acc_type;
+	vm_flags_t acc_type;
 	int fault;
 
 	if (in_atomic() || !mm)

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 13/16] mm/parisc: use vm_flags_t for vma flags
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Helge Deller, linux-kernel, linux-parisc, James E.J. Bottomley

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Cc: linux-parisc@vger.kernel.org
---
 arch/parisc/mm/fault.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index 18162ce..0d3680a 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -49,7 +49,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
  *   VM_WRITE if write operation
  *   VM_EXEC  if execute operation
  */
-static unsigned long
+static vm_flags_t
 parisc_acctyp(unsigned long code, unsigned int inst)
 {
 	if (code == 6 || code == 16)
@@ -173,7 +173,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
 	struct vm_area_struct *vma, *prev_vma;
 	struct task_struct *tsk = current;
 	struct mm_struct *mm = tsk->mm;
-	unsigned long acc_type;
+	vm_flags_t acc_type;
 	int fault;
 
 	if (in_atomic() || !mm)


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 14/16] mm/score: use vm_flags_t for vma flags
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Lennox Wu, Chen Liqin

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Chen Liqin <liqin.chen@sunplusct.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
---
 arch/score/mm/cache.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/score/mm/cache.c b/arch/score/mm/cache.c
index b25e957..2288ffc 100644
--- a/arch/score/mm/cache.c
+++ b/arch/score/mm/cache.c
@@ -79,7 +79,7 @@ void __update_cache(struct vm_area_struct *vma, unsigned long address,
 {
 	struct page *page;
 	unsigned long pfn, addr;
-	int exec = (vma->vm_flags & VM_EXEC);
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 
 	pfn = pte_pfn(pte);
 	if (unlikely(!pfn_valid(pfn)))
@@ -172,7 +172,7 @@ void flush_cache_range(struct vm_area_struct *vma,
 		unsigned long start, unsigned long end)
 {
 	struct mm_struct *mm = vma->vm_mm;
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	pgd_t *pgdp;
 	pud_t *pudp;
 	pmd_t *pmdp;
@@ -210,7 +210,7 @@ void flush_cache_range(struct vm_area_struct *vma,
 void flush_cache_page(struct vm_area_struct *vma,
 		unsigned long addr, unsigned long pfn)
 {
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	unsigned long kaddr = 0xa0000000 | (pfn << PAGE_SHIFT);
 
 	flush_dcache_range(kaddr, kaddr + PAGE_SIZE);


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 14/16] mm/score: use vm_flags_t for vma flags
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, Lennox Wu, Chen Liqin

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Chen Liqin <liqin.chen@sunplusct.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
---
 arch/score/mm/cache.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/score/mm/cache.c b/arch/score/mm/cache.c
index b25e957..2288ffc 100644
--- a/arch/score/mm/cache.c
+++ b/arch/score/mm/cache.c
@@ -79,7 +79,7 @@ void __update_cache(struct vm_area_struct *vma, unsigned long address,
 {
 	struct page *page;
 	unsigned long pfn, addr;
-	int exec = (vma->vm_flags & VM_EXEC);
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 
 	pfn = pte_pfn(pte);
 	if (unlikely(!pfn_valid(pfn)))
@@ -172,7 +172,7 @@ void flush_cache_range(struct vm_area_struct *vma,
 		unsigned long start, unsigned long end)
 {
 	struct mm_struct *mm = vma->vm_mm;
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	pgd_t *pgdp;
 	pud_t *pudp;
 	pmd_t *pmdp;
@@ -210,7 +210,7 @@ void flush_cache_range(struct vm_area_struct *vma,
 void flush_cache_page(struct vm_area_struct *vma,
 		unsigned long addr, unsigned long pfn)
 {
-	int exec = vma->vm_flags & VM_EXEC;
+	int exec = (vma->vm_flags & VM_EXEC) != VM_NONE;
 	unsigned long kaddr = 0xa0000000 | (pfn << PAGE_SHIFT);
 
 	flush_dcache_range(kaddr, kaddr + PAGE_SIZE);

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 15/16] mm: cast vm_flags_t to u64 before printing
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel

Let's always print vm_flags_t as u64, thus now we can freely change
vm_flags_t's size depending on target achitecture or config options.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
 arch/sh/mm/tlbflush_64.c                         |    2 +-
 drivers/infiniband/hw/ipath/ipath_file_ops.c     |    6 ++++--
 drivers/infiniband/hw/qib/qib_file_ops.c         |    6 ++++--
 drivers/staging/android/binder.c                 |   15 ++++++++------
 drivers/staging/tidspbridge/core/tiomap3430.c    |   13 ++++++------
 drivers/staging/tidspbridge/rmgr/drv_interface.c |    4 ++--
 fs/binfmt_elf_fdpic.c                            |   24 ++++++++++++++--------
 mm/memory.c                                      |    5 +++--
 8 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/arch/sh/mm/tlbflush_64.c b/arch/sh/mm/tlbflush_64.c
index e3430e0..b798e7f 100644
--- a/arch/sh/mm/tlbflush_64.c
+++ b/arch/sh/mm/tlbflush_64.c
@@ -48,7 +48,7 @@ static inline void print_vma(struct vm_area_struct *vma)
 	printk("vma end   0x%08lx\n", vma->vm_end);
 
 	print_prots(vma->vm_page_prot);
-	printk("vm_flags 0x%08lx\n", vma->vm_flags);
+	printk("vm_flags 0x%08llx\n", (__force u64)vma->vm_flags);
 }
 
 static inline void print_task(struct task_struct *tsk)
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 736d9ed..b3dfa21 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -1115,7 +1115,8 @@ static int mmap_rcvegrbufs(struct vm_area_struct *vma,
 
 	if (vma->vm_flags & VM_WRITE) {
 		dev_info(&dd->pcidev->dev, "Can't map eager buffers as "
-			 "writable (flags=%lx)\n", vma->vm_flags);
+			 "writable (flags=%llx)\n",
+			 (__force u64)vma->vm_flags);
 		ret = -EPERM;
 		goto bail;
 	}
@@ -1204,7 +1205,8 @@ static int mmap_kvaddr(struct vm_area_struct *vma, u64 pgaddr,
                 if (vma->vm_flags & VM_WRITE) {
                         dev_info(&dd->pcidev->dev,
                                  "Can't map eager buffers as "
-                                 "writable (flags=%lx)\n", vma->vm_flags);
+				 "writable (flags=%llx)\n",
+				 (__force u64)vma->vm_flags);
                         ret = -EPERM;
                         goto bail;
                 }
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
index a740324..0fe928d 100644
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -857,7 +857,8 @@ static int mmap_rcvegrbufs(struct vm_area_struct *vma,
 
 	if (vma->vm_flags & VM_WRITE) {
 		qib_devinfo(dd->pcidev, "Can't map eager buffers as "
-			 "writable (flags=%lx)\n", vma->vm_flags);
+			 "writable (flags=%llx)\n",
+			 (__force u64)vma->vm_flags);
 		ret = -EPERM;
 		goto bail;
 	}
@@ -946,7 +947,8 @@ static int mmap_kvaddr(struct vm_area_struct *vma, u64 pgaddr,
 		if (vma->vm_flags & VM_WRITE) {
 			qib_devinfo(dd->pcidev,
 				 "Can't map eager buffers as "
-				 "writable (flags=%lx)\n", vma->vm_flags);
+				 "writable (flags=%llx)\n",
+				 (__force u64)vma->vm_flags);
 			ret = -EPERM;
 			goto bail;
 		}
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index c283212..b0d03e0 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -2761,9 +2761,10 @@ static void binder_vma_open(struct vm_area_struct *vma)
 {
 	struct binder_proc *proc = vma->vm_private_data;
 	binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-		     "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
+		     "binder: %d open vm area %lx-%lx (%ld K) vma %llx pagep %lx\n",
 		     proc->pid, vma->vm_start, vma->vm_end,
-		     (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+		     (vma->vm_end - vma->vm_start) / SZ_1K,
+		     (__force u64)vma->vm_flags,
 		     (unsigned long)pgprot_val(vma->vm_page_prot));
 }
 
@@ -2771,9 +2772,10 @@ static void binder_vma_close(struct vm_area_struct *vma)
 {
 	struct binder_proc *proc = vma->vm_private_data;
 	binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-		     "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
+		     "binder: %d close vm area %lx-%lx (%ld K) vma %llx pagep %lx\n",
 		     proc->pid, vma->vm_start, vma->vm_end,
-		     (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+		     (vma->vm_end - vma->vm_start) / SZ_1K,
+		     (__force u64)vma->vm_flags,
 		     (unsigned long)pgprot_val(vma->vm_page_prot));
 	proc->vma = NULL;
 	proc->vma_vm_mm = NULL;
@@ -2797,9 +2799,10 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
 		vma->vm_end = vma->vm_start + SZ_4M;
 
 	binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-		     "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n",
+		     "binder_mmap: %d %lx-%lx (%ld K) vma %llx pagep %lx\n",
 		     proc->pid, vma->vm_start, vma->vm_end,
-		     (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+		     (vma->vm_end - vma->vm_start) / SZ_1K,
+		     (__force u64)vma->vm_flags,
 		     (unsigned long)pgprot_val(vma->vm_page_prot));
 
 	if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
index 7862513..328a9ab 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430.c
@@ -1216,9 +1216,9 @@ static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
 	if (vma)
 		dev_dbg(bridge,
 			"VMAfor UserBuf: ul_mpu_addr=%x, ul_num_bytes=%x, "
-			"vm_start=%lx, vm_end=%lx, vm_flags=%lx\n", ul_mpu_addr,
+			"vm_start=%lx, vm_end=%lx, vm_flags=%llx\n", ul_mpu_addr,
 			ul_num_bytes, vma->vm_start, vma->vm_end,
-			vma->vm_flags);
+			(__force u64)vma->vm_flags);
 
 	/*
 	 * It is observed that under some circumstances, the user buffer is
@@ -1230,9 +1230,9 @@ static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
 		vma = find_vma(mm, vma->vm_end + 1);
 		dev_dbg(bridge,
 			"VMA for UserBuf ul_mpu_addr=%x ul_num_bytes=%x, "
-			"vm_start=%lx, vm_end=%lx, vm_flags=%lx\n", ul_mpu_addr,
+			"vm_start=%lx, vm_end=%lx, vm_flags=%llx\n", ul_mpu_addr,
 			ul_num_bytes, vma->vm_start, vma->vm_end,
-			vma->vm_flags);
+			(__force u64)vma->vm_flags);
 	}
 	if (!vma) {
 		pr_err("%s: Failed to get VMA region for 0x%x (%d)\n",
@@ -1302,11 +1302,12 @@ static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
 			} else {
 				pr_err("DSPBRIDGE: get_user_pages FAILED,"
 				       "MPU addr = 0x%x,"
-				       "vma->vm_flags = 0x%lx,"
+				       "vma->vm_flags = 0x%llx,"
 				       "get_user_pages Err"
 				       "Value = %d, Buffer"
 				       "size=0x%x\n", ul_mpu_addr,
-				       vma->vm_flags, pg_num, ul_num_bytes);
+				       (__force u64)vma->vm_flags,
+				       pg_num, ul_num_bytes);
 				status = -EPERM;
 				break;
 			}
diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c
index 3cac014..f7ea4af 100644
--- a/drivers/staging/tidspbridge/rmgr/drv_interface.c
+++ b/drivers/staging/tidspbridge/rmgr/drv_interface.c
@@ -265,9 +265,9 @@ static int bridge_mmap(struct file *filp, struct vm_area_struct *vma)
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
 	dev_dbg(bridge, "%s: vm filp %p start %lx end %lx page_prot %ulx "
-		"flags %lx\n", __func__, filp,
+		"flags %llx\n", __func__, filp,
 		vma->vm_start, vma->vm_end, vma->vm_page_prot,
-		vma->vm_flags);
+		(__force u64)vma->vm_flags);
 
 	status = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
 				 vma->vm_end - vma->vm_start,
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index c64bf5e..49a85b7 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -1215,7 +1215,8 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
 
 	/* Do not dump I/O mapped devices or special mappings */
 	if (vma->vm_flags & (VM_IO | VM_RESERVED)) {
-		kdcore("%08lx: %08lx: no (IO)", vma->vm_start, vma->vm_flags);
+		kdcore("%08lx: %08llx: no (IO)", vma->vm_start,
+		       (__force u64)vma->vm_flags);
 		return 0;
 	}
 
@@ -1223,7 +1224,8 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
 	 * them either. "dump_write()" can't handle it anyway.
 	 */
 	if (!(vma->vm_flags & VM_READ)) {
-		kdcore("%08lx: %08lx: no (!read)", vma->vm_start, vma->vm_flags);
+		kdcore("%08lx: %08llx: no (!read)", vma->vm_start,
+		       (__force u64)vma->vm_flags);
 		return 0;
 	}
 
@@ -1231,14 +1233,16 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
 	if (vma->vm_flags & VM_SHARED) {
 		if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0) {
 			dump_ok = test_bit(MMF_DUMP_ANON_SHARED, &mm_flags);
-			kdcore("%08lx: %08lx: %s (share)", vma->vm_start,
-			       vma->vm_flags, dump_ok ? "yes" : "no");
+			kdcore("%08lx: %08llx: %s (share)", vma->vm_start,
+			       (__force u64)vma->vm_flags,
+			       dump_ok ? "yes" : "no");
 			return dump_ok;
 		}
 
 		dump_ok = test_bit(MMF_DUMP_MAPPED_SHARED, &mm_flags);
-		kdcore("%08lx: %08lx: %s (share)", vma->vm_start,
-		       vma->vm_flags, dump_ok ? "yes" : "no");
+		kdcore("%08lx: %08llx: %s (share)", vma->vm_start,
+		       (__force u64)vma->vm_flags,
+		       dump_ok ? "yes" : "no");
 		return dump_ok;
 	}
 
@@ -1246,14 +1250,16 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
 	/* By default, if it hasn't been written to, don't write it out */
 	if (!vma->anon_vma) {
 		dump_ok = test_bit(MMF_DUMP_MAPPED_PRIVATE, &mm_flags);
-		kdcore("%08lx: %08lx: %s (!anon)", vma->vm_start,
-		       vma->vm_flags, dump_ok ? "yes" : "no");
+		kdcore("%08lx: %08llx: %s (!anon)", vma->vm_start,
+		       (__force u64)vma->vm_flags,
+		       dump_ok ? "yes" : "no");
 		return dump_ok;
 	}
 #endif
 
 	dump_ok = test_bit(MMF_DUMP_ANON_PRIVATE, &mm_flags);
-	kdcore("%08lx: %08lx: %s", vma->vm_start, vma->vm_flags,
+	kdcore("%08lx: %08llx: %s", vma->vm_start,
+	       (__force u64)vma->vm_flags,
 	       dump_ok ? "yes" : "no");
 	return dump_ok;
 }
diff --git a/mm/memory.c b/mm/memory.c
index b1c7c98..ee85fc4 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -705,8 +705,9 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
 	if (page)
 		dump_page(page);
 	printk(KERN_ALERT
-		"addr:%p vm_flags:%08lx anon_vma:%p mapping:%p index:%lx\n",
-		(void *)addr, vma->vm_flags, vma->anon_vma, mapping, index);
+		"addr:%p vm_flags:%08llx anon_vma:%p mapping:%p index:%lx\n",
+		(void *)addr, (__force u64)vma->vm_flags,
+		vma->anon_vma, mapping, index);
 	/*
 	 * Choose text because data symbols depend on CONFIG_KALLSYMS_ALL=y
 	 */


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 15/16] mm: cast vm_flags_t to u64 before printing
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel

Let's always print vm_flags_t as u64, thus now we can freely change
vm_flags_t's size depending on target achitecture or config options.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
 arch/sh/mm/tlbflush_64.c                         |    2 +-
 drivers/infiniband/hw/ipath/ipath_file_ops.c     |    6 ++++--
 drivers/infiniband/hw/qib/qib_file_ops.c         |    6 ++++--
 drivers/staging/android/binder.c                 |   15 ++++++++------
 drivers/staging/tidspbridge/core/tiomap3430.c    |   13 ++++++------
 drivers/staging/tidspbridge/rmgr/drv_interface.c |    4 ++--
 fs/binfmt_elf_fdpic.c                            |   24 ++++++++++++++--------
 mm/memory.c                                      |    5 +++--
 8 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/arch/sh/mm/tlbflush_64.c b/arch/sh/mm/tlbflush_64.c
index e3430e0..b798e7f 100644
--- a/arch/sh/mm/tlbflush_64.c
+++ b/arch/sh/mm/tlbflush_64.c
@@ -48,7 +48,7 @@ static inline void print_vma(struct vm_area_struct *vma)
 	printk("vma end   0x%08lx\n", vma->vm_end);
 
 	print_prots(vma->vm_page_prot);
-	printk("vm_flags 0x%08lx\n", vma->vm_flags);
+	printk("vm_flags 0x%08llx\n", (__force u64)vma->vm_flags);
 }
 
 static inline void print_task(struct task_struct *tsk)
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 736d9ed..b3dfa21 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -1115,7 +1115,8 @@ static int mmap_rcvegrbufs(struct vm_area_struct *vma,
 
 	if (vma->vm_flags & VM_WRITE) {
 		dev_info(&dd->pcidev->dev, "Can't map eager buffers as "
-			 "writable (flags=%lx)\n", vma->vm_flags);
+			 "writable (flags=%llx)\n",
+			 (__force u64)vma->vm_flags);
 		ret = -EPERM;
 		goto bail;
 	}
@@ -1204,7 +1205,8 @@ static int mmap_kvaddr(struct vm_area_struct *vma, u64 pgaddr,
                 if (vma->vm_flags & VM_WRITE) {
                         dev_info(&dd->pcidev->dev,
                                  "Can't map eager buffers as "
-                                 "writable (flags=%lx)\n", vma->vm_flags);
+				 "writable (flags=%llx)\n",
+				 (__force u64)vma->vm_flags);
                         ret = -EPERM;
                         goto bail;
                 }
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c
index a740324..0fe928d 100644
--- a/drivers/infiniband/hw/qib/qib_file_ops.c
+++ b/drivers/infiniband/hw/qib/qib_file_ops.c
@@ -857,7 +857,8 @@ static int mmap_rcvegrbufs(struct vm_area_struct *vma,
 
 	if (vma->vm_flags & VM_WRITE) {
 		qib_devinfo(dd->pcidev, "Can't map eager buffers as "
-			 "writable (flags=%lx)\n", vma->vm_flags);
+			 "writable (flags=%llx)\n",
+			 (__force u64)vma->vm_flags);
 		ret = -EPERM;
 		goto bail;
 	}
@@ -946,7 +947,8 @@ static int mmap_kvaddr(struct vm_area_struct *vma, u64 pgaddr,
 		if (vma->vm_flags & VM_WRITE) {
 			qib_devinfo(dd->pcidev,
 				 "Can't map eager buffers as "
-				 "writable (flags=%lx)\n", vma->vm_flags);
+				 "writable (flags=%llx)\n",
+				 (__force u64)vma->vm_flags);
 			ret = -EPERM;
 			goto bail;
 		}
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index c283212..b0d03e0 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -2761,9 +2761,10 @@ static void binder_vma_open(struct vm_area_struct *vma)
 {
 	struct binder_proc *proc = vma->vm_private_data;
 	binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-		     "binder: %d open vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
+		     "binder: %d open vm area %lx-%lx (%ld K) vma %llx pagep %lx\n",
 		     proc->pid, vma->vm_start, vma->vm_end,
-		     (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+		     (vma->vm_end - vma->vm_start) / SZ_1K,
+		     (__force u64)vma->vm_flags,
 		     (unsigned long)pgprot_val(vma->vm_page_prot));
 }
 
@@ -2771,9 +2772,10 @@ static void binder_vma_close(struct vm_area_struct *vma)
 {
 	struct binder_proc *proc = vma->vm_private_data;
 	binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-		     "binder: %d close vm area %lx-%lx (%ld K) vma %lx pagep %lx\n",
+		     "binder: %d close vm area %lx-%lx (%ld K) vma %llx pagep %lx\n",
 		     proc->pid, vma->vm_start, vma->vm_end,
-		     (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+		     (vma->vm_end - vma->vm_start) / SZ_1K,
+		     (__force u64)vma->vm_flags,
 		     (unsigned long)pgprot_val(vma->vm_page_prot));
 	proc->vma = NULL;
 	proc->vma_vm_mm = NULL;
@@ -2797,9 +2799,10 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
 		vma->vm_end = vma->vm_start + SZ_4M;
 
 	binder_debug(BINDER_DEBUG_OPEN_CLOSE,
-		     "binder_mmap: %d %lx-%lx (%ld K) vma %lx pagep %lx\n",
+		     "binder_mmap: %d %lx-%lx (%ld K) vma %llx pagep %lx\n",
 		     proc->pid, vma->vm_start, vma->vm_end,
-		     (vma->vm_end - vma->vm_start) / SZ_1K, vma->vm_flags,
+		     (vma->vm_end - vma->vm_start) / SZ_1K,
+		     (__force u64)vma->vm_flags,
 		     (unsigned long)pgprot_val(vma->vm_page_prot));
 
 	if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
index 7862513..328a9ab 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430.c
@@ -1216,9 +1216,9 @@ static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
 	if (vma)
 		dev_dbg(bridge,
 			"VMAfor UserBuf: ul_mpu_addr=%x, ul_num_bytes=%x, "
-			"vm_start=%lx, vm_end=%lx, vm_flags=%lx\n", ul_mpu_addr,
+			"vm_start=%lx, vm_end=%lx, vm_flags=%llx\n", ul_mpu_addr,
 			ul_num_bytes, vma->vm_start, vma->vm_end,
-			vma->vm_flags);
+			(__force u64)vma->vm_flags);
 
 	/*
 	 * It is observed that under some circumstances, the user buffer is
@@ -1230,9 +1230,9 @@ static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
 		vma = find_vma(mm, vma->vm_end + 1);
 		dev_dbg(bridge,
 			"VMA for UserBuf ul_mpu_addr=%x ul_num_bytes=%x, "
-			"vm_start=%lx, vm_end=%lx, vm_flags=%lx\n", ul_mpu_addr,
+			"vm_start=%lx, vm_end=%lx, vm_flags=%llx\n", ul_mpu_addr,
 			ul_num_bytes, vma->vm_start, vma->vm_end,
-			vma->vm_flags);
+			(__force u64)vma->vm_flags);
 	}
 	if (!vma) {
 		pr_err("%s: Failed to get VMA region for 0x%x (%d)\n",
@@ -1302,11 +1302,12 @@ static int bridge_brd_mem_map(struct bridge_dev_context *dev_ctxt,
 			} else {
 				pr_err("DSPBRIDGE: get_user_pages FAILED,"
 				       "MPU addr = 0x%x,"
-				       "vma->vm_flags = 0x%lx,"
+				       "vma->vm_flags = 0x%llx,"
 				       "get_user_pages Err"
 				       "Value = %d, Buffer"
 				       "size=0x%x\n", ul_mpu_addr,
-				       vma->vm_flags, pg_num, ul_num_bytes);
+				       (__force u64)vma->vm_flags,
+				       pg_num, ul_num_bytes);
 				status = -EPERM;
 				break;
 			}
diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c
index 3cac014..f7ea4af 100644
--- a/drivers/staging/tidspbridge/rmgr/drv_interface.c
+++ b/drivers/staging/tidspbridge/rmgr/drv_interface.c
@@ -265,9 +265,9 @@ static int bridge_mmap(struct file *filp, struct vm_area_struct *vma)
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
 
 	dev_dbg(bridge, "%s: vm filp %p start %lx end %lx page_prot %ulx "
-		"flags %lx\n", __func__, filp,
+		"flags %llx\n", __func__, filp,
 		vma->vm_start, vma->vm_end, vma->vm_page_prot,
-		vma->vm_flags);
+		(__force u64)vma->vm_flags);
 
 	status = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
 				 vma->vm_end - vma->vm_start,
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index c64bf5e..49a85b7 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -1215,7 +1215,8 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
 
 	/* Do not dump I/O mapped devices or special mappings */
 	if (vma->vm_flags & (VM_IO | VM_RESERVED)) {
-		kdcore("%08lx: %08lx: no (IO)", vma->vm_start, vma->vm_flags);
+		kdcore("%08lx: %08llx: no (IO)", vma->vm_start,
+		       (__force u64)vma->vm_flags);
 		return 0;
 	}
 
@@ -1223,7 +1224,8 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
 	 * them either. "dump_write()" can't handle it anyway.
 	 */
 	if (!(vma->vm_flags & VM_READ)) {
-		kdcore("%08lx: %08lx: no (!read)", vma->vm_start, vma->vm_flags);
+		kdcore("%08lx: %08llx: no (!read)", vma->vm_start,
+		       (__force u64)vma->vm_flags);
 		return 0;
 	}
 
@@ -1231,14 +1233,16 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
 	if (vma->vm_flags & VM_SHARED) {
 		if (vma->vm_file->f_path.dentry->d_inode->i_nlink == 0) {
 			dump_ok = test_bit(MMF_DUMP_ANON_SHARED, &mm_flags);
-			kdcore("%08lx: %08lx: %s (share)", vma->vm_start,
-			       vma->vm_flags, dump_ok ? "yes" : "no");
+			kdcore("%08lx: %08llx: %s (share)", vma->vm_start,
+			       (__force u64)vma->vm_flags,
+			       dump_ok ? "yes" : "no");
 			return dump_ok;
 		}
 
 		dump_ok = test_bit(MMF_DUMP_MAPPED_SHARED, &mm_flags);
-		kdcore("%08lx: %08lx: %s (share)", vma->vm_start,
-		       vma->vm_flags, dump_ok ? "yes" : "no");
+		kdcore("%08lx: %08llx: %s (share)", vma->vm_start,
+		       (__force u64)vma->vm_flags,
+		       dump_ok ? "yes" : "no");
 		return dump_ok;
 	}
 
@@ -1246,14 +1250,16 @@ static int maydump(struct vm_area_struct *vma, unsigned long mm_flags)
 	/* By default, if it hasn't been written to, don't write it out */
 	if (!vma->anon_vma) {
 		dump_ok = test_bit(MMF_DUMP_MAPPED_PRIVATE, &mm_flags);
-		kdcore("%08lx: %08lx: %s (!anon)", vma->vm_start,
-		       vma->vm_flags, dump_ok ? "yes" : "no");
+		kdcore("%08lx: %08llx: %s (!anon)", vma->vm_start,
+		       (__force u64)vma->vm_flags,
+		       dump_ok ? "yes" : "no");
 		return dump_ok;
 	}
 #endif
 
 	dump_ok = test_bit(MMF_DUMP_ANON_PRIVATE, &mm_flags);
-	kdcore("%08lx: %08lx: %s", vma->vm_start, vma->vm_flags,
+	kdcore("%08lx: %08llx: %s", vma->vm_start,
+	       (__force u64)vma->vm_flags,
 	       dump_ok ? "yes" : "no");
 	return dump_ok;
 }
diff --git a/mm/memory.c b/mm/memory.c
index b1c7c98..ee85fc4 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -705,8 +705,9 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
 	if (page)
 		dump_page(page);
 	printk(KERN_ALERT
-		"addr:%p vm_flags:%08lx anon_vma:%p mapping:%p index:%lx\n",
-		(void *)addr, vma->vm_flags, vma->anon_vma, mapping, index);
+		"addr:%p vm_flags:%08llx anon_vma:%p mapping:%p index:%lx\n",
+		(void *)addr, (__force u64)vma->vm_flags,
+		vma->anon_vma, mapping, index);
 	/*
 	 * Choose text because data symbols depend on CONFIG_KALLSYMS_ALL=y
 	 */

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 16/16] mm: vm_flags_t strict type checking
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Hugh Dickins, linux-kernel, KOSAKI Motohiro,
	Benjamin Herrenschmidt

Now nobody uses VM_* constants in macro-expressions, so we can add type to them.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h       |  138 ++++++++++++++++++++++++++++++++--------------
 include/linux/mm_types.h |    4 +
 2 files changed, 97 insertions(+), 45 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index be35c2f..b432c28 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -74,59 +74,111 @@ extern unsigned int kobjsize(const void *objp);
  * vm_flags in vm_area_struct, see mm_types.h.
  */
 
-#define VM_NONE		0x00000000
+enum {
+	__VM_READ,
+	__VM_WRITE,
+	__VM_EXEC,
+	__VM_SHARED,
+
+	__VM_MAYREAD,
+	__VM_MAYWRITE,
+	__VM_MAYEXEC,
+	__VM_MAYSHARE,
+
+	__VM_GROWSDOWN,
+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
+	__VM_GROWSUP,
+#else
+	__VM_NOHUGEPAGE,
+#endif
+	__VM_PFNMAP,
+	__VM_DENYWRITE,
+
+	__VM_EXECUTABLE,
+	__VM_LOCKED,
+	__VM_IO,
+	__VM_SEQ_READ,
+
+	__VM_RAND_READ,
+	__VM_DONTCOPY,
+	__VM_DONTEXPAND,
+	__VM_RESERVED,
 
-#define VM_READ		0x00000001	/* currently active flags */
-#define VM_WRITE	0x00000002
-#define VM_EXEC		0x00000004
-#define VM_SHARED	0x00000008
+	__VM_ACCOUNT,
+	__VM_NORESERVE,
+	__VM_HUGETLB,
+	__VM_NONLINEAR,
+
+#ifndef CONFIG_TRANSPARENT_HUGEPAGE
+	__VM_MAPPED_COPY,
+#else
+	__VM_HUGEPAGE,
+#endif
+	__VM_INSERTPAGE,
+	__VM_ALWAYSDUMP,
+	__VM_CAN_NONLINEAR,
+
+	__VM_MIXEDMAP,
+	__VM_SAO,
+	__VM_PFN_AT_MMAP,
+	__VM_MERGEABLE,
+
+	__NR_VMA_FLAGS
+};
+
+#define VM_NONE		((__force vm_flags_t)0)
+
+#define	__VMF(name)	((__force vm_flags_t)(1ull << (__VM_##name)))
+
+#define VM_READ		__VMF(READ) /* currently active flags */
+#define VM_WRITE	__VMF(WRITE)
+#define VM_EXEC		__VMF(EXEC)
+#define VM_SHARED	__VMF(SHARED)
 
 /* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
-#define VM_MAYREAD	0x00000010	/* limits for mprotect() etc */
-#define VM_MAYWRITE	0x00000020
-#define VM_MAYEXEC	0x00000040
-#define VM_MAYSHARE	0x00000080
+#define VM_MAYREAD	__VMF(MAYREAD) /* limits for mprotect() etc */
+#define VM_MAYWRITE	__VMF(MAYWRITE)
+#define VM_MAYEXEC	__VMF(MAYEXEC)
+#define VM_MAYSHARE	__VMF(MAYSHARE)
 
-#define VM_GROWSDOWN	0x00000100	/* general info on the segment */
+#define VM_GROWSDOWN	__VMF(GROWSDOWN) /* general info on the segment */
 #if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
-#define VM_GROWSUP	0x00000200
+#define VM_GROWSUP	__VMF(GROWSUP)
 #else
-#define VM_GROWSUP	0x00000000
-#define VM_NOHUGEPAGE	0x00000200	/* MADV_NOHUGEPAGE marked this vma */
+#define VM_GROWSUP	VM_NONE
+#define VM_NOHUGEPAGE	__VMF(NOHUGEPAGE) /* MADV_NOHUGEPAGE marked this vma */
 #endif
-#define VM_PFNMAP	0x00000400	/* Page-ranges managed without "struct page", just pure PFN */
-#define VM_DENYWRITE	0x00000800	/* ETXTBSY on write attempts.. */
-
-#define VM_EXECUTABLE	0x00001000
-#define VM_LOCKED	0x00002000
-#define VM_IO           0x00004000	/* Memory mapped I/O or similar */
-
-					/* Used by sys_madvise() */
-#define VM_SEQ_READ	0x00008000	/* App will access data sequentially */
-#define VM_RAND_READ	0x00010000	/* App will not benefit from clustered reads */
-
-#define VM_DONTCOPY	0x00020000      /* Do not copy this vma on fork */
-#define VM_DONTEXPAND	0x00040000	/* Cannot expand with mremap() */
-#define VM_RESERVED	0x00080000	/* Count as reserved_vm like IO */
-#define VM_ACCOUNT	0x00100000	/* Is a VM accounted object */
-#define VM_NORESERVE	0x00200000	/* should the VM suppress accounting */
-#define VM_HUGETLB	0x00400000	/* Huge TLB Page VM */
-#define VM_NONLINEAR	0x00800000	/* Is non-linear (remap_file_pages) */
+#define VM_PFNMAP	__VMF(PFNMAP) /* Page-ranges managed without "struct page", just pure PFN */
+#define VM_DENYWRITE	__VMF(DENYWRITE) /* ETXTBSY on write attempts.. */
+
+#define VM_EXECUTABLE	__VMF(EXECUTABLE)
+#define VM_LOCKED	__VMF(LOCKED)
+#define VM_IO		__VMF(IO) /* Memory mapped I/O or similar */
+
+					  /* Used by sys_madvise() */
+#define VM_SEQ_READ	__VMF(SEQ_READ) /* App will access data sequentially */
+#define VM_RAND_READ	__VMF(RAND_READ) /* App will not benefit from clustered reads */
+
+#define VM_DONTCOPY	__VMF(DONTCOPY) /* Do not copy this vma on fork */
+#define VM_DONTEXPAND	__VMF(DONTEXPAND) /* Cannot expand with mremap() */
+#define VM_RESERVED	__VMF(RESERVED) /* Count as reserved_vm like IO */
+#define VM_ACCOUNT	__VMF(ACCOUNT) /* Is a VM accounted object */
+#define VM_NORESERVE	__VMF(NORESERVE) /* should the VM suppress accounting */
+#define VM_HUGETLB	__VMF(HUGETLB) /* Huge TLB Page VM */
+#define VM_NONLINEAR	__VMF(NONLINEAR) /* Is non-linear (remap_file_pages) */
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
-#define VM_MAPPED_COPY	0x01000000	/* T if mapped copy of data (nommu mmap) */
+#define VM_MAPPED_COPY	__VMF(MAPPED_COPY) /* T if mapped copy of data (nommu mmap) */
 #else
-#define VM_HUGEPAGE	0x01000000	/* MADV_HUGEPAGE marked this vma */
+#define VM_HUGEPAGE	__VMF(HUGEPAGE) /* MADV_HUGEPAGE marked this vma */
 #endif
-#define VM_INSERTPAGE	0x02000000	/* The vma has had "vm_insert_page()" done on it */
-#define VM_ALWAYSDUMP	0x04000000	/* Always include in core dumps */
-
-#define VM_CAN_NONLINEAR 0x08000000	/* Has ->fault & does nonlinear pages */
-#define VM_MIXEDMAP	0x10000000	/* Can contain "struct page" and pure PFN pages */
-#define VM_SAO		0x20000000	/* Strong Access Ordering (powerpc) */
-#define VM_PFN_AT_MMAP	0x40000000	/* PFNMAP vma that is fully mapped at mmap time */
-#define VM_MERGEABLE	0x80000000	/* KSM may merge identical pages */
-
-#define __NR_VMA_FLAGS	32
+#define VM_INSERTPAGE	__VMF(INSERTPAGE) /* The vma has had "vm_insert_page()" done on it */
+#define VM_ALWAYSDUMP	__VMF(ALWAYSDUMP) /* Always include in core dumps */
+
+#define VM_CAN_NONLINEAR __VMF(CAN_NONLINEAR) /* Has ->fault & does nonlinear pages */
+#define VM_MIXEDMAP	__VMF(MIXEDMAP) /* Can contain "struct page" and pure PFN pages */
+#define VM_SAO		__VMF(SAO) /* Strong Access Ordering (powerpc) */
+#define VM_PFN_AT_MMAP	__VMF(PFN_AT_MMAP) /* PFNMAP vma that is fully mapped at mmap time */
+#define VM_MERGEABLE	__VMF(MERGEABLE) /* KSM may merge identical pages */
 
 #ifndef __GENERATING_BOUNDS_H
 
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index d57e764..f14cc5e 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -172,9 +172,9 @@ struct page_frag {
 };
 
 #if (NR_VMA_FLAGS > 32)
-typedef unsigned long long __nocast vm_flags_t;
+typedef unsigned long long __bitwise__ vm_flags_t;
 #else
-typedef unsigned long __nocast vm_flags_t;
+typedef unsigned long __bitwise__ vm_flags_t;
 #endif
 
 /*


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH 16/16] mm: vm_flags_t strict type checking
@ 2012-03-21  6:57   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Hugh Dickins, linux-kernel, KOSAKI Motohiro,
	Benjamin Herrenschmidt

Now nobody uses VM_* constants in macro-expressions, so we can add type to them.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h       |  138 ++++++++++++++++++++++++++++++++--------------
 include/linux/mm_types.h |    4 +
 2 files changed, 97 insertions(+), 45 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index be35c2f..b432c28 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -74,59 +74,111 @@ extern unsigned int kobjsize(const void *objp);
  * vm_flags in vm_area_struct, see mm_types.h.
  */
 
-#define VM_NONE		0x00000000
+enum {
+	__VM_READ,
+	__VM_WRITE,
+	__VM_EXEC,
+	__VM_SHARED,
+
+	__VM_MAYREAD,
+	__VM_MAYWRITE,
+	__VM_MAYEXEC,
+	__VM_MAYSHARE,
+
+	__VM_GROWSDOWN,
+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
+	__VM_GROWSUP,
+#else
+	__VM_NOHUGEPAGE,
+#endif
+	__VM_PFNMAP,
+	__VM_DENYWRITE,
+
+	__VM_EXECUTABLE,
+	__VM_LOCKED,
+	__VM_IO,
+	__VM_SEQ_READ,
+
+	__VM_RAND_READ,
+	__VM_DONTCOPY,
+	__VM_DONTEXPAND,
+	__VM_RESERVED,
 
-#define VM_READ		0x00000001	/* currently active flags */
-#define VM_WRITE	0x00000002
-#define VM_EXEC		0x00000004
-#define VM_SHARED	0x00000008
+	__VM_ACCOUNT,
+	__VM_NORESERVE,
+	__VM_HUGETLB,
+	__VM_NONLINEAR,
+
+#ifndef CONFIG_TRANSPARENT_HUGEPAGE
+	__VM_MAPPED_COPY,
+#else
+	__VM_HUGEPAGE,
+#endif
+	__VM_INSERTPAGE,
+	__VM_ALWAYSDUMP,
+	__VM_CAN_NONLINEAR,
+
+	__VM_MIXEDMAP,
+	__VM_SAO,
+	__VM_PFN_AT_MMAP,
+	__VM_MERGEABLE,
+
+	__NR_VMA_FLAGS
+};
+
+#define VM_NONE		((__force vm_flags_t)0)
+
+#define	__VMF(name)	((__force vm_flags_t)(1ull << (__VM_##name)))
+
+#define VM_READ		__VMF(READ) /* currently active flags */
+#define VM_WRITE	__VMF(WRITE)
+#define VM_EXEC		__VMF(EXEC)
+#define VM_SHARED	__VMF(SHARED)
 
 /* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
-#define VM_MAYREAD	0x00000010	/* limits for mprotect() etc */
-#define VM_MAYWRITE	0x00000020
-#define VM_MAYEXEC	0x00000040
-#define VM_MAYSHARE	0x00000080
+#define VM_MAYREAD	__VMF(MAYREAD) /* limits for mprotect() etc */
+#define VM_MAYWRITE	__VMF(MAYWRITE)
+#define VM_MAYEXEC	__VMF(MAYEXEC)
+#define VM_MAYSHARE	__VMF(MAYSHARE)
 
-#define VM_GROWSDOWN	0x00000100	/* general info on the segment */
+#define VM_GROWSDOWN	__VMF(GROWSDOWN) /* general info on the segment */
 #if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
-#define VM_GROWSUP	0x00000200
+#define VM_GROWSUP	__VMF(GROWSUP)
 #else
-#define VM_GROWSUP	0x00000000
-#define VM_NOHUGEPAGE	0x00000200	/* MADV_NOHUGEPAGE marked this vma */
+#define VM_GROWSUP	VM_NONE
+#define VM_NOHUGEPAGE	__VMF(NOHUGEPAGE) /* MADV_NOHUGEPAGE marked this vma */
 #endif
-#define VM_PFNMAP	0x00000400	/* Page-ranges managed without "struct page", just pure PFN */
-#define VM_DENYWRITE	0x00000800	/* ETXTBSY on write attempts.. */
-
-#define VM_EXECUTABLE	0x00001000
-#define VM_LOCKED	0x00002000
-#define VM_IO           0x00004000	/* Memory mapped I/O or similar */
-
-					/* Used by sys_madvise() */
-#define VM_SEQ_READ	0x00008000	/* App will access data sequentially */
-#define VM_RAND_READ	0x00010000	/* App will not benefit from clustered reads */
-
-#define VM_DONTCOPY	0x00020000      /* Do not copy this vma on fork */
-#define VM_DONTEXPAND	0x00040000	/* Cannot expand with mremap() */
-#define VM_RESERVED	0x00080000	/* Count as reserved_vm like IO */
-#define VM_ACCOUNT	0x00100000	/* Is a VM accounted object */
-#define VM_NORESERVE	0x00200000	/* should the VM suppress accounting */
-#define VM_HUGETLB	0x00400000	/* Huge TLB Page VM */
-#define VM_NONLINEAR	0x00800000	/* Is non-linear (remap_file_pages) */
+#define VM_PFNMAP	__VMF(PFNMAP) /* Page-ranges managed without "struct page", just pure PFN */
+#define VM_DENYWRITE	__VMF(DENYWRITE) /* ETXTBSY on write attempts.. */
+
+#define VM_EXECUTABLE	__VMF(EXECUTABLE)
+#define VM_LOCKED	__VMF(LOCKED)
+#define VM_IO		__VMF(IO) /* Memory mapped I/O or similar */
+
+					  /* Used by sys_madvise() */
+#define VM_SEQ_READ	__VMF(SEQ_READ) /* App will access data sequentially */
+#define VM_RAND_READ	__VMF(RAND_READ) /* App will not benefit from clustered reads */
+
+#define VM_DONTCOPY	__VMF(DONTCOPY) /* Do not copy this vma on fork */
+#define VM_DONTEXPAND	__VMF(DONTEXPAND) /* Cannot expand with mremap() */
+#define VM_RESERVED	__VMF(RESERVED) /* Count as reserved_vm like IO */
+#define VM_ACCOUNT	__VMF(ACCOUNT) /* Is a VM accounted object */
+#define VM_NORESERVE	__VMF(NORESERVE) /* should the VM suppress accounting */
+#define VM_HUGETLB	__VMF(HUGETLB) /* Huge TLB Page VM */
+#define VM_NONLINEAR	__VMF(NONLINEAR) /* Is non-linear (remap_file_pages) */
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
-#define VM_MAPPED_COPY	0x01000000	/* T if mapped copy of data (nommu mmap) */
+#define VM_MAPPED_COPY	__VMF(MAPPED_COPY) /* T if mapped copy of data (nommu mmap) */
 #else
-#define VM_HUGEPAGE	0x01000000	/* MADV_HUGEPAGE marked this vma */
+#define VM_HUGEPAGE	__VMF(HUGEPAGE) /* MADV_HUGEPAGE marked this vma */
 #endif
-#define VM_INSERTPAGE	0x02000000	/* The vma has had "vm_insert_page()" done on it */
-#define VM_ALWAYSDUMP	0x04000000	/* Always include in core dumps */
-
-#define VM_CAN_NONLINEAR 0x08000000	/* Has ->fault & does nonlinear pages */
-#define VM_MIXEDMAP	0x10000000	/* Can contain "struct page" and pure PFN pages */
-#define VM_SAO		0x20000000	/* Strong Access Ordering (powerpc) */
-#define VM_PFN_AT_MMAP	0x40000000	/* PFNMAP vma that is fully mapped at mmap time */
-#define VM_MERGEABLE	0x80000000	/* KSM may merge identical pages */
-
-#define __NR_VMA_FLAGS	32
+#define VM_INSERTPAGE	__VMF(INSERTPAGE) /* The vma has had "vm_insert_page()" done on it */
+#define VM_ALWAYSDUMP	__VMF(ALWAYSDUMP) /* Always include in core dumps */
+
+#define VM_CAN_NONLINEAR __VMF(CAN_NONLINEAR) /* Has ->fault & does nonlinear pages */
+#define VM_MIXEDMAP	__VMF(MIXEDMAP) /* Can contain "struct page" and pure PFN pages */
+#define VM_SAO		__VMF(SAO) /* Strong Access Ordering (powerpc) */
+#define VM_PFN_AT_MMAP	__VMF(PFN_AT_MMAP) /* PFNMAP vma that is fully mapped at mmap time */
+#define VM_MERGEABLE	__VMF(MERGEABLE) /* KSM may merge identical pages */
 
 #ifndef __GENERATING_BOUNDS_H
 
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index d57e764..f14cc5e 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -172,9 +172,9 @@ struct page_frag {
 };
 
 #if (NR_VMA_FLAGS > 32)
-typedef unsigned long long __nocast vm_flags_t;
+typedef unsigned long long __bitwise__ vm_flags_t;
 #else
-typedef unsigned long __nocast vm_flags_t;
+typedef unsigned long __bitwise__ vm_flags_t;
 #endif
 
 /*

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* Re: [PATCH 06/16] mm/x86: use vm_flags_t for vma flags
  2012-03-21  6:56   ` Konstantin Khlebnikov
@ 2012-03-21  6:57     ` H. Peter Anvin
  -1 siblings, 0 replies; 104+ messages in thread
From: H. Peter Anvin @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, x86, linux-kernel, linux-mm, Ingo Molnar, Thomas Gleixner

On 03/20/2012 11:56 PM, Konstantin Khlebnikov wrote:
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org

Please put in a patch description.

	-hpa


-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 06/16] mm/x86: use vm_flags_t for vma flags
@ 2012-03-21  6:57     ` H. Peter Anvin
  0 siblings, 0 replies; 104+ messages in thread
From: H. Peter Anvin @ 2012-03-21  6:57 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, x86, linux-kernel, linux-mm, Ingo Molnar, Thomas Gleixner

On 03/20/2012 11:56 PM, Konstantin Khlebnikov wrote:
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org

Please put in a patch description.

	-hpa


-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 04/16] mm/nommu: use vm_flags_t for vma flags
  2012-03-21  6:56   ` Konstantin Khlebnikov
@ 2012-03-21  7:08     ` Greg Ungerer
  -1 siblings, 0 replies; 104+ messages in thread
From: Greg Ungerer @ 2012-03-21  7:08 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, David Howells, linux-mm, linux-kernel, Greg Ungerer


Hi Konstantin,

On 21/03/12 16:56, Konstantin Khlebnikov wrote:
> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
> Cc: David Howells<dhowells@redhat.com>
> Cc: Greg Ungerer<gerg@uclinux.org>
> ---
>   fs/proc/nommu.c      |    3 ++-
>   fs/proc/task_nommu.c |   14 ++++++++------
>   mm/nommu.c           |   19 ++++++++++---------
>   3 files changed, 20 insertions(+), 16 deletions(-)
>
> diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
> index b1822dd..cadc798 100644
> --- a/fs/proc/nommu.c
> +++ b/fs/proc/nommu.c
> @@ -39,7 +39,8 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
>   	unsigned long ino = 0;
>   	struct file *file;
>   	dev_t dev = 0;
> -	int flags, len;
> +	int len;
> +	vm_flags_t vm_flags;
>
>   	flags = region->vm_flags;
         ^^^^^
I think you want vm_flags here right?
There is other uses of "flags" in this function as well.

Regards
Greg


>   	file = region->vm_file;
> diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
> index 8aaba8c..9abbc66 100644
> --- a/fs/proc/task_nommu.c
> +++ b/fs/proc/task_nommu.c
> @@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>   	unsigned long ino = 0;
>   	struct file *file;
>   	dev_t dev = 0;
> -	int flags, len;
> +	int len;
> +	vm_flags_t vm_flags;
>   	unsigned long long pgoff = 0;
>
> -	flags = vma->vm_flags;
> +	vm_flags = vma->vm_flags;
>   	file = vma->vm_file;
>
>   	if (file) {
> @@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>   		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
>   		   vma->vm_start,
>   		   vma->vm_end,
> -		   flags&  VM_READ ? 'r' : '-',
> -		   flags&  VM_WRITE ? 'w' : '-',
> -		   flags&  VM_EXEC ? 'x' : '-',
> -		   flags&  VM_MAYSHARE ? flags&  VM_SHARED ? 'S' : 's' : 'p',
> +		   vm_flags&  VM_READ ? 'r' : '-',
> +		   vm_flags&  VM_WRITE ? 'w' : '-',
> +		   vm_flags&  VM_EXEC ? 'x' : '-',
> +		   vm_flags&  VM_MAYSHARE ?
> +			vm_flags&  VM_SHARED ? 'S' : 's' : 'p',
>   		   pgoff,
>   		   MAJOR(dev), MINOR(dev), ino,&len);
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index f59e170..33d0ab7 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
>   		     int *retry)
>   {
>   	struct vm_area_struct *vma;
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>   	int i;
>
>   	/* calculate required read or write permissions.
> @@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
>   /*
>    * update protection on a vma
>    */
> -static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
> +static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
>   {
>   #ifdef CONFIG_MPU
>   	struct mm_struct *mm = vma->vm_mm;
>   	long start = vma->vm_start&  PAGE_MASK;
>   	while (start<  vma->vm_end) {
> -		protect_page(mm, start, flags);
> +		protect_page(mm, start, vm_flags);
>   		start += PAGE_SIZE;
>   	}
>   	update_protections(mm);
> @@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
>    * we've determined that we can make the mapping, now translate what we
>    * now know into VMA flags
>    */
> -static unsigned long determine_vm_flags(struct file *file,
> -					unsigned long prot,
> -					unsigned long flags,
> -					unsigned long capabilities)
> +static vm_flags_t determine_vm_flags(struct file *file,
> +				     unsigned long prot,
> +				     unsigned long flags,
> +				     unsigned long capabilities)
>   {
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>
>   	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
>   	/* vm_flags |= mm->def_flags; */
> @@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
>   	struct vm_area_struct *vma;
>   	struct vm_region *region;
>   	struct rb_node *rb;
> -	unsigned long capabilities, vm_flags, result;
> +	unsigned long capabilities, result;
> +	vm_flags_t vm_flags;
>   	int ret;
>
>   	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);
>
>
>
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 04/16] mm/nommu: use vm_flags_t for vma flags
@ 2012-03-21  7:08     ` Greg Ungerer
  0 siblings, 0 replies; 104+ messages in thread
From: Greg Ungerer @ 2012-03-21  7:08 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, David Howells, linux-mm, linux-kernel, Greg Ungerer


Hi Konstantin,

On 21/03/12 16:56, Konstantin Khlebnikov wrote:
> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
> Cc: David Howells<dhowells@redhat.com>
> Cc: Greg Ungerer<gerg@uclinux.org>
> ---
>   fs/proc/nommu.c      |    3 ++-
>   fs/proc/task_nommu.c |   14 ++++++++------
>   mm/nommu.c           |   19 ++++++++++---------
>   3 files changed, 20 insertions(+), 16 deletions(-)
>
> diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
> index b1822dd..cadc798 100644
> --- a/fs/proc/nommu.c
> +++ b/fs/proc/nommu.c
> @@ -39,7 +39,8 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
>   	unsigned long ino = 0;
>   	struct file *file;
>   	dev_t dev = 0;
> -	int flags, len;
> +	int len;
> +	vm_flags_t vm_flags;
>
>   	flags = region->vm_flags;
         ^^^^^
I think you want vm_flags here right?
There is other uses of "flags" in this function as well.

Regards
Greg


>   	file = region->vm_file;
> diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
> index 8aaba8c..9abbc66 100644
> --- a/fs/proc/task_nommu.c
> +++ b/fs/proc/task_nommu.c
> @@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>   	unsigned long ino = 0;
>   	struct file *file;
>   	dev_t dev = 0;
> -	int flags, len;
> +	int len;
> +	vm_flags_t vm_flags;
>   	unsigned long long pgoff = 0;
>
> -	flags = vma->vm_flags;
> +	vm_flags = vma->vm_flags;
>   	file = vma->vm_file;
>
>   	if (file) {
> @@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>   		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
>   		   vma->vm_start,
>   		   vma->vm_end,
> -		   flags&  VM_READ ? 'r' : '-',
> -		   flags&  VM_WRITE ? 'w' : '-',
> -		   flags&  VM_EXEC ? 'x' : '-',
> -		   flags&  VM_MAYSHARE ? flags&  VM_SHARED ? 'S' : 's' : 'p',
> +		   vm_flags&  VM_READ ? 'r' : '-',
> +		   vm_flags&  VM_WRITE ? 'w' : '-',
> +		   vm_flags&  VM_EXEC ? 'x' : '-',
> +		   vm_flags&  VM_MAYSHARE ?
> +			vm_flags&  VM_SHARED ? 'S' : 's' : 'p',
>   		   pgoff,
>   		   MAJOR(dev), MINOR(dev), ino,&len);
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index f59e170..33d0ab7 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
>   		     int *retry)
>   {
>   	struct vm_area_struct *vma;
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>   	int i;
>
>   	/* calculate required read or write permissions.
> @@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
>   /*
>    * update protection on a vma
>    */
> -static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
> +static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
>   {
>   #ifdef CONFIG_MPU
>   	struct mm_struct *mm = vma->vm_mm;
>   	long start = vma->vm_start&  PAGE_MASK;
>   	while (start<  vma->vm_end) {
> -		protect_page(mm, start, flags);
> +		protect_page(mm, start, vm_flags);
>   		start += PAGE_SIZE;
>   	}
>   	update_protections(mm);
> @@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
>    * we've determined that we can make the mapping, now translate what we
>    * now know into VMA flags
>    */
> -static unsigned long determine_vm_flags(struct file *file,
> -					unsigned long prot,
> -					unsigned long flags,
> -					unsigned long capabilities)
> +static vm_flags_t determine_vm_flags(struct file *file,
> +				     unsigned long prot,
> +				     unsigned long flags,
> +				     unsigned long capabilities)
>   {
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>
>   	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
>   	/* vm_flags |= mm->def_flags; */
> @@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
>   	struct vm_area_struct *vma;
>   	struct vm_region *region;
>   	struct rb_node *rb;
> -	unsigned long capabilities, vm_flags, result;
> +	unsigned long capabilities, result;
> +	vm_flags_t vm_flags;
>   	int ret;
>
>   	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);
>
>
>
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 04/16] mm/nommu: use vm_flags_t for vma flags
  2012-03-21  7:08     ` Greg Ungerer
@ 2012-03-21  7:20       ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  7:20 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: Andrew Morton, David Howells, linux-mm, linux-kernel, Greg Ungerer

Greg Ungerer wrote:
>
> Hi Konstantin,
>
> On 21/03/12 16:56, Konstantin Khlebnikov wrote:
>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>> Cc: David Howells<dhowells@redhat.com>
>> Cc: Greg Ungerer<gerg@uclinux.org>
>> ---
>>    fs/proc/nommu.c      |    3 ++-
>>    fs/proc/task_nommu.c |   14 ++++++++------
>>    mm/nommu.c           |   19 ++++++++++---------
>>    3 files changed, 20 insertions(+), 16 deletions(-)
>>
>> diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
>> index b1822dd..cadc798 100644
>> --- a/fs/proc/nommu.c
>> +++ b/fs/proc/nommu.c
>> @@ -39,7 +39,8 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
>>    	unsigned long ino = 0;
>>    	struct file *file;
>>    	dev_t dev = 0;
>> -	int flags, len;
>> +	int len;
>> +	vm_flags_t vm_flags;
>>
>>    	flags = region->vm_flags;
>           ^^^^^
> I think you want vm_flags here right?
> There is other uses of "flags" in this function as well.

Right, I missed this.

Sorry for my cheating, I didn't check compiling for all possible targets =)

>
> Regards
> Greg
>
>
>>    	file = region->vm_file;
>> diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
>> index 8aaba8c..9abbc66 100644
>> --- a/fs/proc/task_nommu.c
>> +++ b/fs/proc/task_nommu.c
>> @@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>>    	unsigned long ino = 0;
>>    	struct file *file;
>>    	dev_t dev = 0;
>> -	int flags, len;
>> +	int len;
>> +	vm_flags_t vm_flags;
>>    	unsigned long long pgoff = 0;
>>
>> -	flags = vma->vm_flags;
>> +	vm_flags = vma->vm_flags;
>>    	file = vma->vm_file;
>>
>>    	if (file) {
>> @@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>>    		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
>>    		   vma->vm_start,
>>    		   vma->vm_end,
>> -		   flags&   VM_READ ? 'r' : '-',
>> -		   flags&   VM_WRITE ? 'w' : '-',
>> -		   flags&   VM_EXEC ? 'x' : '-',
>> -		   flags&   VM_MAYSHARE ? flags&   VM_SHARED ? 'S' : 's' : 'p',
>> +		   vm_flags&   VM_READ ? 'r' : '-',
>> +		   vm_flags&   VM_WRITE ? 'w' : '-',
>> +		   vm_flags&   VM_EXEC ? 'x' : '-',
>> +		   vm_flags&   VM_MAYSHARE ?
>> +			vm_flags&   VM_SHARED ? 'S' : 's' : 'p',
>>    		   pgoff,
>>    		   MAJOR(dev), MINOR(dev), ino,&len);
>>
>> diff --git a/mm/nommu.c b/mm/nommu.c
>> index f59e170..33d0ab7 100644
>> --- a/mm/nommu.c
>> +++ b/mm/nommu.c
>> @@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
>>    		     int *retry)
>>    {
>>    	struct vm_area_struct *vma;
>> -	unsigned long vm_flags;
>> +	vm_flags_t vm_flags;
>>    	int i;
>>
>>    	/* calculate required read or write permissions.
>> @@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
>>    /*
>>     * update protection on a vma
>>     */
>> -static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
>> +static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
>>    {
>>    #ifdef CONFIG_MPU
>>    	struct mm_struct *mm = vma->vm_mm;
>>    	long start = vma->vm_start&   PAGE_MASK;
>>    	while (start<   vma->vm_end) {
>> -		protect_page(mm, start, flags);
>> +		protect_page(mm, start, vm_flags);
>>    		start += PAGE_SIZE;
>>    	}
>>    	update_protections(mm);
>> @@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
>>     * we've determined that we can make the mapping, now translate what we
>>     * now know into VMA flags
>>     */
>> -static unsigned long determine_vm_flags(struct file *file,
>> -					unsigned long prot,
>> -					unsigned long flags,
>> -					unsigned long capabilities)
>> +static vm_flags_t determine_vm_flags(struct file *file,
>> +				     unsigned long prot,
>> +				     unsigned long flags,
>> +				     unsigned long capabilities)
>>    {
>> -	unsigned long vm_flags;
>> +	vm_flags_t vm_flags;
>>
>>    	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
>>    	/* vm_flags |= mm->def_flags; */
>> @@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
>>    	struct vm_area_struct *vma;
>>    	struct vm_region *region;
>>    	struct rb_node *rb;
>> -	unsigned long capabilities, vm_flags, result;
>> +	unsigned long capabilities, result;
>> +	vm_flags_t vm_flags;
>>    	int ret;
>>
>>    	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);
>>
>>
>>
>>
>
>


^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 04/16] mm/nommu: use vm_flags_t for vma flags
@ 2012-03-21  7:20       ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21  7:20 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: Andrew Morton, David Howells, linux-mm, linux-kernel, Greg Ungerer

Greg Ungerer wrote:
>
> Hi Konstantin,
>
> On 21/03/12 16:56, Konstantin Khlebnikov wrote:
>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>> Cc: David Howells<dhowells@redhat.com>
>> Cc: Greg Ungerer<gerg@uclinux.org>
>> ---
>>    fs/proc/nommu.c      |    3 ++-
>>    fs/proc/task_nommu.c |   14 ++++++++------
>>    mm/nommu.c           |   19 ++++++++++---------
>>    3 files changed, 20 insertions(+), 16 deletions(-)
>>
>> diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
>> index b1822dd..cadc798 100644
>> --- a/fs/proc/nommu.c
>> +++ b/fs/proc/nommu.c
>> @@ -39,7 +39,8 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
>>    	unsigned long ino = 0;
>>    	struct file *file;
>>    	dev_t dev = 0;
>> -	int flags, len;
>> +	int len;
>> +	vm_flags_t vm_flags;
>>
>>    	flags = region->vm_flags;
>           ^^^^^
> I think you want vm_flags here right?
> There is other uses of "flags" in this function as well.

Right, I missed this.

Sorry for my cheating, I didn't check compiling for all possible targets =)

>
> Regards
> Greg
>
>
>>    	file = region->vm_file;
>> diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
>> index 8aaba8c..9abbc66 100644
>> --- a/fs/proc/task_nommu.c
>> +++ b/fs/proc/task_nommu.c
>> @@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>>    	unsigned long ino = 0;
>>    	struct file *file;
>>    	dev_t dev = 0;
>> -	int flags, len;
>> +	int len;
>> +	vm_flags_t vm_flags;
>>    	unsigned long long pgoff = 0;
>>
>> -	flags = vma->vm_flags;
>> +	vm_flags = vma->vm_flags;
>>    	file = vma->vm_file;
>>
>>    	if (file) {
>> @@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>>    		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
>>    		   vma->vm_start,
>>    		   vma->vm_end,
>> -		   flags&   VM_READ ? 'r' : '-',
>> -		   flags&   VM_WRITE ? 'w' : '-',
>> -		   flags&   VM_EXEC ? 'x' : '-',
>> -		   flags&   VM_MAYSHARE ? flags&   VM_SHARED ? 'S' : 's' : 'p',
>> +		   vm_flags&   VM_READ ? 'r' : '-',
>> +		   vm_flags&   VM_WRITE ? 'w' : '-',
>> +		   vm_flags&   VM_EXEC ? 'x' : '-',
>> +		   vm_flags&   VM_MAYSHARE ?
>> +			vm_flags&   VM_SHARED ? 'S' : 's' : 'p',
>>    		   pgoff,
>>    		   MAJOR(dev), MINOR(dev), ino,&len);
>>
>> diff --git a/mm/nommu.c b/mm/nommu.c
>> index f59e170..33d0ab7 100644
>> --- a/mm/nommu.c
>> +++ b/mm/nommu.c
>> @@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
>>    		     int *retry)
>>    {
>>    	struct vm_area_struct *vma;
>> -	unsigned long vm_flags;
>> +	vm_flags_t vm_flags;
>>    	int i;
>>
>>    	/* calculate required read or write permissions.
>> @@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
>>    /*
>>     * update protection on a vma
>>     */
>> -static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
>> +static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
>>    {
>>    #ifdef CONFIG_MPU
>>    	struct mm_struct *mm = vma->vm_mm;
>>    	long start = vma->vm_start&   PAGE_MASK;
>>    	while (start<   vma->vm_end) {
>> -		protect_page(mm, start, flags);
>> +		protect_page(mm, start, vm_flags);
>>    		start += PAGE_SIZE;
>>    	}
>>    	update_protections(mm);
>> @@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
>>     * we've determined that we can make the mapping, now translate what we
>>     * now know into VMA flags
>>     */
>> -static unsigned long determine_vm_flags(struct file *file,
>> -					unsigned long prot,
>> -					unsigned long flags,
>> -					unsigned long capabilities)
>> +static vm_flags_t determine_vm_flags(struct file *file,
>> +				     unsigned long prot,
>> +				     unsigned long flags,
>> +				     unsigned long capabilities)
>>    {
>> -	unsigned long vm_flags;
>> +	vm_flags_t vm_flags;
>>
>>    	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
>>    	/* vm_flags |= mm->def_flags; */
>> @@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
>>    	struct vm_area_struct *vma;
>>    	struct vm_region *region;
>>    	struct rb_node *rb;
>> -	unsigned long capabilities, vm_flags, result;
>> +	unsigned long capabilities, result;
>> +	vm_flags_t vm_flags;
>>    	int ret;
>>
>>    	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);
>>
>>
>>
>>
>
>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-21  6:56 ` Konstantin Khlebnikov
@ 2012-03-21 10:06   ` Minchan Kim
  -1 siblings, 0 replies; 104+ messages in thread
From: Minchan Kim @ 2012-03-21 10:06 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Hi Konstantin,

It seems to be nice clean up to me and you are a volunteer we have been wanted
for a long time. Thanks!
I am one of people who really want to expand vm_flags to 64 bit but when KOSAKI
tried it, Linus said his concerning, I guess you already saw that.

He want to tidy vm_flags's usage up rather than expanding it.
Without the discussion about that, just expanding vm_flags would make us use 
it up easily so that we might need more space. 

Readahead flags are good candidate to move into another space and arch-specific flags, I guess.
Another candidate I think of is THP flag. It's just for only anonymous vma now
(But I am not sure we have a plan to support it for file-backed pages in future)
so we can move it to anon_vma or somewhere.
I think other guys might find more somethings

The point is that at least, we have to discuss about clean up current vm_flags's
use cases before expanding it unconditionally.

On Wed, Mar 21, 2012 at 10:56:07AM +0400, Konstantin Khlebnikov wrote:
> There is good old tradition: every year somebody submit patches for extending
> vma->vm_flags upto 64-bits, because there no free bits left on 32-bit systems.
> 
> previous attempts:
> https://lkml.org/lkml/2011/4/12/24	(KOSAKI Motohiro)
> https://lkml.org/lkml/2010/4/27/23	(Benjamin Herrenschmidt)
> https://lkml.org/lkml/2009/10/1/202	(Hugh Dickins)
> 
> Here already exist special type for this: vm_flags_t, but not all code uses it.
> So, before switching vm_flags_t from unsinged long to u64 we must spread
> vm_flags_t everywhere and fix all possible type-casting problems.
> 
> There is no functional changes in this patch set,
> it only prepares code for vma->vm_flags converting.
> 
> ---
> 
> Konstantin Khlebnikov (16):
>       mm: introduce NR_VMA_FLAGS
>       mm: use vm_flags_t for vma flags
>       mm/shmem: use vm_flags_t for vma flags
>       mm/nommu: use vm_flags_t for vma flags
>       mm/drivers: use vm_flags_t for vma flags
>       mm/x86: use vm_flags_t for vma flags
>       mm/arm: use vm_flags_t for vma flags
>       mm/unicore32: use vm_flags_t for vma flags
>       mm/ia64: use vm_flags_t for vma flags
>       mm/powerpc: use vm_flags_t for vma flags
>       mm/s390: use vm_flags_t for vma flags
>       mm/mips: use vm_flags_t for vma flags
>       mm/parisc: use vm_flags_t for vma flags
>       mm/score: use vm_flags_t for vma flags
>       mm: cast vm_flags_t to u64 before printing
>       mm: vm_flags_t strict type checking
> 
> 
>  arch/arm/include/asm/cacheflush.h                |    5 -
>  arch/arm/kernel/asm-offsets.c                    |    6 +
>  arch/arm/mm/fault.c                              |    2 
>  arch/ia64/mm/fault.c                             |    9 +
>  arch/mips/mm/c-r3k.c                             |    2 
>  arch/mips/mm/c-r4k.c                             |    6 -
>  arch/mips/mm/c-tx39.c                            |    2 
>  arch/parisc/mm/fault.c                           |    4 -
>  arch/powerpc/include/asm/mman.h                  |    2 
>  arch/s390/mm/fault.c                             |    8 +
>  arch/score/mm/cache.c                            |    6 -
>  arch/sh/mm/tlbflush_64.c                         |    2 
>  arch/unicore32/kernel/asm-offsets.c              |    6 +
>  arch/unicore32/mm/fault.c                        |    2 
>  arch/x86/mm/hugetlbpage.c                        |    4 -
>  drivers/char/mem.c                               |    2 
>  drivers/infiniband/hw/ipath/ipath_file_ops.c     |    6 +
>  drivers/infiniband/hw/qib/qib_file_ops.c         |    6 +
>  drivers/media/video/omap3isp/ispqueue.h          |    2 
>  drivers/staging/android/ashmem.c                 |    2 
>  drivers/staging/android/binder.c                 |   15 +-
>  drivers/staging/tidspbridge/core/tiomap3430.c    |   13 +-
>  drivers/staging/tidspbridge/rmgr/drv_interface.c |    4 -
>  fs/binfmt_elf.c                                  |    2 
>  fs/binfmt_elf_fdpic.c                            |   24 ++-
>  fs/exec.c                                        |    2 
>  fs/proc/nommu.c                                  |    3 
>  fs/proc/task_nommu.c                             |   14 +-
>  include/linux/backing-dev.h                      |    7 -
>  include/linux/huge_mm.h                          |    4 -
>  include/linux/ksm.h                              |    8 +
>  include/linux/mm.h                               |  163 +++++++++++++++-------
>  include/linux/mm_types.h                         |   11 +
>  include/linux/mman.h                             |    4 -
>  include/linux/rmap.h                             |    8 +
>  include/linux/shmem_fs.h                         |    5 -
>  kernel/bounds.c                                  |    2 
>  kernel/events/core.c                             |    4 -
>  kernel/fork.c                                    |    2 
>  kernel/sys.c                                     |    4 -
>  mm/backing-dev.c                                 |    4 +
>  mm/huge_memory.c                                 |    2 
>  mm/ksm.c                                         |    4 -
>  mm/madvise.c                                     |    2 
>  mm/memory.c                                      |    9 +
>  mm/mlock.c                                       |    2 
>  mm/mmap.c                                        |   36 ++---
>  mm/mprotect.c                                    |    9 +
>  mm/mremap.c                                      |    2 
>  mm/nommu.c                                       |   19 +--
>  mm/rmap.c                                        |   16 +-
>  mm/shmem.c                                       |   54 ++++---
>  mm/vmscan.c                                      |    4 -
>  53 files changed, 322 insertions(+), 224 deletions(-)
> 
> -- 
> Signature
> 
> --
> 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/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-21 10:06   ` Minchan Kim
  0 siblings, 0 replies; 104+ messages in thread
From: Minchan Kim @ 2012-03-21 10:06 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Hi Konstantin,

It seems to be nice clean up to me and you are a volunteer we have been wanted
for a long time. Thanks!
I am one of people who really want to expand vm_flags to 64 bit but when KOSAKI
tried it, Linus said his concerning, I guess you already saw that.

He want to tidy vm_flags's usage up rather than expanding it.
Without the discussion about that, just expanding vm_flags would make us use 
it up easily so that we might need more space. 

Readahead flags are good candidate to move into another space and arch-specific flags, I guess.
Another candidate I think of is THP flag. It's just for only anonymous vma now
(But I am not sure we have a plan to support it for file-backed pages in future)
so we can move it to anon_vma or somewhere.
I think other guys might find more somethings

The point is that at least, we have to discuss about clean up current vm_flags's
use cases before expanding it unconditionally.

On Wed, Mar 21, 2012 at 10:56:07AM +0400, Konstantin Khlebnikov wrote:
> There is good old tradition: every year somebody submit patches for extending
> vma->vm_flags upto 64-bits, because there no free bits left on 32-bit systems.
> 
> previous attempts:
> https://lkml.org/lkml/2011/4/12/24	(KOSAKI Motohiro)
> https://lkml.org/lkml/2010/4/27/23	(Benjamin Herrenschmidt)
> https://lkml.org/lkml/2009/10/1/202	(Hugh Dickins)
> 
> Here already exist special type for this: vm_flags_t, but not all code uses it.
> So, before switching vm_flags_t from unsinged long to u64 we must spread
> vm_flags_t everywhere and fix all possible type-casting problems.
> 
> There is no functional changes in this patch set,
> it only prepares code for vma->vm_flags converting.
> 
> ---
> 
> Konstantin Khlebnikov (16):
>       mm: introduce NR_VMA_FLAGS
>       mm: use vm_flags_t for vma flags
>       mm/shmem: use vm_flags_t for vma flags
>       mm/nommu: use vm_flags_t for vma flags
>       mm/drivers: use vm_flags_t for vma flags
>       mm/x86: use vm_flags_t for vma flags
>       mm/arm: use vm_flags_t for vma flags
>       mm/unicore32: use vm_flags_t for vma flags
>       mm/ia64: use vm_flags_t for vma flags
>       mm/powerpc: use vm_flags_t for vma flags
>       mm/s390: use vm_flags_t for vma flags
>       mm/mips: use vm_flags_t for vma flags
>       mm/parisc: use vm_flags_t for vma flags
>       mm/score: use vm_flags_t for vma flags
>       mm: cast vm_flags_t to u64 before printing
>       mm: vm_flags_t strict type checking
> 
> 
>  arch/arm/include/asm/cacheflush.h                |    5 -
>  arch/arm/kernel/asm-offsets.c                    |    6 +
>  arch/arm/mm/fault.c                              |    2 
>  arch/ia64/mm/fault.c                             |    9 +
>  arch/mips/mm/c-r3k.c                             |    2 
>  arch/mips/mm/c-r4k.c                             |    6 -
>  arch/mips/mm/c-tx39.c                            |    2 
>  arch/parisc/mm/fault.c                           |    4 -
>  arch/powerpc/include/asm/mman.h                  |    2 
>  arch/s390/mm/fault.c                             |    8 +
>  arch/score/mm/cache.c                            |    6 -
>  arch/sh/mm/tlbflush_64.c                         |    2 
>  arch/unicore32/kernel/asm-offsets.c              |    6 +
>  arch/unicore32/mm/fault.c                        |    2 
>  arch/x86/mm/hugetlbpage.c                        |    4 -
>  drivers/char/mem.c                               |    2 
>  drivers/infiniband/hw/ipath/ipath_file_ops.c     |    6 +
>  drivers/infiniband/hw/qib/qib_file_ops.c         |    6 +
>  drivers/media/video/omap3isp/ispqueue.h          |    2 
>  drivers/staging/android/ashmem.c                 |    2 
>  drivers/staging/android/binder.c                 |   15 +-
>  drivers/staging/tidspbridge/core/tiomap3430.c    |   13 +-
>  drivers/staging/tidspbridge/rmgr/drv_interface.c |    4 -
>  fs/binfmt_elf.c                                  |    2 
>  fs/binfmt_elf_fdpic.c                            |   24 ++-
>  fs/exec.c                                        |    2 
>  fs/proc/nommu.c                                  |    3 
>  fs/proc/task_nommu.c                             |   14 +-
>  include/linux/backing-dev.h                      |    7 -
>  include/linux/huge_mm.h                          |    4 -
>  include/linux/ksm.h                              |    8 +
>  include/linux/mm.h                               |  163 +++++++++++++++-------
>  include/linux/mm_types.h                         |   11 +
>  include/linux/mman.h                             |    4 -
>  include/linux/rmap.h                             |    8 +
>  include/linux/shmem_fs.h                         |    5 -
>  kernel/bounds.c                                  |    2 
>  kernel/events/core.c                             |    4 -
>  kernel/fork.c                                    |    2 
>  kernel/sys.c                                     |    4 -
>  mm/backing-dev.c                                 |    4 +
>  mm/huge_memory.c                                 |    2 
>  mm/ksm.c                                         |    4 -
>  mm/madvise.c                                     |    2 
>  mm/memory.c                                      |    9 +
>  mm/mlock.c                                       |    2 
>  mm/mmap.c                                        |   36 ++---
>  mm/mprotect.c                                    |    9 +
>  mm/mremap.c                                      |    2 
>  mm/nommu.c                                       |   19 +--
>  mm/rmap.c                                        |   16 +-
>  mm/shmem.c                                       |   54 ++++---
>  mm/vmscan.c                                      |    4 -
>  53 files changed, 322 insertions(+), 224 deletions(-)
> 
> -- 
> Signature
> 
> --
> 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/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 05/16] mm/drivers: use vm_flags_t for vma flags
  2012-03-21  6:56   ` Konstantin Khlebnikov
@ 2012-03-21 10:34     ` Laurent Pinchart
  -1 siblings, 0 replies; 104+ messages in thread
From: Laurent Pinchart @ 2012-03-21 10:34 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, devel, Greg Kroah-Hartman, linux-kernel,
	Mauro Carvalho Chehab, linux-mm, Arve Hjønnevåg,
	John Stultz, linux-media

Hi Konstantin,

Thanks for the patch.

On Wednesday 21 March 2012 10:56:33 Konstantin Khlebnikov wrote:
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> Cc: linux-media@vger.kernel.org
> Cc: devel@driverdev.osuosl.org
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: "Arve Hjønnevåg" <arve@android.com>
> ---
>  drivers/media/video/omap3isp/ispqueue.h |    2 +-

For the OMAP3 ISP driver,

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  drivers/staging/android/ashmem.c        |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/video/omap3isp/ispqueue.h
> b/drivers/media/video/omap3isp/ispqueue.h index 92c5a12..908dfd7 100644
> --- a/drivers/media/video/omap3isp/ispqueue.h
> +++ b/drivers/media/video/omap3isp/ispqueue.h
> @@ -90,7 +90,7 @@ struct isp_video_buffer {
>  	void *vaddr;
> 
>  	/* For userspace buffers. */
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>  	unsigned long offset;
>  	unsigned int npages;
>  	struct page **pages;
> diff --git a/drivers/staging/android/ashmem.c
> b/drivers/staging/android/ashmem.c index 9f1f27e..4511420 100644
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -269,7 +269,7 @@ out:
>  	return ret;
>  }
> 
> -static inline unsigned long calc_vm_may_flags(unsigned long prot)
> +static inline vm_flags_t calc_vm_may_flags(unsigned long prot)
>  {
>  	return _calc_vm_trans(prot, PROT_READ,  VM_MAYREAD) |
>  	       _calc_vm_trans(prot, PROT_WRITE, VM_MAYWRITE) |
> 

-- 
Regards,

Laurent Pinchart


^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 05/16] mm/drivers: use vm_flags_t for vma flags
@ 2012-03-21 10:34     ` Laurent Pinchart
  0 siblings, 0 replies; 104+ messages in thread
From: Laurent Pinchart @ 2012-03-21 10:34 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, devel, Greg Kroah-Hartman, linux-kernel,
	Mauro Carvalho Chehab, linux-mm, Arve Hjønnevåg,
	John Stultz, linux-media

Hi Konstantin,

Thanks for the patch.

On Wednesday 21 March 2012 10:56:33 Konstantin Khlebnikov wrote:
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> Cc: linux-media@vger.kernel.org
> Cc: devel@driverdev.osuosl.org
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: "Arve Hjønnevåg" <arve@android.com>
> ---
>  drivers/media/video/omap3isp/ispqueue.h |    2 +-

For the OMAP3 ISP driver,

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  drivers/staging/android/ashmem.c        |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/video/omap3isp/ispqueue.h
> b/drivers/media/video/omap3isp/ispqueue.h index 92c5a12..908dfd7 100644
> --- a/drivers/media/video/omap3isp/ispqueue.h
> +++ b/drivers/media/video/omap3isp/ispqueue.h
> @@ -90,7 +90,7 @@ struct isp_video_buffer {
>  	void *vaddr;
> 
>  	/* For userspace buffers. */
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>  	unsigned long offset;
>  	unsigned int npages;
>  	struct page **pages;
> diff --git a/drivers/staging/android/ashmem.c
> b/drivers/staging/android/ashmem.c index 9f1f27e..4511420 100644
> --- a/drivers/staging/android/ashmem.c
> +++ b/drivers/staging/android/ashmem.c
> @@ -269,7 +269,7 @@ out:
>  	return ret;
>  }
> 
> -static inline unsigned long calc_vm_may_flags(unsigned long prot)
> +static inline vm_flags_t calc_vm_may_flags(unsigned long prot)
>  {
>  	return _calc_vm_trans(prot, PROT_READ,  VM_MAYREAD) |
>  	       _calc_vm_trans(prot, PROT_WRITE, VM_MAYWRITE) |
> 

-- 
Regards,

Laurent Pinchart

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* [PATCH v2 04/16] mm/nommu: use vm_flags_t for vma flags
  2012-03-21  6:56   ` Konstantin Khlebnikov
@ 2012-03-21 12:01     ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21 12:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Howells, linux-mm, linux-kernel, Greg Ungerer

v2: fix compilation

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Greg Ungerer <gerg@uclinux.org>

---

This time, I honestly checked the compiling for arm/at91x40_defconfig
last linux-next is broken, but my parts are ok.

---
 fs/proc/nommu.c      |   14 ++++++++------
 fs/proc/task_nommu.c |   14 ++++++++------
 mm/nommu.c           |   19 ++++++++++---------
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index b1822dd..6046ddb 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -39,9 +39,10 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
-	int flags, len;
+	int len;
+	vm_flags_t vm_flags;
 
-	flags = region->vm_flags;
+	vm_flags = region->vm_flags;
 	file = region->vm_file;
 
 	if (file) {
@@ -54,10 +55,11 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
 		   region->vm_start,
 		   region->vm_end,
-		   flags & VM_READ ? 'r' : '-',
-		   flags & VM_WRITE ? 'w' : '-',
-		   flags & VM_EXEC ? 'x' : '-',
-		   flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
+		   vm_flags & VM_READ ? 'r' : '-',
+		   vm_flags & VM_WRITE ? 'w' : '-',
+		   vm_flags & VM_EXEC ? 'x' : '-',
+		   vm_flags & VM_MAYSHARE ?
+			vm_flags & VM_SHARED ? 'S' : 's' : 'p',
 		   ((loff_t)region->vm_pgoff) << PAGE_SHIFT,
 		   MAJOR(dev), MINOR(dev), ino, &len);
 
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 74fe164..9447caa 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
-	int flags, len;
+	int len;
+	vm_flags_t vm_flags;
 	unsigned long long pgoff = 0;
 
-	flags = vma->vm_flags;
+	vm_flags = vma->vm_flags;
 	file = vma->vm_file;
 
 	if (file) {
@@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
 		   vma->vm_start,
 		   vma->vm_end,
-		   flags & VM_READ ? 'r' : '-',
-		   flags & VM_WRITE ? 'w' : '-',
-		   flags & VM_EXEC ? 'x' : '-',
-		   flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
+		   vm_flags & VM_READ ? 'r' : '-',
+		   vm_flags & VM_WRITE ? 'w' : '-',
+		   vm_flags & VM_EXEC ? 'x' : '-',
+		   vm_flags & VM_MAYSHARE ?
+			vm_flags & VM_SHARED ? 'S' : 's' : 'p',
 		   pgoff,
 		   MAJOR(dev), MINOR(dev), ino, &len);
 
diff --git a/mm/nommu.c b/mm/nommu.c
index f59e170..33d0ab7 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 		     int *retry)
 {
 	struct vm_area_struct *vma;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	int i;
 
 	/* calculate required read or write permissions.
@@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
 /*
  * update protection on a vma
  */
-static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
+static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
 {
 #ifdef CONFIG_MPU
 	struct mm_struct *mm = vma->vm_mm;
 	long start = vma->vm_start & PAGE_MASK;
 	while (start < vma->vm_end) {
-		protect_page(mm, start, flags);
+		protect_page(mm, start, vm_flags);
 		start += PAGE_SIZE;
 	}
 	update_protections(mm);
@@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
  * we've determined that we can make the mapping, now translate what we
  * now know into VMA flags
  */
-static unsigned long determine_vm_flags(struct file *file,
-					unsigned long prot,
-					unsigned long flags,
-					unsigned long capabilities)
+static vm_flags_t determine_vm_flags(struct file *file,
+				     unsigned long prot,
+				     unsigned long flags,
+				     unsigned long capabilities)
 {
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 
 	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
 	/* vm_flags |= mm->def_flags; */
@@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
 	struct vm_area_struct *vma;
 	struct vm_region *region;
 	struct rb_node *rb;
-	unsigned long capabilities, vm_flags, result;
+	unsigned long capabilities, result;
+	vm_flags_t vm_flags;
 	int ret;
 
 	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH v2 04/16] mm/nommu: use vm_flags_t for vma flags
@ 2012-03-21 12:01     ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21 12:01 UTC (permalink / raw)
  To: Andrew Morton; +Cc: David Howells, linux-mm, linux-kernel, Greg Ungerer

v2: fix compilation

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Greg Ungerer <gerg@uclinux.org>

---

This time, I honestly checked the compiling for arm/at91x40_defconfig
last linux-next is broken, but my parts are ok.

---
 fs/proc/nommu.c      |   14 ++++++++------
 fs/proc/task_nommu.c |   14 ++++++++------
 mm/nommu.c           |   19 ++++++++++---------
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index b1822dd..6046ddb 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -39,9 +39,10 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
-	int flags, len;
+	int len;
+	vm_flags_t vm_flags;
 
-	flags = region->vm_flags;
+	vm_flags = region->vm_flags;
 	file = region->vm_file;
 
 	if (file) {
@@ -54,10 +55,11 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
 		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
 		   region->vm_start,
 		   region->vm_end,
-		   flags & VM_READ ? 'r' : '-',
-		   flags & VM_WRITE ? 'w' : '-',
-		   flags & VM_EXEC ? 'x' : '-',
-		   flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
+		   vm_flags & VM_READ ? 'r' : '-',
+		   vm_flags & VM_WRITE ? 'w' : '-',
+		   vm_flags & VM_EXEC ? 'x' : '-',
+		   vm_flags & VM_MAYSHARE ?
+			vm_flags & VM_SHARED ? 'S' : 's' : 'p',
 		   ((loff_t)region->vm_pgoff) << PAGE_SHIFT,
 		   MAJOR(dev), MINOR(dev), ino, &len);
 
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 74fe164..9447caa 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 	unsigned long ino = 0;
 	struct file *file;
 	dev_t dev = 0;
-	int flags, len;
+	int len;
+	vm_flags_t vm_flags;
 	unsigned long long pgoff = 0;
 
-	flags = vma->vm_flags;
+	vm_flags = vma->vm_flags;
 	file = vma->vm_file;
 
 	if (file) {
@@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
 		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
 		   vma->vm_start,
 		   vma->vm_end,
-		   flags & VM_READ ? 'r' : '-',
-		   flags & VM_WRITE ? 'w' : '-',
-		   flags & VM_EXEC ? 'x' : '-',
-		   flags & VM_MAYSHARE ? flags & VM_SHARED ? 'S' : 's' : 'p',
+		   vm_flags & VM_READ ? 'r' : '-',
+		   vm_flags & VM_WRITE ? 'w' : '-',
+		   vm_flags & VM_EXEC ? 'x' : '-',
+		   vm_flags & VM_MAYSHARE ?
+			vm_flags & VM_SHARED ? 'S' : 's' : 'p',
 		   pgoff,
 		   MAJOR(dev), MINOR(dev), ino, &len);
 
diff --git a/mm/nommu.c b/mm/nommu.c
index f59e170..33d0ab7 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
 		     int *retry)
 {
 	struct vm_area_struct *vma;
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 	int i;
 
 	/* calculate required read or write permissions.
@@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
 /*
  * update protection on a vma
  */
-static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
+static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
 {
 #ifdef CONFIG_MPU
 	struct mm_struct *mm = vma->vm_mm;
 	long start = vma->vm_start & PAGE_MASK;
 	while (start < vma->vm_end) {
-		protect_page(mm, start, flags);
+		protect_page(mm, start, vm_flags);
 		start += PAGE_SIZE;
 	}
 	update_protections(mm);
@@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
  * we've determined that we can make the mapping, now translate what we
  * now know into VMA flags
  */
-static unsigned long determine_vm_flags(struct file *file,
-					unsigned long prot,
-					unsigned long flags,
-					unsigned long capabilities)
+static vm_flags_t determine_vm_flags(struct file *file,
+				     unsigned long prot,
+				     unsigned long flags,
+				     unsigned long capabilities)
 {
-	unsigned long vm_flags;
+	vm_flags_t vm_flags;
 
 	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
 	/* vm_flags |= mm->def_flags; */
@@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
 	struct vm_area_struct *vma;
 	struct vm_region *region;
 	struct rb_node *rb;
-	unsigned long capabilities, vm_flags, result;
+	unsigned long capabilities, result;
+	vm_flags_t vm_flags;
 	int ret;
 
 	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH v2 16/16] mm: vm_flags_t strict type checking
  2012-03-21  6:57   ` Konstantin Khlebnikov
@ 2012-03-21 12:11     ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21 12:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Hugh Dickins, linux-kernel, KOSAKI Motohiro,
	Benjamin Herrenschmidt

Now nobody uses VM_* constants in macro-expressions, so we can add type to them.

v2: resolve conflict with patch "coredump: add VM_NODUMP, MADV_NODUMP, MADV_CLEAR_NODUMP"

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h       |  135 ++++++++++++++++++++++++++++++++--------------
 include/linux/mm_types.h |    4 +
 2 files changed, 96 insertions(+), 43 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4ff7bad..4aeb3f5 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -74,59 +74,112 @@ extern unsigned int kobjsize(const void *objp);
  * vm_flags in vm_area_struct, see mm_types.h.
  */
 
-#define VM_NONE		0x00000000
+enum {
+	__VM_READ,
+	__VM_WRITE,
+	__VM_EXEC,
+	__VM_SHARED,
+
+	__VM_MAYREAD,
+	__VM_MAYWRITE,
+	__VM_MAYEXEC,
+	__VM_MAYSHARE,
+
+	__VM_GROWSDOWN,
+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
+	__VM_GROWSUP,
+#else
+	__VM_NOHUGEPAGE,
+#endif
+	__VM_PFNMAP,
+	__VM_DENYWRITE,
+
+	__VM_EXECUTABLE,
+	__VM_LOCKED,
+	__VM_IO,
+	__VM_SEQ_READ,
+
+	__VM_RAND_READ,
+	__VM_DONTCOPY,
+	__VM_DONTEXPAND,
+	__VM_RESERVED,
+
+	__VM_ACCOUNT,
+	__VM_NORESERVE,
+	__VM_HUGETLB,
+	__VM_NONLINEAR,
+
+#ifndef CONFIG_TRANSPARENT_HUGEPAGE
+	__VM_MAPPED_COPY,
+#else
+	__VM_HUGEPAGE,
+#endif
+	__VM_INSERTPAGE,
+	__VM_NODUMP,
+	__VM_CAN_NONLINEAR,
+
+	__VM_MIXEDMAP,
+	__VM_SAO,
+	__VM_PFN_AT_MMAP,
+	__VM_MERGEABLE,
+
+	__NR_VMA_FLAGS
+};
+
+#define VM_NONE		((__force vm_flags_t)0)
+
+#define __VMF(name)	((__force vm_flags_t)(1ull << (__VM_##name)))
 
-#define VM_READ		0x00000001	/* currently active flags */
-#define VM_WRITE	0x00000002
-#define VM_EXEC		0x00000004
-#define VM_SHARED	0x00000008
+#define VM_READ		__VMF(READ)	/* currently active flags */
+#define VM_WRITE	__VMF(WRITE)
+#define VM_EXEC		__VMF(EXEC)
+#define VM_SHARED	__VMF(SHARED)
 
 /* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
-#define VM_MAYREAD	0x00000010	/* limits for mprotect() etc */
-#define VM_MAYWRITE	0x00000020
-#define VM_MAYEXEC	0x00000040
-#define VM_MAYSHARE	0x00000080
+#define VM_MAYREAD	__VMF(MAYREAD)	/* limits for mprotect() etc */
+#define VM_MAYWRITE	__VMF(MAYWRITE)
+#define VM_MAYEXEC	__VMF(MAYEXEC)
+#define VM_MAYSHARE	__VMF(MAYSHARE)
 
-#define VM_GROWSDOWN	0x00000100	/* general info on the segment */
+#define VM_GROWSDOWN	__VMF(GROWSDOWN) /* general info on the segment */
 #if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
-#define VM_GROWSUP	0x00000200
+#define VM_GROWSUP	__VMF(GROWSUP)
 #else
-#define VM_GROWSUP	0x00000000
-#define VM_NOHUGEPAGE	0x00000200	/* MADV_NOHUGEPAGE marked this vma */
+#define VM_GROWSUP	VM_NONE
+#define VM_NOHUGEPAGE	__VMF(NOHUGEPAGE) /* MADV_NOHUGEPAGE marked this vma */
 #endif
-#define VM_PFNMAP	0x00000400	/* Page-ranges managed without "struct page", just pure PFN */
-#define VM_DENYWRITE	0x00000800	/* ETXTBSY on write attempts.. */
-
-#define VM_EXECUTABLE	0x00001000
-#define VM_LOCKED	0x00002000
-#define VM_IO           0x00004000	/* Memory mapped I/O or similar */
-
-					/* Used by sys_madvise() */
-#define VM_SEQ_READ	0x00008000	/* App will access data sequentially */
-#define VM_RAND_READ	0x00010000	/* App will not benefit from clustered reads */
-
-#define VM_DONTCOPY	0x00020000      /* Do not copy this vma on fork */
-#define VM_DONTEXPAND	0x00040000	/* Cannot expand with mremap() */
-#define VM_RESERVED	0x00080000	/* Count as reserved_vm like IO */
-#define VM_ACCOUNT	0x00100000	/* Is a VM accounted object */
-#define VM_NORESERVE	0x00200000	/* should the VM suppress accounting */
-#define VM_HUGETLB	0x00400000	/* Huge TLB Page VM */
-#define VM_NONLINEAR	0x00800000	/* Is non-linear (remap_file_pages) */
+#define VM_PFNMAP	__VMF(PFNMAP)	/* Page-ranges managed without "struct page", just pure PFN */
+#define VM_DENYWRITE	__VMF(DENYWRITE)/* ETXTBSY on write attempts.. */
+
+#define VM_EXECUTABLE	__VMF(EXECUTABLE)
+#define VM_LOCKED	__VMF(LOCKED)
+#define VM_IO		__VMF(IO)	/* Memory mapped I/O or similar */
+
+					  /* Used by sys_madvise() */
+#define VM_SEQ_READ	__VMF(SEQ_READ)	/* App will access data sequentially */
+#define VM_RAND_READ	__VMF(RAND_READ) /* App will not benefit from clustered reads */
+
+#define VM_DONTCOPY	__VMF(DONTCOPY)	/* Do not copy this vma on fork */
+#define VM_DONTEXPAND	__VMF(DONTEXPAND) /* Cannot expand with mremap() */
+#define VM_RESERVED	__VMF(RESERVED)	/* Count as reserved_vm like IO */
+#define VM_ACCOUNT	__VMF(ACCOUNT)	/* Is a VM accounted object */
+#define VM_NORESERVE	__VMF(NORESERVE) /* should the VM suppress accounting */
+#define VM_HUGETLB	__VMF(HUGETLB)	/* Huge TLB Page VM */
+#define VM_NONLINEAR	__VMF(NONLINEAR) /* Is non-linear (remap_file_pages) */
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
-#define VM_MAPPED_COPY	0x01000000	/* T if mapped copy of data (nommu mmap) */
+#define VM_MAPPED_COPY	__VMF(MAPPED_COPY) /* T if mapped copy of data (nommu mmap) */
 #else
-#define VM_HUGEPAGE	0x01000000	/* MADV_HUGEPAGE marked this vma */
+#define VM_HUGEPAGE	__VMF(HUGEPAGE)	/* MADV_HUGEPAGE marked this vma */
 #endif
-#define VM_INSERTPAGE	0x02000000	/* The vma has had "vm_insert_page()" done on it */
-#define VM_NODUMP	0x04000000	/* Do not include in the core dump */
 
-#define VM_CAN_NONLINEAR 0x08000000	/* Has ->fault & does nonlinear pages */
-#define VM_MIXEDMAP	0x10000000	/* Can contain "struct page" and pure PFN pages */
-#define VM_SAO		0x20000000	/* Strong Access Ordering (powerpc) */
-#define VM_PFN_AT_MMAP	0x40000000	/* PFNMAP vma that is fully mapped at mmap time */
-#define VM_MERGEABLE	0x80000000	/* KSM may merge identical pages */
+#define VM_INSERTPAGE	__VMF(INSERTPAGE) /* The vma has had "vm_insert_page()" done on it */
+#define VM_NODUMP	__VMF(NODUMP)	/* Do not include in the core dump */
 
-#define __NR_VMA_FLAGS	32
+#define VM_CAN_NONLINEAR __VMF(CAN_NONLINEAR) /* Has ->fault & does nonlinear pages */
+#define VM_MIXEDMAP	__VMF(MIXEDMAP)	/* Can contain "struct page" and pure PFN pages */
+#define VM_SAO		__VMF(SAO)	/* Strong Access Ordering (powerpc) */
+#define VM_PFN_AT_MMAP	__VMF(PFN_AT_MMAP) /* PFNMAP vma that is fully mapped at mmap time */
+#define VM_MERGEABLE	__VMF(MERGEABLE) /* KSM may merge identical pages */
 
 #ifndef __GENERATING_BOUNDS_H
 
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index d57e764..f14cc5e 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -172,9 +172,9 @@ struct page_frag {
 };
 
 #if (NR_VMA_FLAGS > 32)
-typedef unsigned long long __nocast vm_flags_t;
+typedef unsigned long long __bitwise__ vm_flags_t;
 #else
-typedef unsigned long __nocast vm_flags_t;
+typedef unsigned long __bitwise__ vm_flags_t;
 #endif
 
 /*


^ permalink raw reply related	[flat|nested] 104+ messages in thread

* [PATCH v2 16/16] mm: vm_flags_t strict type checking
@ 2012-03-21 12:11     ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21 12:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, Hugh Dickins, linux-kernel, KOSAKI Motohiro,
	Benjamin Herrenschmidt

Now nobody uses VM_* constants in macro-expressions, so we can add type to them.

v2: resolve conflict with patch "coredump: add VM_NODUMP, MADV_NODUMP, MADV_CLEAR_NODUMP"

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
---
 include/linux/mm.h       |  135 ++++++++++++++++++++++++++++++++--------------
 include/linux/mm_types.h |    4 +
 2 files changed, 96 insertions(+), 43 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4ff7bad..4aeb3f5 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -74,59 +74,112 @@ extern unsigned int kobjsize(const void *objp);
  * vm_flags in vm_area_struct, see mm_types.h.
  */
 
-#define VM_NONE		0x00000000
+enum {
+	__VM_READ,
+	__VM_WRITE,
+	__VM_EXEC,
+	__VM_SHARED,
+
+	__VM_MAYREAD,
+	__VM_MAYWRITE,
+	__VM_MAYEXEC,
+	__VM_MAYSHARE,
+
+	__VM_GROWSDOWN,
+#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
+	__VM_GROWSUP,
+#else
+	__VM_NOHUGEPAGE,
+#endif
+	__VM_PFNMAP,
+	__VM_DENYWRITE,
+
+	__VM_EXECUTABLE,
+	__VM_LOCKED,
+	__VM_IO,
+	__VM_SEQ_READ,
+
+	__VM_RAND_READ,
+	__VM_DONTCOPY,
+	__VM_DONTEXPAND,
+	__VM_RESERVED,
+
+	__VM_ACCOUNT,
+	__VM_NORESERVE,
+	__VM_HUGETLB,
+	__VM_NONLINEAR,
+
+#ifndef CONFIG_TRANSPARENT_HUGEPAGE
+	__VM_MAPPED_COPY,
+#else
+	__VM_HUGEPAGE,
+#endif
+	__VM_INSERTPAGE,
+	__VM_NODUMP,
+	__VM_CAN_NONLINEAR,
+
+	__VM_MIXEDMAP,
+	__VM_SAO,
+	__VM_PFN_AT_MMAP,
+	__VM_MERGEABLE,
+
+	__NR_VMA_FLAGS
+};
+
+#define VM_NONE		((__force vm_flags_t)0)
+
+#define __VMF(name)	((__force vm_flags_t)(1ull << (__VM_##name)))
 
-#define VM_READ		0x00000001	/* currently active flags */
-#define VM_WRITE	0x00000002
-#define VM_EXEC		0x00000004
-#define VM_SHARED	0x00000008
+#define VM_READ		__VMF(READ)	/* currently active flags */
+#define VM_WRITE	__VMF(WRITE)
+#define VM_EXEC		__VMF(EXEC)
+#define VM_SHARED	__VMF(SHARED)
 
 /* mprotect() hardcodes VM_MAYREAD >> 4 == VM_READ, and so for r/w/x bits. */
-#define VM_MAYREAD	0x00000010	/* limits for mprotect() etc */
-#define VM_MAYWRITE	0x00000020
-#define VM_MAYEXEC	0x00000040
-#define VM_MAYSHARE	0x00000080
+#define VM_MAYREAD	__VMF(MAYREAD)	/* limits for mprotect() etc */
+#define VM_MAYWRITE	__VMF(MAYWRITE)
+#define VM_MAYEXEC	__VMF(MAYEXEC)
+#define VM_MAYSHARE	__VMF(MAYSHARE)
 
-#define VM_GROWSDOWN	0x00000100	/* general info on the segment */
+#define VM_GROWSDOWN	__VMF(GROWSDOWN) /* general info on the segment */
 #if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
-#define VM_GROWSUP	0x00000200
+#define VM_GROWSUP	__VMF(GROWSUP)
 #else
-#define VM_GROWSUP	0x00000000
-#define VM_NOHUGEPAGE	0x00000200	/* MADV_NOHUGEPAGE marked this vma */
+#define VM_GROWSUP	VM_NONE
+#define VM_NOHUGEPAGE	__VMF(NOHUGEPAGE) /* MADV_NOHUGEPAGE marked this vma */
 #endif
-#define VM_PFNMAP	0x00000400	/* Page-ranges managed without "struct page", just pure PFN */
-#define VM_DENYWRITE	0x00000800	/* ETXTBSY on write attempts.. */
-
-#define VM_EXECUTABLE	0x00001000
-#define VM_LOCKED	0x00002000
-#define VM_IO           0x00004000	/* Memory mapped I/O or similar */
-
-					/* Used by sys_madvise() */
-#define VM_SEQ_READ	0x00008000	/* App will access data sequentially */
-#define VM_RAND_READ	0x00010000	/* App will not benefit from clustered reads */
-
-#define VM_DONTCOPY	0x00020000      /* Do not copy this vma on fork */
-#define VM_DONTEXPAND	0x00040000	/* Cannot expand with mremap() */
-#define VM_RESERVED	0x00080000	/* Count as reserved_vm like IO */
-#define VM_ACCOUNT	0x00100000	/* Is a VM accounted object */
-#define VM_NORESERVE	0x00200000	/* should the VM suppress accounting */
-#define VM_HUGETLB	0x00400000	/* Huge TLB Page VM */
-#define VM_NONLINEAR	0x00800000	/* Is non-linear (remap_file_pages) */
+#define VM_PFNMAP	__VMF(PFNMAP)	/* Page-ranges managed without "struct page", just pure PFN */
+#define VM_DENYWRITE	__VMF(DENYWRITE)/* ETXTBSY on write attempts.. */
+
+#define VM_EXECUTABLE	__VMF(EXECUTABLE)
+#define VM_LOCKED	__VMF(LOCKED)
+#define VM_IO		__VMF(IO)	/* Memory mapped I/O or similar */
+
+					  /* Used by sys_madvise() */
+#define VM_SEQ_READ	__VMF(SEQ_READ)	/* App will access data sequentially */
+#define VM_RAND_READ	__VMF(RAND_READ) /* App will not benefit from clustered reads */
+
+#define VM_DONTCOPY	__VMF(DONTCOPY)	/* Do not copy this vma on fork */
+#define VM_DONTEXPAND	__VMF(DONTEXPAND) /* Cannot expand with mremap() */
+#define VM_RESERVED	__VMF(RESERVED)	/* Count as reserved_vm like IO */
+#define VM_ACCOUNT	__VMF(ACCOUNT)	/* Is a VM accounted object */
+#define VM_NORESERVE	__VMF(NORESERVE) /* should the VM suppress accounting */
+#define VM_HUGETLB	__VMF(HUGETLB)	/* Huge TLB Page VM */
+#define VM_NONLINEAR	__VMF(NONLINEAR) /* Is non-linear (remap_file_pages) */
 #ifndef CONFIG_TRANSPARENT_HUGEPAGE
-#define VM_MAPPED_COPY	0x01000000	/* T if mapped copy of data (nommu mmap) */
+#define VM_MAPPED_COPY	__VMF(MAPPED_COPY) /* T if mapped copy of data (nommu mmap) */
 #else
-#define VM_HUGEPAGE	0x01000000	/* MADV_HUGEPAGE marked this vma */
+#define VM_HUGEPAGE	__VMF(HUGEPAGE)	/* MADV_HUGEPAGE marked this vma */
 #endif
-#define VM_INSERTPAGE	0x02000000	/* The vma has had "vm_insert_page()" done on it */
-#define VM_NODUMP	0x04000000	/* Do not include in the core dump */
 
-#define VM_CAN_NONLINEAR 0x08000000	/* Has ->fault & does nonlinear pages */
-#define VM_MIXEDMAP	0x10000000	/* Can contain "struct page" and pure PFN pages */
-#define VM_SAO		0x20000000	/* Strong Access Ordering (powerpc) */
-#define VM_PFN_AT_MMAP	0x40000000	/* PFNMAP vma that is fully mapped at mmap time */
-#define VM_MERGEABLE	0x80000000	/* KSM may merge identical pages */
+#define VM_INSERTPAGE	__VMF(INSERTPAGE) /* The vma has had "vm_insert_page()" done on it */
+#define VM_NODUMP	__VMF(NODUMP)	/* Do not include in the core dump */
 
-#define __NR_VMA_FLAGS	32
+#define VM_CAN_NONLINEAR __VMF(CAN_NONLINEAR) /* Has ->fault & does nonlinear pages */
+#define VM_MIXEDMAP	__VMF(MIXEDMAP)	/* Can contain "struct page" and pure PFN pages */
+#define VM_SAO		__VMF(SAO)	/* Strong Access Ordering (powerpc) */
+#define VM_PFN_AT_MMAP	__VMF(PFN_AT_MMAP) /* PFNMAP vma that is fully mapped at mmap time */
+#define VM_MERGEABLE	__VMF(MERGEABLE) /* KSM may merge identical pages */
 
 #ifndef __GENERATING_BOUNDS_H
 
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index d57e764..f14cc5e 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -172,9 +172,9 @@ struct page_frag {
 };
 
 #if (NR_VMA_FLAGS > 32)
-typedef unsigned long long __nocast vm_flags_t;
+typedef unsigned long long __bitwise__ vm_flags_t;
 #else
-typedef unsigned long __nocast vm_flags_t;
+typedef unsigned long __bitwise__ vm_flags_t;
 #endif
 
 /*

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-21 10:06   ` Minchan Kim
@ 2012-03-21 13:16     ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21 13:16 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Andrew Morton, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Minchan Kim wrote:
> Hi Konstantin,
>
> It seems to be nice clean up to me and you are a volunteer we have been wanted
> for a long time. Thanks!
> I am one of people who really want to expand vm_flags to 64 bit but when KOSAKI
> tried it, Linus said his concerning, I guess you already saw that.
>
> He want to tidy vm_flags's usage up rather than expanding it.
> Without the discussion about that, just expanding vm_flags would make us use
> it up easily so that we might need more space.

Strictly speaking, my pachset does not expands vm_flags, it just prepares to this.
Anyway vm_flags_t looks better than hard-coded "unsigned long" and messy type-casts around it.

>
> Readahead flags are good candidate to move into another space and arch-specific flags, I guess.
> Another candidate I think of is THP flag. It's just for only anonymous vma now
> (But I am not sure we have a plan to support it for file-backed pages in future)
> so we can move it to anon_vma or somewhere.
> I think other guys might find more somethings
>
> The point is that at least, we have to discuss about clean up current vm_flags's
> use cases before expanding it unconditionally.

Seems like we can easily remove VM_EXECUTABLE
(count in mm->num_exe_file_vmas amount of vmas with vma->vm_file == mm->exe_file
instead of vmas with VM_EXECUTABLE bit)

And probably VM_CAN_NONLINEAR...

>
> On Wed, Mar 21, 2012 at 10:56:07AM +0400, Konstantin Khlebnikov wrote:
>> There is good old tradition: every year somebody submit patches for extending
>> vma->vm_flags upto 64-bits, because there no free bits left on 32-bit systems.
>>
>> previous attempts:
>> https://lkml.org/lkml/2011/4/12/24	(KOSAKI Motohiro)
>> https://lkml.org/lkml/2010/4/27/23	(Benjamin Herrenschmidt)
>> https://lkml.org/lkml/2009/10/1/202	(Hugh Dickins)
>>
>> Here already exist special type for this: vm_flags_t, but not all code uses it.
>> So, before switching vm_flags_t from unsinged long to u64 we must spread
>> vm_flags_t everywhere and fix all possible type-casting problems.
>>
>> There is no functional changes in this patch set,
>> it only prepares code for vma->vm_flags converting.
>>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-21 13:16     ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-21 13:16 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Andrew Morton, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Minchan Kim wrote:
> Hi Konstantin,
>
> It seems to be nice clean up to me and you are a volunteer we have been wanted
> for a long time. Thanks!
> I am one of people who really want to expand vm_flags to 64 bit but when KOSAKI
> tried it, Linus said his concerning, I guess you already saw that.
>
> He want to tidy vm_flags's usage up rather than expanding it.
> Without the discussion about that, just expanding vm_flags would make us use
> it up easily so that we might need more space.

Strictly speaking, my pachset does not expands vm_flags, it just prepares to this.
Anyway vm_flags_t looks better than hard-coded "unsigned long" and messy type-casts around it.

>
> Readahead flags are good candidate to move into another space and arch-specific flags, I guess.
> Another candidate I think of is THP flag. It's just for only anonymous vma now
> (But I am not sure we have a plan to support it for file-backed pages in future)
> so we can move it to anon_vma or somewhere.
> I think other guys might find more somethings
>
> The point is that at least, we have to discuss about clean up current vm_flags's
> use cases before expanding it unconditionally.

Seems like we can easily remove VM_EXECUTABLE
(count in mm->num_exe_file_vmas amount of vmas with vma->vm_file == mm->exe_file
instead of vmas with VM_EXECUTABLE bit)

And probably VM_CAN_NONLINEAR...

>
> On Wed, Mar 21, 2012 at 10:56:07AM +0400, Konstantin Khlebnikov wrote:
>> There is good old tradition: every year somebody submit patches for extending
>> vma->vm_flags upto 64-bits, because there no free bits left on 32-bit systems.
>>
>> previous attempts:
>> https://lkml.org/lkml/2011/4/12/24	(KOSAKI Motohiro)
>> https://lkml.org/lkml/2010/4/27/23	(Benjamin Herrenschmidt)
>> https://lkml.org/lkml/2009/10/1/202	(Hugh Dickins)
>>
>> Here already exist special type for this: vm_flags_t, but not all code uses it.
>> So, before switching vm_flags_t from unsinged long to u64 we must spread
>> vm_flags_t everywhere and fix all possible type-casting problems.
>>
>> There is no functional changes in this patch set,
>> it only prepares code for vma->vm_flags converting.
>>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 05/16] mm/drivers: use vm_flags_t for vma flags
  2012-03-21  6:56   ` Konstantin Khlebnikov
@ 2012-03-21 14:46     ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 104+ messages in thread
From: Greg Kroah-Hartman @ 2012-03-21 14:46 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, devel, linux-kernel, Mauro Carvalho Chehab,
	linux-mm, Arve Hjønnevåg, John Stultz,
	Laurent Pinchart, linux-media

On Wed, Mar 21, 2012 at 10:56:33AM +0400, Konstantin Khlebnikov wrote:
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> Cc: linux-media@vger.kernel.org
> Cc: devel@driverdev.osuosl.org
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: "Arve Hjønnevåg" <arve@android.com>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 05/16] mm/drivers: use vm_flags_t for vma flags
@ 2012-03-21 14:46     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 104+ messages in thread
From: Greg Kroah-Hartman @ 2012-03-21 14:46 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, devel, linux-kernel, Mauro Carvalho Chehab,
	linux-mm, Arve Hjønnevåg, John Stultz,
	Laurent Pinchart, linux-media

On Wed, Mar 21, 2012 at 10:56:33AM +0400, Konstantin Khlebnikov wrote:
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> Cc: linux-media@vger.kernel.org
> Cc: devel@driverdev.osuosl.org
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: John Stultz <john.stultz@linaro.org>
> Cc: "Arve Hjonnevag" <arve@android.com>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-21 13:16     ` Konstantin Khlebnikov
@ 2012-03-22  5:39       ` Minchan Kim
  -1 siblings, 0 replies; 104+ messages in thread
From: Minchan Kim @ 2012-03-22  5:39 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Wed, Mar 21, 2012 at 05:16:06PM +0400, Konstantin Khlebnikov wrote:
> Minchan Kim wrote:
> >Hi Konstantin,
> >
> >It seems to be nice clean up to me and you are a volunteer we have been wanted
> >for a long time. Thanks!
> >I am one of people who really want to expand vm_flags to 64 bit but when KOSAKI
> >tried it, Linus said his concerning, I guess you already saw that.
> >
> >He want to tidy vm_flags's usage up rather than expanding it.
> >Without the discussion about that, just expanding vm_flags would make us use
> >it up easily so that we might need more space.
> 
> Strictly speaking, my pachset does not expands vm_flags, it just prepares to this.
> Anyway vm_flags_t looks better than hard-coded "unsigned long" and messy type-casts around it.

Indeed.

> 
> >
> >Readahead flags are good candidate to move into another space and arch-specific flags, I guess.
> >Another candidate I think of is THP flag. It's just for only anonymous vma now
> >(But I am not sure we have a plan to support it for file-backed pages in future)
> >so we can move it to anon_vma or somewhere.
> >I think other guys might find more somethings
> >
> >The point is that at least, we have to discuss about clean up current vm_flags's
> >use cases before expanding it unconditionally.
> 
> Seems like we can easily remove VM_EXECUTABLE
> (count in mm->num_exe_file_vmas amount of vmas with vma->vm_file == mm->exe_file
> instead of vmas with VM_EXECUTABLE bit)
> 
> And probably VM_CAN_NONLINEAR...

I think we can also unify VM_MAPPED_COPY(nommu) and VM_SAO(powerpc) with one VM_ARCH_1
Okay. After this series is merged, let's try to remove flags we can do. Then, other guys
might suggest another ideas.

Thanks.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22  5:39       ` Minchan Kim
  0 siblings, 0 replies; 104+ messages in thread
From: Minchan Kim @ 2012-03-22  5:39 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Wed, Mar 21, 2012 at 05:16:06PM +0400, Konstantin Khlebnikov wrote:
> Minchan Kim wrote:
> >Hi Konstantin,
> >
> >It seems to be nice clean up to me and you are a volunteer we have been wanted
> >for a long time. Thanks!
> >I am one of people who really want to expand vm_flags to 64 bit but when KOSAKI
> >tried it, Linus said his concerning, I guess you already saw that.
> >
> >He want to tidy vm_flags's usage up rather than expanding it.
> >Without the discussion about that, just expanding vm_flags would make us use
> >it up easily so that we might need more space.
> 
> Strictly speaking, my pachset does not expands vm_flags, it just prepares to this.
> Anyway vm_flags_t looks better than hard-coded "unsigned long" and messy type-casts around it.

Indeed.

> 
> >
> >Readahead flags are good candidate to move into another space and arch-specific flags, I guess.
> >Another candidate I think of is THP flag. It's just for only anonymous vma now
> >(But I am not sure we have a plan to support it for file-backed pages in future)
> >so we can move it to anon_vma or somewhere.
> >I think other guys might find more somethings
> >
> >The point is that at least, we have to discuss about clean up current vm_flags's
> >use cases before expanding it unconditionally.
> 
> Seems like we can easily remove VM_EXECUTABLE
> (count in mm->num_exe_file_vmas amount of vmas with vma->vm_file == mm->exe_file
> instead of vmas with VM_EXECUTABLE bit)
> 
> And probably VM_CAN_NONLINEAR...

I think we can also unify VM_MAPPED_COPY(nommu) and VM_SAO(powerpc) with one VM_ARCH_1
Okay. After this series is merged, let's try to remove flags we can do. Then, other guys
might suggest another ideas.

Thanks.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22  5:39       ` Minchan Kim
@ 2012-03-22  6:22         ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 104+ messages in thread
From: Benjamin Herrenschmidt @ 2012-03-22  6:22 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Konstantin Khlebnikov, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

On Thu, 2012-03-22 at 14:39 +0900, Minchan Kim wrote:
> I think we can also unify VM_MAPPED_COPY(nommu) and VM_SAO(powerpc)
> with one VM_ARCH_1
> Okay. After this series is merged, let's try to remove flags we can
> do. Then, other guys
> might suggest another ideas.

Agreed. I would like more VM_ARCH while at it :-)

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22  6:22         ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 104+ messages in thread
From: Benjamin Herrenschmidt @ 2012-03-22  6:22 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Konstantin Khlebnikov, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

On Thu, 2012-03-22 at 14:39 +0900, Minchan Kim wrote:
> I think we can also unify VM_MAPPED_COPY(nommu) and VM_SAO(powerpc)
> with one VM_ARCH_1
> Okay. After this series is merged, let's try to remove flags we can
> do. Then, other guys
> might suggest another ideas.

Agreed. I would like more VM_ARCH while at it :-)

Cheers,
Ben.


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 07/16] mm/arm: use vm_flags_t for vma flags
  2012-03-21  6:56   ` Konstantin Khlebnikov
  (?)
@ 2012-03-22 21:21     ` Andrew Morton
  -1 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 21:21 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: linux-mm, Russell King, linux-kernel, linux-arm-kernel

On Wed, 21 Mar 2012 10:56:42 +0400
Konstantin Khlebnikov <khlebnikov@openvz.org> wrote:

> Cast vm_flags to unsigned int for __cpuc_flush_user_range(),
> because its vm_flags argument declared as unsigned int.
> Asssembler code wants to test VM_EXEC bit on vma->vm_flags,
> but for big-endian we should get upper word for this.
> 
> ...
>
> --- a/arch/arm/include/asm/cacheflush.h
> +++ b/arch/arm/include/asm/cacheflush.h
> @@ -217,7 +217,7 @@ vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
>  {
>  	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm)))
>  		__cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
> -					vma->vm_flags);
> +					(__force unsigned int)vma->vm_flags);
>  }

This won't work if a later version of __cpuc_flush_user_range() needs
access to newly-added flags in the upper 32 bits.

I guess we don't have to do anything about it at this stage, and that
if we do ever hit this problem, we'll need to put those newly-added
flags into the lower 32 bits of the vm_flags_t.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 07/16] mm/arm: use vm_flags_t for vma flags
@ 2012-03-22 21:21     ` Andrew Morton
  0 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 21:21 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: linux-mm, Russell King, linux-kernel, linux-arm-kernel

On Wed, 21 Mar 2012 10:56:42 +0400
Konstantin Khlebnikov <khlebnikov@openvz.org> wrote:

> Cast vm_flags to unsigned int for __cpuc_flush_user_range(),
> because its vm_flags argument declared as unsigned int.
> Asssembler code wants to test VM_EXEC bit on vma->vm_flags,
> but for big-endian we should get upper word for this.
> 
> ...
>
> --- a/arch/arm/include/asm/cacheflush.h
> +++ b/arch/arm/include/asm/cacheflush.h
> @@ -217,7 +217,7 @@ vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
>  {
>  	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm)))
>  		__cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
> -					vma->vm_flags);
> +					(__force unsigned int)vma->vm_flags);
>  }

This won't work if a later version of __cpuc_flush_user_range() needs
access to newly-added flags in the upper 32 bits.

I guess we don't have to do anything about it at this stage, and that
if we do ever hit this problem, we'll need to put those newly-added
flags into the lower 32 bits of the vm_flags_t.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* [PATCH 07/16] mm/arm: use vm_flags_t for vma flags
@ 2012-03-22 21:21     ` Andrew Morton
  0 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 21:21 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 21 Mar 2012 10:56:42 +0400
Konstantin Khlebnikov <khlebnikov@openvz.org> wrote:

> Cast vm_flags to unsigned int for __cpuc_flush_user_range(),
> because its vm_flags argument declared as unsigned int.
> Asssembler code wants to test VM_EXEC bit on vma->vm_flags,
> but for big-endian we should get upper word for this.
> 
> ...
>
> --- a/arch/arm/include/asm/cacheflush.h
> +++ b/arch/arm/include/asm/cacheflush.h
> @@ -217,7 +217,7 @@ vivt_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned
>  {
>  	if (cpumask_test_cpu(smp_processor_id(), mm_cpumask(vma->vm_mm)))
>  		__cpuc_flush_user_range(start & PAGE_MASK, PAGE_ALIGN(end),
> -					vma->vm_flags);
> +					(__force unsigned int)vma->vm_flags);
>  }

This won't work if a later version of __cpuc_flush_user_range() needs
access to newly-added flags in the upper 32 bits.

I guess we don't have to do anything about it at this stage, and that
if we do ever hit this problem, we'll need to put those newly-added
flags into the lower 32 bits of the vm_flags_t.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-21 13:16     ` Konstantin Khlebnikov
@ 2012-03-22 21:26       ` Andrew Morton
  -1 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 21:26 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Minchan Kim, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

On Wed, 21 Mar 2012 17:16:06 +0400
Konstantin Khlebnikov <khlebnikov@openvz.org> wrote:

> Minchan Kim wrote:
> > Hi Konstantin,
> >
> > It seems to be nice clean up to me and you are a volunteer we have been wanted
> > for a long time. Thanks!
> > I am one of people who really want to expand vm_flags to 64 bit but when KOSAKI
> > tried it, Linus said his concerning, I guess you already saw that.
> >
> > He want to tidy vm_flags's usage up rather than expanding it.
> > Without the discussion about that, just expanding vm_flags would make us use
> > it up easily so that we might need more space.
> 
> Strictly speaking, my pachset does not expands vm_flags, it just prepares to this.
> Anyway vm_flags_t looks better than hard-coded "unsigned long" and messy type-casts around it.

It would be nice to find some way of triggering compiler warnings or
sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
thoughts on this?

(Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
describe it)

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 21:26       ` Andrew Morton
  0 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 21:26 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Minchan Kim, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

On Wed, 21 Mar 2012 17:16:06 +0400
Konstantin Khlebnikov <khlebnikov@openvz.org> wrote:

> Minchan Kim wrote:
> > Hi Konstantin,
> >
> > It seems to be nice clean up to me and you are a volunteer we have been wanted
> > for a long time. Thanks!
> > I am one of people who really want to expand vm_flags to 64 bit but when KOSAKI
> > tried it, Linus said his concerning, I guess you already saw that.
> >
> > He want to tidy vm_flags's usage up rather than expanding it.
> > Without the discussion about that, just expanding vm_flags would make us use
> > it up easily so that we might need more space.
> 
> Strictly speaking, my pachset does not expands vm_flags, it just prepares to this.
> Anyway vm_flags_t looks better than hard-coded "unsigned long" and messy type-casts around it.

It would be nice to find some way of triggering compiler warnings or
sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
thoughts on this?

(Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
describe it)

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 21:26       ` Andrew Morton
@ 2012-03-22 21:28         ` Al Viro
  -1 siblings, 0 replies; 104+ messages in thread
From: Al Viro @ 2012-03-22 21:28 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Konstantin Khlebnikov, Minchan Kim, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
> It would be nice to find some way of triggering compiler warnings or
> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
> thoughts on this?
> 
> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
> describe it)

Use __bitwise for that - check how gfp_t is handled.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 21:28         ` Al Viro
  0 siblings, 0 replies; 104+ messages in thread
From: Al Viro @ 2012-03-22 21:28 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Konstantin Khlebnikov, Minchan Kim, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
> It would be nice to find some way of triggering compiler warnings or
> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
> thoughts on this?
> 
> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
> describe it)

Use __bitwise for that - check how gfp_t is handled.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 21:28         ` Al Viro
@ 2012-03-22 21:41           ` Andrew Morton
  -1 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 21:41 UTC (permalink / raw)
  To: Al Viro
  Cc: Konstantin Khlebnikov, Minchan Kim, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Thu, 22 Mar 2012 21:28:11 +0000
Al Viro <viro@ZenIV.linux.org.uk> wrote:

> On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
> > It would be nice to find some way of triggering compiler warnings or
> > sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
> > thoughts on this?
> > 
> > (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
> > describe it)
> 
> Use __bitwise for that - check how gfp_t is handled.

So what does __nocast do?

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 21:41           ` Andrew Morton
  0 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 21:41 UTC (permalink / raw)
  To: Al Viro
  Cc: Konstantin Khlebnikov, Minchan Kim, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Thu, 22 Mar 2012 21:28:11 +0000
Al Viro <viro@ZenIV.linux.org.uk> wrote:

> On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
> > It would be nice to find some way of triggering compiler warnings or
> > sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
> > thoughts on this?
> > 
> > (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
> > describe it)
> 
> Use __bitwise for that - check how gfp_t is handled.

So what does __nocast do?

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 21:41           ` Andrew Morton
@ 2012-03-22 21:57             ` Al Viro
  -1 siblings, 0 replies; 104+ messages in thread
From: Al Viro @ 2012-03-22 21:57 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Konstantin Khlebnikov, Minchan Kim, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Thu, Mar 22, 2012 at 02:41:22PM -0700, Andrew Morton wrote:
> On Thu, 22 Mar 2012 21:28:11 +0000
> Al Viro <viro@ZenIV.linux.org.uk> wrote:
> 
> > On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
> > > It would be nice to find some way of triggering compiler warnings or
> > > sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
> > > thoughts on this?
> > > 
> > > (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
> > > describe it)
> > 
> > Use __bitwise for that - check how gfp_t is handled.
> 
> So what does __nocast do?

Not much...  Basically, extending conversions.  __nocast int can be
freely mixed with int - no complaints will be given.

As far as I'm concerned, it's deprecated - it's weaker than __bitwise and
doesn't have particulary useful semantics.  For this kind of stuff (flags)
__bitwise is definitely better - that's what it had been implemented for.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 21:57             ` Al Viro
  0 siblings, 0 replies; 104+ messages in thread
From: Al Viro @ 2012-03-22 21:57 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Konstantin Khlebnikov, Minchan Kim, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Thu, Mar 22, 2012 at 02:41:22PM -0700, Andrew Morton wrote:
> On Thu, 22 Mar 2012 21:28:11 +0000
> Al Viro <viro@ZenIV.linux.org.uk> wrote:
> 
> > On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
> > > It would be nice to find some way of triggering compiler warnings or
> > > sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
> > > thoughts on this?
> > > 
> > > (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
> > > describe it)
> > 
> > Use __bitwise for that - check how gfp_t is handled.
> 
> So what does __nocast do?

Not much...  Basically, extending conversions.  __nocast int can be
freely mixed with int - no complaints will be given.

As far as I'm concerned, it's deprecated - it's weaker than __bitwise and
doesn't have particulary useful semantics.  For this kind of stuff (flags)
__bitwise is definitely better - that's what it had been implemented for.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 21:41           ` Andrew Morton
@ 2012-03-22 22:05             ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-22 22:05 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, Minchan Kim, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Andrew Morton wrote:
> On Thu, 22 Mar 2012 21:28:11 +0000
> Al Viro<viro@ZenIV.linux.org.uk>  wrote:
>
>> On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
>>> It would be nice to find some way of triggering compiler warnings or
>>> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
>>> thoughts on this?
>>>
>>> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
>>> describe it)
>>
>> Use __bitwise for that - check how gfp_t is handled.
>
> So what does __nocast do?

Actually it forbid any non-forced casts, but its implementation in sparse seems buggy:
__nocast generates some strange false positives. For example it sometimes forgot about
type attributes in function arguments, I saw this for vm_flags argument in ksm_madvise().
I can reproduce this bug, if somebody interested.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 22:05             ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-22 22:05 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, Minchan Kim, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Andrew Morton wrote:
> On Thu, 22 Mar 2012 21:28:11 +0000
> Al Viro<viro@ZenIV.linux.org.uk>  wrote:
>
>> On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
>>> It would be nice to find some way of triggering compiler warnings or
>>> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
>>> thoughts on this?
>>>
>>> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
>>> describe it)
>>
>> Use __bitwise for that - check how gfp_t is handled.
>
> So what does __nocast do?

Actually it forbid any non-forced casts, but its implementation in sparse seems buggy:
__nocast generates some strange false positives. For example it sometimes forgot about
type attributes in function arguments, I saw this for vm_flags argument in ksm_madvise().
I can reproduce this bug, if somebody interested.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 21:41           ` Andrew Morton
@ 2012-03-22 22:08             ` Linus Torvalds
  -1 siblings, 0 replies; 104+ messages in thread
From: Linus Torvalds @ 2012-03-22 22:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, Konstantin Khlebnikov, Minchan Kim, linux-mm,
	linux-kernel, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Thu, Mar 22, 2012 at 2:41 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
>>
>> Use __bitwise for that - check how gfp_t is handled.
>
> So what does __nocast do?

__nocast warns about explicit or implicit casting to different types.

HOWEVER, it doesn't consider two 32-bit integers to be different
types, so a __nocast 'int' type may be returned as a regular 'int'
type and then the __nocast is lost.

So "__nocast" on integer types is usually not that powerful. It just
gets lost too easily. It's more useful for things like pointers. It
also doesn't warn about the mixing: you can add integers to __nocast
integer types, and it's not really considered anything wrong.

__bitwise ends up being a "stronger integer separation". That one
doesn't allow you to mix with non-bitwise integers, so now it's much
harder to lose the type by mistake.

So basic rules is:

 - "__nocast" on its own tends to be more useful for *big* integers
that still need to act like integers, but you want to make it much
less likely that they get truncated by mistake. So a 64-bit integer
that you don't want to mistakenly/silently be returned as "int", for
example. But they mix well with random integer types, so you can add
to them etc without using anything special. However, that mixing also
means that the __nocast really gets lost fairly easily.

 - "__bitwise" is for *unique types* that cannot be mixed with other
types, and that you'd never want to just use as a random integer (the
integer 0 is special, though, and gets silently accepted iirc - it's
kind of like "NULL" for pointers). So "gfp_t" or the "safe endianness"
types would be __bitwise: you can only operate on them by doing
specific operations that know about *that* particular type.

Generally, you want __bitwise if you are looking for type safety.
"__nocast" really is pretty weak.

                  Linus

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 22:08             ` Linus Torvalds
  0 siblings, 0 replies; 104+ messages in thread
From: Linus Torvalds @ 2012-03-22 22:08 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, Konstantin Khlebnikov, Minchan Kim, linux-mm,
	linux-kernel, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux

On Thu, Mar 22, 2012 at 2:41 PM, Andrew Morton
<akpm@linux-foundation.org> wrote:
>>
>> Use __bitwise for that - check how gfp_t is handled.
>
> So what does __nocast do?

__nocast warns about explicit or implicit casting to different types.

HOWEVER, it doesn't consider two 32-bit integers to be different
types, so a __nocast 'int' type may be returned as a regular 'int'
type and then the __nocast is lost.

So "__nocast" on integer types is usually not that powerful. It just
gets lost too easily. It's more useful for things like pointers. It
also doesn't warn about the mixing: you can add integers to __nocast
integer types, and it's not really considered anything wrong.

__bitwise ends up being a "stronger integer separation". That one
doesn't allow you to mix with non-bitwise integers, so now it's much
harder to lose the type by mistake.

So basic rules is:

 - "__nocast" on its own tends to be more useful for *big* integers
that still need to act like integers, but you want to make it much
less likely that they get truncated by mistake. So a 64-bit integer
that you don't want to mistakenly/silently be returned as "int", for
example. But they mix well with random integer types, so you can add
to them etc without using anything special. However, that mixing also
means that the __nocast really gets lost fairly easily.

 - "__bitwise" is for *unique types* that cannot be mixed with other
types, and that you'd never want to just use as a random integer (the
integer 0 is special, though, and gets silently accepted iirc - it's
kind of like "NULL" for pointers). So "gfp_t" or the "safe endianness"
types would be __bitwise: you can only operate on them by doing
specific operations that know about *that* particular type.

Generally, you want __bitwise if you are looking for type safety.
"__nocast" really is pretty weak.

                  Linus

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 22:05             ` Konstantin Khlebnikov
@ 2012-03-22 22:24               ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-22 22:24 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, Minchan Kim, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Konstantin Khlebnikov wrote:
> Andrew Morton wrote:
>> On Thu, 22 Mar 2012 21:28:11 +0000
>> Al Viro<viro@ZenIV.linux.org.uk>   wrote:
>>
>>> On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
>>>> It would be nice to find some way of triggering compiler warnings or
>>>> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
>>>> thoughts on this?
>>>>
>>>> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
>>>> describe it)
>>>
>>> Use __bitwise for that - check how gfp_t is handled.
>>
>> So what does __nocast do?
>
> Actually it forbid any non-forced casts, but its implementation in sparse seems buggy:
> __nocast generates some strange false positives. For example it sometimes forgot about
> type attributes in function arguments, I saw this for vm_flags argument in ksm_madvise().
> I can reproduce this bug, if somebody interested.
>

1.c:

# define __nocast	__attribute__((nocast))

typedef long __nocast long_t;

static void f(long_t *x)
{
}

static void g(void)
{
	long_t x;

	f(&x);
}

$ sparse 1.c
1.c:13:12: warning: incorrect type in argument 1 (different modifiers)
1.c:13:12:    expected int [nocast] [usertype] *x
1.c:13:12:    got int *<noident>
1.c:13:12: warning: implicit cast to nocast type

Is this ok?


^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 22:24               ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-22 22:24 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, Minchan Kim, linux-mm, linux-kernel, Linus Torvalds,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Konstantin Khlebnikov wrote:
> Andrew Morton wrote:
>> On Thu, 22 Mar 2012 21:28:11 +0000
>> Al Viro<viro@ZenIV.linux.org.uk>   wrote:
>>
>>> On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
>>>> It would be nice to find some way of triggering compiler warnings or
>>>> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
>>>> thoughts on this?
>>>>
>>>> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
>>>> describe it)
>>>
>>> Use __bitwise for that - check how gfp_t is handled.
>>
>> So what does __nocast do?
>
> Actually it forbid any non-forced casts, but its implementation in sparse seems buggy:
> __nocast generates some strange false positives. For example it sometimes forgot about
> type attributes in function arguments, I saw this for vm_flags argument in ksm_madvise().
> I can reproduce this bug, if somebody interested.
>

1.c:

# define __nocast	__attribute__((nocast))

typedef long __nocast long_t;

static void f(long_t *x)
{
}

static void g(void)
{
	long_t x;

	f(&x);
}

$ sparse 1.c
1.c:13:12: warning: incorrect type in argument 1 (different modifiers)
1.c:13:12:    expected int [nocast] [usertype] *x
1.c:13:12:    got int *<noident>
1.c:13:12: warning: implicit cast to nocast type

Is this ok?

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 22:24               ` Konstantin Khlebnikov
@ 2012-03-22 22:39                 ` Linus Torvalds
  -1 siblings, 0 replies; 104+ messages in thread
From: Linus Torvalds @ 2012-03-22 22:39 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, Al Viro, Minchan Kim, linux-mm, linux-kernel,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

On Thu, Mar 22, 2012 at 3:24 PM, Konstantin Khlebnikov
<khlebnikov@openvz.org> wrote:
>
> # define __nocast       __attribute__((nocast))
>
> typedef long __nocast long_t;

So the intention is that this really creates a *new* type.

So "long_t" really is a different type from "long", but because
__nocast is so weak, it happily casts to another integer type of the
same size.

But a pointer to it is different, the same way "int *" is different
from "long *" even if "int" and "long" happen to have the same size.
So I do think that the warning you quote is correct and expected:

> 1.c:13:12: warning: incorrect type in argument 1 (different modifiers)
> 1.c:13:12:    expected int [nocast] [usertype] *x
> 1.c:13:12:    got int *<noident>
> 1.c:13:12: warning: implicit cast to nocast type
>
> Is this ok?

Yes.

The thing about __nocast is that it's so *very* very easy to lose it.
For example, do this:

  typedef long __nocast long_t;

  int main(long_t a)
  {
        return a;
  }

and you get the (expected) warning.

HOWEVER. Now do "return a+1" instead, and the warning goes away. Why?
Because the expression ends up having just the type "long", because
the "a" mixed happily with the "1" (that was cast from 'int' to 'long'
by the normal C type rules).

That is arguably a bug, but this kind of thing really wasn't what
__nocast was designed for. The __nocast design ended up being too
weak, though, and we hardly use it in the kernel.

                        Linus

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 22:39                 ` Linus Torvalds
  0 siblings, 0 replies; 104+ messages in thread
From: Linus Torvalds @ 2012-03-22 22:39 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, Al Viro, Minchan Kim, linux-mm, linux-kernel,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

On Thu, Mar 22, 2012 at 3:24 PM, Konstantin Khlebnikov
<khlebnikov@openvz.org> wrote:
>
> # define __nocast       __attribute__((nocast))
>
> typedef long __nocast long_t;

So the intention is that this really creates a *new* type.

So "long_t" really is a different type from "long", but because
__nocast is so weak, it happily casts to another integer type of the
same size.

But a pointer to it is different, the same way "int *" is different
from "long *" even if "int" and "long" happen to have the same size.
So I do think that the warning you quote is correct and expected:

> 1.c:13:12: warning: incorrect type in argument 1 (different modifiers)
> 1.c:13:12:    expected int [nocast] [usertype] *x
> 1.c:13:12:    got int *<noident>
> 1.c:13:12: warning: implicit cast to nocast type
>
> Is this ok?

Yes.

The thing about __nocast is that it's so *very* very easy to lose it.
For example, do this:

  typedef long __nocast long_t;

  int main(long_t a)
  {
        return a;
  }

and you get the (expected) warning.

HOWEVER. Now do "return a+1" instead, and the warning goes away. Why?
Because the expression ends up having just the type "long", because
the "a" mixed happily with the "1" (that was cast from 'int' to 'long'
by the normal C type rules).

That is arguably a bug, but this kind of thing really wasn't what
__nocast was designed for. The __nocast design ended up being too
weak, though, and we hardly use it in the kernel.

                        Linus

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 22:39                 ` Linus Torvalds
@ 2012-03-22 22:52                   ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-22 22:52 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Al Viro, Minchan Kim, linux-mm, linux-kernel,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Linus Torvalds wrote:
> On Thu, Mar 22, 2012 at 3:24 PM, Konstantin Khlebnikov
> <khlebnikov@openvz.org>  wrote:
>>
>> # define __nocast       __attribute__((nocast))
>>
>> typedef long __nocast long_t;
>
> So the intention is that this really creates a *new* type.
>
> So "long_t" really is a different type from "long", but because
> __nocast is so weak, it happily casts to another integer type of the
> same size.
>
> But a pointer to it is different, the same way "int *" is different
> from "long *" even if "int" and "long" happen to have the same size.
> So I do think that the warning you quote is correct and expected:
>
>> 1.c:13:12: warning: incorrect type in argument 1 (different modifiers)
>> 1.c:13:12:    expected int [nocast] [usertype] *x
>> 1.c:13:12:    got int *<noident>
>> 1.c:13:12: warning: implicit cast to nocast type
>>
>> Is this ok?
>
> Yes.
>
> The thing about __nocast is that it's so *very* very easy to lose it.
> For example, do this:
>
>    typedef long __nocast long_t;
>
>    int main(long_t a)
>    {
>          return a;
>    }
>
> and you get the (expected) warning.
>
> HOWEVER. Now do "return a+1" instead, and the warning goes away. Why?
> Because the expression ends up having just the type "long", because
> the "a" mixed happily with the "1" (that was cast from 'int' to 'long'
> by the normal C type rules).
>
> That is arguably a bug, but this kind of thing really wasn't what
> __nocast was designed for. The __nocast design ended up being too
> weak, though, and we hardly use it in the kernel.
>

Thanks. Looks like "__nocast" totally undocumented.
It would be nice to add something about this into Documentation/sparse.txt

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 22:52                   ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-22 22:52 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Andrew Morton, Al Viro, Minchan Kim, linux-mm, linux-kernel,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux

Linus Torvalds wrote:
> On Thu, Mar 22, 2012 at 3:24 PM, Konstantin Khlebnikov
> <khlebnikov@openvz.org>  wrote:
>>
>> # define __nocast       __attribute__((nocast))
>>
>> typedef long __nocast long_t;
>
> So the intention is that this really creates a *new* type.
>
> So "long_t" really is a different type from "long", but because
> __nocast is so weak, it happily casts to another integer type of the
> same size.
>
> But a pointer to it is different, the same way "int *" is different
> from "long *" even if "int" and "long" happen to have the same size.
> So I do think that the warning you quote is correct and expected:
>
>> 1.c:13:12: warning: incorrect type in argument 1 (different modifiers)
>> 1.c:13:12:    expected int [nocast] [usertype] *x
>> 1.c:13:12:    got int *<noident>
>> 1.c:13:12: warning: implicit cast to nocast type
>>
>> Is this ok?
>
> Yes.
>
> The thing about __nocast is that it's so *very* very easy to lose it.
> For example, do this:
>
>    typedef long __nocast long_t;
>
>    int main(long_t a)
>    {
>          return a;
>    }
>
> and you get the (expected) warning.
>
> HOWEVER. Now do "return a+1" instead, and the warning goes away. Why?
> Because the expression ends up having just the type "long", because
> the "a" mixed happily with the "1" (that was cast from 'int' to 'long'
> by the normal C type rules).
>
> That is arguably a bug, but this kind of thing really wasn't what
> __nocast was designed for. The __nocast design ended up being too
> weak, though, and we hardly use it in the kernel.
>

Thanks. Looks like "__nocast" totally undocumented.
It would be nice to add something about this into Documentation/sparse.txt

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 22:52                   ` Konstantin Khlebnikov
@ 2012-03-22 23:09                     ` Andrew Morton
  -1 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 23:09 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Linus Torvalds, Al Viro, Minchan Kim, linux-mm, linux-kernel,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux,
	Christopher Li

On Fri, 23 Mar 2012 02:52:05 +0400
Konstantin Khlebnikov <khlebnikov@openvz.org> wrote:

> >> Is this ok?
> >
> > Yes.
> >
> > The thing about __nocast is that it's so *very* very easy to lose it.
> > For example, do this:
> >
> >    typedef long __nocast long_t;
> >
> >    int main(long_t a)
> >    {
> >          return a;
> >    }
> >
> > and you get the (expected) warning.
> >
> > HOWEVER. Now do "return a+1" instead, and the warning goes away. Why?
> > Because the expression ends up having just the type "long", because
> > the "a" mixed happily with the "1" (that was cast from 'int' to 'long'
> > by the normal C type rules).
> >
> > That is arguably a bug, but this kind of thing really wasn't what
> > __nocast was designed for. The __nocast design ended up being too
> > weak, though, and we hardly use it in the kernel.
> >
> 
> Thanks. Looks like "__nocast" totally undocumented.
> It would be nice to add something about this into Documentation/sparse.txt

Yup, Chris has added this to his todo list (thanks!).

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-22 23:09                     ` Andrew Morton
  0 siblings, 0 replies; 104+ messages in thread
From: Andrew Morton @ 2012-03-22 23:09 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Linus Torvalds, Al Viro, Minchan Kim, linux-mm, linux-kernel,
	Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt, linux,
	Christopher Li

On Fri, 23 Mar 2012 02:52:05 +0400
Konstantin Khlebnikov <khlebnikov@openvz.org> wrote:

> >> Is this ok?
> >
> > Yes.
> >
> > The thing about __nocast is that it's so *very* very easy to lose it.
> > For example, do this:
> >
> >    typedef long __nocast long_t;
> >
> >    int main(long_t a)
> >    {
> >          return a;
> >    }
> >
> > and you get the (expected) warning.
> >
> > HOWEVER. Now do "return a+1" instead, and the warning goes away. Why?
> > Because the expression ends up having just the type "long", because
> > the "a" mixed happily with the "1" (that was cast from 'int' to 'long'
> > by the normal C type rules).
> >
> > That is arguably a bug, but this kind of thing really wasn't what
> > __nocast was designed for. The __nocast design ended up being too
> > weak, though, and we hardly use it in the kernel.
> >
> 
> Thanks. Looks like "__nocast" totally undocumented.
> It would be nice to add something about this into Documentation/sparse.txt

Yup, Chris has added this to his todo list (thanks!).

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 23:09                     ` Andrew Morton
@ 2012-03-23  1:42                       ` Al Viro
  -1 siblings, 0 replies; 104+ messages in thread
From: Al Viro @ 2012-03-23  1:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Konstantin Khlebnikov, Linus Torvalds, Minchan Kim, linux-mm,
	linux-kernel, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux, Christopher Li

On Thu, Mar 22, 2012 at 04:09:44PM -0700, Andrew Morton wrote:

> > Thanks. Looks like "__nocast" totally undocumented.
> > It would be nice to add something about this into Documentation/sparse.txt
> 
> Yup, Chris has added this to his todo list (thanks!).

Alternatively, we could just remove the remaining instances in the kernel -
cputime_t is the only borderline reasonable one there; xfs ones should be
__bitwise and so should zd_addr_t thing (with cpu_to_le16() moved from
uses of those suckers to macro definitions).  Hell knows - I suspect that
cputime_t also might've been turned into __bitwise u64, but I hadn't checked
if we ever do plain arithmetics on those...

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-23  1:42                       ` Al Viro
  0 siblings, 0 replies; 104+ messages in thread
From: Al Viro @ 2012-03-23  1:42 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Konstantin Khlebnikov, Linus Torvalds, Minchan Kim, linux-mm,
	linux-kernel, Hugh Dickins, KOSAKI Motohiro, Ben Herrenschmidt,
	linux, Christopher Li

On Thu, Mar 22, 2012 at 04:09:44PM -0700, Andrew Morton wrote:

> > Thanks. Looks like "__nocast" totally undocumented.
> > It would be nice to add something about this into Documentation/sparse.txt
> 
> Yup, Chris has added this to his todo list (thanks!).

Alternatively, we could just remove the remaining instances in the kernel -
cputime_t is the only borderline reasonable one there; xfs ones should be
__bitwise and so should zd_addr_t thing (with cpu_to_le16() moved from
uses of those suckers to macro definitions).  Hell knows - I suspect that
cputime_t also might've been turned into __bitwise u64, but I hadn't checked
if we ever do plain arithmetics on those...

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH v2 04/16] mm/nommu: use vm_flags_t for vma flags
  2012-03-21 12:01     ` Konstantin Khlebnikov
@ 2012-03-23  6:47       ` Greg Ungerer
  -1 siblings, 0 replies; 104+ messages in thread
From: Greg Ungerer @ 2012-03-23  6:47 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, David Howells, linux-mm, linux-kernel, Greg Ungerer

Hi Konstantin,

On 21/03/12 22:01, Konstantin Khlebnikov wrote:
> v2: fix compilation
>
> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
> Cc: David Howells<dhowells@redhat.com>
> Cc: Greg Ungerer<gerg@uclinux.org>
>
> ---
>
> This time, I honestly checked the compiling for arm/at91x40_defconfig
> last linux-next is broken, but my parts are ok.

This looks ok to me.

Acked-by: Greg Ungerer <gerg@uclinux.org>

Regards
Greg



> ---
>   fs/proc/nommu.c      |   14 ++++++++------
>   fs/proc/task_nommu.c |   14 ++++++++------
>   mm/nommu.c           |   19 ++++++++++---------
>   3 files changed, 26 insertions(+), 21 deletions(-)
>
> diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
> index b1822dd..6046ddb 100644
> --- a/fs/proc/nommu.c
> +++ b/fs/proc/nommu.c
> @@ -39,9 +39,10 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
>   	unsigned long ino = 0;
>   	struct file *file;
>   	dev_t dev = 0;
> -	int flags, len;
> +	int len;
> +	vm_flags_t vm_flags;
>
> -	flags = region->vm_flags;
> +	vm_flags = region->vm_flags;
>   	file = region->vm_file;
>
>   	if (file) {
> @@ -54,10 +55,11 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
>   		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
>   		   region->vm_start,
>   		   region->vm_end,
> -		   flags&  VM_READ ? 'r' : '-',
> -		   flags&  VM_WRITE ? 'w' : '-',
> -		   flags&  VM_EXEC ? 'x' : '-',
> -		   flags&  VM_MAYSHARE ? flags&  VM_SHARED ? 'S' : 's' : 'p',
> +		   vm_flags&  VM_READ ? 'r' : '-',
> +		   vm_flags&  VM_WRITE ? 'w' : '-',
> +		   vm_flags&  VM_EXEC ? 'x' : '-',
> +		   vm_flags&  VM_MAYSHARE ?
> +			vm_flags&  VM_SHARED ? 'S' : 's' : 'p',
>   		   ((loff_t)region->vm_pgoff)<<  PAGE_SHIFT,
>   		   MAJOR(dev), MINOR(dev), ino,&len);
>
> diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
> index 74fe164..9447caa 100644
> --- a/fs/proc/task_nommu.c
> +++ b/fs/proc/task_nommu.c
> @@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>   	unsigned long ino = 0;
>   	struct file *file;
>   	dev_t dev = 0;
> -	int flags, len;
> +	int len;
> +	vm_flags_t vm_flags;
>   	unsigned long long pgoff = 0;
>
> -	flags = vma->vm_flags;
> +	vm_flags = vma->vm_flags;
>   	file = vma->vm_file;
>
>   	if (file) {
> @@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>   		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
>   		   vma->vm_start,
>   		   vma->vm_end,
> -		   flags&  VM_READ ? 'r' : '-',
> -		   flags&  VM_WRITE ? 'w' : '-',
> -		   flags&  VM_EXEC ? 'x' : '-',
> -		   flags&  VM_MAYSHARE ? flags&  VM_SHARED ? 'S' : 's' : 'p',
> +		   vm_flags&  VM_READ ? 'r' : '-',
> +		   vm_flags&  VM_WRITE ? 'w' : '-',
> +		   vm_flags&  VM_EXEC ? 'x' : '-',
> +		   vm_flags&  VM_MAYSHARE ?
> +			vm_flags&  VM_SHARED ? 'S' : 's' : 'p',
>   		   pgoff,
>   		   MAJOR(dev), MINOR(dev), ino,&len);
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index f59e170..33d0ab7 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
>   		     int *retry)
>   {
>   	struct vm_area_struct *vma;
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>   	int i;
>
>   	/* calculate required read or write permissions.
> @@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
>   /*
>    * update protection on a vma
>    */
> -static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
> +static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
>   {
>   #ifdef CONFIG_MPU
>   	struct mm_struct *mm = vma->vm_mm;
>   	long start = vma->vm_start&  PAGE_MASK;
>   	while (start<  vma->vm_end) {
> -		protect_page(mm, start, flags);
> +		protect_page(mm, start, vm_flags);
>   		start += PAGE_SIZE;
>   	}
>   	update_protections(mm);
> @@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
>    * we've determined that we can make the mapping, now translate what we
>    * now know into VMA flags
>    */
> -static unsigned long determine_vm_flags(struct file *file,
> -					unsigned long prot,
> -					unsigned long flags,
> -					unsigned long capabilities)
> +static vm_flags_t determine_vm_flags(struct file *file,
> +				     unsigned long prot,
> +				     unsigned long flags,
> +				     unsigned long capabilities)
>   {
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>
>   	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
>   	/* vm_flags |= mm->def_flags; */
> @@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
>   	struct vm_area_struct *vma;
>   	struct vm_region *region;
>   	struct rb_node *rb;
> -	unsigned long capabilities, vm_flags, result;
> +	unsigned long capabilities, result;
> +	vm_flags_t vm_flags;
>   	int ret;
>
>   	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);
>
>
>
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH v2 04/16] mm/nommu: use vm_flags_t for vma flags
@ 2012-03-23  6:47       ` Greg Ungerer
  0 siblings, 0 replies; 104+ messages in thread
From: Greg Ungerer @ 2012-03-23  6:47 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Andrew Morton, David Howells, linux-mm, linux-kernel, Greg Ungerer

Hi Konstantin,

On 21/03/12 22:01, Konstantin Khlebnikov wrote:
> v2: fix compilation
>
> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
> Cc: David Howells<dhowells@redhat.com>
> Cc: Greg Ungerer<gerg@uclinux.org>
>
> ---
>
> This time, I honestly checked the compiling for arm/at91x40_defconfig
> last linux-next is broken, but my parts are ok.

This looks ok to me.

Acked-by: Greg Ungerer <gerg@uclinux.org>

Regards
Greg



> ---
>   fs/proc/nommu.c      |   14 ++++++++------
>   fs/proc/task_nommu.c |   14 ++++++++------
>   mm/nommu.c           |   19 ++++++++++---------
>   3 files changed, 26 insertions(+), 21 deletions(-)
>
> diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
> index b1822dd..6046ddb 100644
> --- a/fs/proc/nommu.c
> +++ b/fs/proc/nommu.c
> @@ -39,9 +39,10 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
>   	unsigned long ino = 0;
>   	struct file *file;
>   	dev_t dev = 0;
> -	int flags, len;
> +	int len;
> +	vm_flags_t vm_flags;
>
> -	flags = region->vm_flags;
> +	vm_flags = region->vm_flags;
>   	file = region->vm_file;
>
>   	if (file) {
> @@ -54,10 +55,11 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
>   		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
>   		   region->vm_start,
>   		   region->vm_end,
> -		   flags&  VM_READ ? 'r' : '-',
> -		   flags&  VM_WRITE ? 'w' : '-',
> -		   flags&  VM_EXEC ? 'x' : '-',
> -		   flags&  VM_MAYSHARE ? flags&  VM_SHARED ? 'S' : 's' : 'p',
> +		   vm_flags&  VM_READ ? 'r' : '-',
> +		   vm_flags&  VM_WRITE ? 'w' : '-',
> +		   vm_flags&  VM_EXEC ? 'x' : '-',
> +		   vm_flags&  VM_MAYSHARE ?
> +			vm_flags&  VM_SHARED ? 'S' : 's' : 'p',
>   		   ((loff_t)region->vm_pgoff)<<  PAGE_SHIFT,
>   		   MAJOR(dev), MINOR(dev), ino,&len);
>
> diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
> index 74fe164..9447caa 100644
> --- a/fs/proc/task_nommu.c
> +++ b/fs/proc/task_nommu.c
> @@ -142,10 +142,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>   	unsigned long ino = 0;
>   	struct file *file;
>   	dev_t dev = 0;
> -	int flags, len;
> +	int len;
> +	vm_flags_t vm_flags;
>   	unsigned long long pgoff = 0;
>
> -	flags = vma->vm_flags;
> +	vm_flags = vma->vm_flags;
>   	file = vma->vm_file;
>
>   	if (file) {
> @@ -159,10 +160,11 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
>   		   "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
>   		   vma->vm_start,
>   		   vma->vm_end,
> -		   flags&  VM_READ ? 'r' : '-',
> -		   flags&  VM_WRITE ? 'w' : '-',
> -		   flags&  VM_EXEC ? 'x' : '-',
> -		   flags&  VM_MAYSHARE ? flags&  VM_SHARED ? 'S' : 's' : 'p',
> +		   vm_flags&  VM_READ ? 'r' : '-',
> +		   vm_flags&  VM_WRITE ? 'w' : '-',
> +		   vm_flags&  VM_EXEC ? 'x' : '-',
> +		   vm_flags&  VM_MAYSHARE ?
> +			vm_flags&  VM_SHARED ? 'S' : 's' : 'p',
>   		   pgoff,
>   		   MAJOR(dev), MINOR(dev), ino,&len);
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index f59e170..33d0ab7 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -130,7 +130,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
>   		     int *retry)
>   {
>   	struct vm_area_struct *vma;
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>   	int i;
>
>   	/* calculate required read or write permissions.
> @@ -658,13 +658,13 @@ static void put_nommu_region(struct vm_region *region)
>   /*
>    * update protection on a vma
>    */
> -static void protect_vma(struct vm_area_struct *vma, unsigned long flags)
> +static void protect_vma(struct vm_area_struct *vma, vm_flags_t vm_flags)
>   {
>   #ifdef CONFIG_MPU
>   	struct mm_struct *mm = vma->vm_mm;
>   	long start = vma->vm_start&  PAGE_MASK;
>   	while (start<  vma->vm_end) {
> -		protect_page(mm, start, flags);
> +		protect_page(mm, start, vm_flags);
>   		start += PAGE_SIZE;
>   	}
>   	update_protections(mm);
> @@ -1060,12 +1060,12 @@ static int validate_mmap_request(struct file *file,
>    * we've determined that we can make the mapping, now translate what we
>    * now know into VMA flags
>    */
> -static unsigned long determine_vm_flags(struct file *file,
> -					unsigned long prot,
> -					unsigned long flags,
> -					unsigned long capabilities)
> +static vm_flags_t determine_vm_flags(struct file *file,
> +				     unsigned long prot,
> +				     unsigned long flags,
> +				     unsigned long capabilities)
>   {
> -	unsigned long vm_flags;
> +	vm_flags_t vm_flags;
>
>   	vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags);
>   	/* vm_flags |= mm->def_flags; */
> @@ -1243,7 +1243,8 @@ unsigned long do_mmap_pgoff(struct file *file,
>   	struct vm_area_struct *vma;
>   	struct vm_region *region;
>   	struct rb_node *rb;
> -	unsigned long capabilities, vm_flags, result;
> +	unsigned long capabilities, result;
> +	vm_flags_t vm_flags;
>   	int ret;
>
>   	kenter(",%lx,%lx,%lx,%lx,%lx", addr, len, prot, flags, pgoff);
>
>
>
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22 21:28         ` Al Viro
@ 2012-03-23 16:19           ` KOSAKI Motohiro
  -1 siblings, 0 replies; 104+ messages in thread
From: KOSAKI Motohiro @ 2012-03-23 16:19 UTC (permalink / raw)
  To: viro
  Cc: akpm, khlebnikov, minchan, linux-mm, linux-kernel, torvalds,
	hughd, kosaki.motohiro, benh, linux

On 3/22/2012 5:28 PM, Al Viro wrote:
> On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
>> It would be nice to find some way of triggering compiler warnings or
>> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
>> thoughts on this?
>>
>> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
>> describe it)
> 
> Use __bitwise for that - check how gfp_t is handled.

Hmm..

If now we activate __bitwise, really plenty driver start create lots warnings.
Does it make sense?

In fact, x86-32 keep 32bit vma_t forever. thus all x86 specific driver don't
need any change. Moreover many ancient drivers has no maintainer and I can't
expect such driver will be fixed even though a warning occur.

So, I think __nocast weakness is better than strict __bitwise annotation for
this situation.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-23 16:19           ` KOSAKI Motohiro
  0 siblings, 0 replies; 104+ messages in thread
From: KOSAKI Motohiro @ 2012-03-23 16:19 UTC (permalink / raw)
  To: viro
  Cc: akpm, khlebnikov, minchan, linux-mm, linux-kernel, torvalds,
	hughd, kosaki.motohiro, benh, linux

On 3/22/2012 5:28 PM, Al Viro wrote:
> On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
>> It would be nice to find some way of triggering compiler warnings or
>> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
>> thoughts on this?
>>
>> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
>> describe it)
> 
> Use __bitwise for that - check how gfp_t is handled.

Hmm..

If now we activate __bitwise, really plenty driver start create lots warnings.
Does it make sense?

In fact, x86-32 keep 32bit vma_t forever. thus all x86 specific driver don't
need any change. Moreover many ancient drivers has no maintainer and I can't
expect such driver will be fixed even though a warning occur.

So, I think __nocast weakness is better than strict __bitwise annotation for
this situation.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-22  6:22         ` Benjamin Herrenschmidt
@ 2012-03-24 14:46           ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-24 14:46 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

Benjamin Herrenschmidt wrote:
> On Thu, 2012-03-22 at 14:39 +0900, Minchan Kim wrote:
>> I think we can also unify VM_MAPPED_COPY(nommu) and VM_SAO(powerpc)
>> with one VM_ARCH_1
>> Okay. After this series is merged, let's try to remove flags we can
>> do. Then, other guys
>> might suggest another ideas.
>
> Agreed. I would like more VM_ARCH while at it :-)

Currently I see here four architecture-specific flags =)

             VM_ARCH_1       VM_ARCH_2       VM_ARCH_3       VM_ARCH_4
     x86     VM_NOHUGEPAGE   VM_HUGEPAGE     -               VM_PFN_AT_MMAP
     powerpc -               -               VM_SAO          -
     parisc  VM_GROWSUP      -               -               -
     ia64    VM_GROWSUP      -               -               -
     nommu   -               VM_MAPPED_COPY  -               -

Obviously we can combine VM_PFN_AT_MMAP, VM_SAO, VM_GROWSUP and VM_MAPPED_COPY into one.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-24 14:46           ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-24 14:46 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

Benjamin Herrenschmidt wrote:
> On Thu, 2012-03-22 at 14:39 +0900, Minchan Kim wrote:
>> I think we can also unify VM_MAPPED_COPY(nommu) and VM_SAO(powerpc)
>> with one VM_ARCH_1
>> Okay. After this series is merged, let's try to remove flags we can
>> do. Then, other guys
>> might suggest another ideas.
>
> Agreed. I would like more VM_ARCH while at it :-)

Currently I see here four architecture-specific flags =)

             VM_ARCH_1       VM_ARCH_2       VM_ARCH_3       VM_ARCH_4
     x86     VM_NOHUGEPAGE   VM_HUGEPAGE     -               VM_PFN_AT_MMAP
     powerpc -               -               VM_SAO          -
     parisc  VM_GROWSUP      -               -               -
     ia64    VM_GROWSUP      -               -               -
     nommu   -               VM_MAPPED_COPY  -               -

Obviously we can combine VM_PFN_AT_MMAP, VM_SAO, VM_GROWSUP and VM_MAPPED_COPY into one.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-24 14:46           ` Konstantin Khlebnikov
@ 2012-03-24 15:00             ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-24 15:00 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

Konstantin Khlebnikov wrote:
> Benjamin Herrenschmidt wrote:
>> On Thu, 2012-03-22 at 14:39 +0900, Minchan Kim wrote:
>>> I think we can also unify VM_MAPPED_COPY(nommu) and VM_SAO(powerpc)
>>> with one VM_ARCH_1
>>> Okay. After this series is merged, let's try to remove flags we can
>>> do. Then, other guys
>>> might suggest another ideas.
>>
>> Agreed. I would like more VM_ARCH while at it :-)
>
> Currently I see here four architecture-specific flags =)
>
> VM_ARCH_1 VM_ARCH_2 VM_ARCH_3 VM_ARCH_4
> x86 VM_NOHUGEPAGE VM_HUGEPAGE - VM_PFN_AT_MMAP
> powerpc - - VM_SAO -
> parisc VM_GROWSUP - - -
> ia64 VM_GROWSUP - - -
> nommu - VM_MAPPED_COPY - -
>
> Obviously we can combine VM_PFN_AT_MMAP, VM_SAO, VM_GROWSUP and VM_MAPPED_COPY into one.

Also logic and usage of VM_IO, VM_RESERVED, VM_PFNMAP, VM_MIXEDMAP,
VM_INSERTPAGE, VM_DONTEXPAND and VM_DONTCOPY are very messy.
I think some of them can be replaced with two flags:
VM_SPECIAL_PFN and VM_SPECIAL_PAGE, or something like this.

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-24 15:00             ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-24 15:00 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

Konstantin Khlebnikov wrote:
> Benjamin Herrenschmidt wrote:
>> On Thu, 2012-03-22 at 14:39 +0900, Minchan Kim wrote:
>>> I think we can also unify VM_MAPPED_COPY(nommu) and VM_SAO(powerpc)
>>> with one VM_ARCH_1
>>> Okay. After this series is merged, let's try to remove flags we can
>>> do. Then, other guys
>>> might suggest another ideas.
>>
>> Agreed. I would like more VM_ARCH while at it :-)
>
> Currently I see here four architecture-specific flags =)
>
> VM_ARCH_1 VM_ARCH_2 VM_ARCH_3 VM_ARCH_4
> x86 VM_NOHUGEPAGE VM_HUGEPAGE - VM_PFN_AT_MMAP
> powerpc - - VM_SAO -
> parisc VM_GROWSUP - - -
> ia64 VM_GROWSUP - - -
> nommu - VM_MAPPED_COPY - -
>
> Obviously we can combine VM_PFN_AT_MMAP, VM_SAO, VM_GROWSUP and VM_MAPPED_COPY into one.

Also logic and usage of VM_IO, VM_RESERVED, VM_PFNMAP, VM_MIXEDMAP,
VM_INSERTPAGE, VM_DONTEXPAND and VM_DONTCOPY are very messy.
I think some of them can be replaced with two flags:
VM_SPECIAL_PFN and VM_SPECIAL_PAGE, or something like this.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-24 14:46           ` Konstantin Khlebnikov
@ 2012-03-24 23:50             ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 104+ messages in thread
From: Benjamin Herrenschmidt @ 2012-03-24 23:50 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

On Sat, 2012-03-24 at 18:46 +0400, Konstantin Khlebnikov wrote:
> Obviously we can combine VM_PFN_AT_MMAP, VM_SAO, VM_GROWSUP and
> VM_MAPPED_COPY into one.

VM_PFN_AT_MMAP isn't arch specific afaik...

Cheers,
Ben.



^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-24 23:50             ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 104+ messages in thread
From: Benjamin Herrenschmidt @ 2012-03-24 23:50 UTC (permalink / raw)
  To: Konstantin Khlebnikov
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

On Sat, 2012-03-24 at 18:46 +0400, Konstantin Khlebnikov wrote:
> Obviously we can combine VM_PFN_AT_MMAP, VM_SAO, VM_GROWSUP and
> VM_MAPPED_COPY into one.

VM_PFN_AT_MMAP isn't arch specific afaik...

Cheers,
Ben.


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-24 23:50             ` Benjamin Herrenschmidt
@ 2012-03-25  7:55               ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-25  7:55 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

Benjamin Herrenschmidt wrote:
> On Sat, 2012-03-24 at 18:46 +0400, Konstantin Khlebnikov wrote:
>> Obviously we can combine VM_PFN_AT_MMAP, VM_SAO, VM_GROWSUP and
>> VM_MAPPED_COPY into one.
>
> VM_PFN_AT_MMAP isn't arch specific afaik...

Technically yes, but all this pfnmap-tracking engine has only one user: x86 PAT.
We can easily make it x86-only, or try to implement it without using special flag on vma.

>
> Cheers,
> Ben.
>
>


^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-25  7:55               ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-25  7:55 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Minchan Kim, Andrew Morton, linux-mm, linux-kernel,
	Linus Torvalds, Hugh Dickins, KOSAKI Motohiro, linux

Benjamin Herrenschmidt wrote:
> On Sat, 2012-03-24 at 18:46 +0400, Konstantin Khlebnikov wrote:
>> Obviously we can combine VM_PFN_AT_MMAP, VM_SAO, VM_GROWSUP and
>> VM_MAPPED_COPY into one.
>
> VM_PFN_AT_MMAP isn't arch specific afaik...

Technically yes, but all this pfnmap-tracking engine has only one user: x86 PAT.
We can easily make it x86-only, or try to implement it without using special flag on vma.

>
> Cheers,
> Ben.
>
>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 08/16] mm/unicore32: use vm_flags_t for vma flags
  2012-03-21  6:56   ` Konstantin Khlebnikov
@ 2012-03-27  3:38     ` Guan Xuetao
  -1 siblings, 0 replies; 104+ messages in thread
From: Guan Xuetao @ 2012-03-27  3:38 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: Andrew Morton, linux-mm, linux-kernel

On 03/21/2012 02:56 PM, Konstantin Khlebnikov wrote:
> The same magic like in arm: assembler code wants to test VM_EXEC,
> but for big-endian we should get upper word for this.
>
> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
> Cc: Guan Xuetao<gxt@mprc.pku.edu.cn>
> ---
>   arch/unicore32/kernel/asm-offsets.c |    6 +++++-
>   arch/unicore32/mm/fault.c           |    2 +-
>   2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/unicore32/kernel/asm-offsets.c b/arch/unicore32/kernel/asm-offsets.c
> index ffcbe75..e3199b5 100644
> --- a/arch/unicore32/kernel/asm-offsets.c
> +++ b/arch/unicore32/kernel/asm-offsets.c
> @@ -87,9 +87,13 @@ int main(void)
>   	DEFINE(S_FRAME_SIZE,	sizeof(struct pt_regs));
>   	BLANK();
>   	DEFINE(VMA_VM_MM,	offsetof(struct vm_area_struct, vm_mm));
> +#if defined(CONFIG_CPU_BIG_ENDIAN)&&  (NR_VMA_FLAGS>  32)
> +	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags) + 4);
> +#else
CONFIG_CPU_BIG/LITTLE_ENDIAN is defined only in some archs, and not 
supported by unicore32.

>   	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags));
> +#endif
>   	BLANK();
> -	DEFINE(VM_EXEC,		VM_EXEC);
> +	DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);
Is this check useful for asm-offsets.h?

>   	BLANK();
>   	DEFINE(PAGE_SZ,		PAGE_SIZE);
>   	BLANK();
> diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
> index 283aa4b..9137996 100644
> --- a/arch/unicore32/mm/fault.c
> +++ b/arch/unicore32/mm/fault.c
> @@ -158,7 +158,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
>    */
>   static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
>   {
> -	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
> +	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;

I am confused  for the type of vm_flags in vm_area_struct being 
'unsigned long',  not vm_flags_t.

Regards,

Guan Xuetao

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 08/16] mm/unicore32: use vm_flags_t for vma flags
@ 2012-03-27  3:38     ` Guan Xuetao
  0 siblings, 0 replies; 104+ messages in thread
From: Guan Xuetao @ 2012-03-27  3:38 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: Andrew Morton, linux-mm, linux-kernel

On 03/21/2012 02:56 PM, Konstantin Khlebnikov wrote:
> The same magic like in arm: assembler code wants to test VM_EXEC,
> but for big-endian we should get upper word for this.
>
> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
> Cc: Guan Xuetao<gxt@mprc.pku.edu.cn>
> ---
>   arch/unicore32/kernel/asm-offsets.c |    6 +++++-
>   arch/unicore32/mm/fault.c           |    2 +-
>   2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/arch/unicore32/kernel/asm-offsets.c b/arch/unicore32/kernel/asm-offsets.c
> index ffcbe75..e3199b5 100644
> --- a/arch/unicore32/kernel/asm-offsets.c
> +++ b/arch/unicore32/kernel/asm-offsets.c
> @@ -87,9 +87,13 @@ int main(void)
>   	DEFINE(S_FRAME_SIZE,	sizeof(struct pt_regs));
>   	BLANK();
>   	DEFINE(VMA_VM_MM,	offsetof(struct vm_area_struct, vm_mm));
> +#if defined(CONFIG_CPU_BIG_ENDIAN)&&  (NR_VMA_FLAGS>  32)
> +	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags) + 4);
> +#else
CONFIG_CPU_BIG/LITTLE_ENDIAN is defined only in some archs, and not 
supported by unicore32.

>   	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags));
> +#endif
>   	BLANK();
> -	DEFINE(VM_EXEC,		VM_EXEC);
> +	DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);
Is this check useful for asm-offsets.h?

>   	BLANK();
>   	DEFINE(PAGE_SZ,		PAGE_SIZE);
>   	BLANK();
> diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
> index 283aa4b..9137996 100644
> --- a/arch/unicore32/mm/fault.c
> +++ b/arch/unicore32/mm/fault.c
> @@ -158,7 +158,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
>    */
>   static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
>   {
> -	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
> +	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;

I am confused  for the type of vm_flags in vm_area_struct being 
'unsigned long',  not vm_flags_t.

Regards,

Guan Xuetao

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 08/16] mm/unicore32: use vm_flags_t for vma flags
  2012-03-27  3:38     ` Guan Xuetao
@ 2012-03-27  5:58       ` Konstantin Khlebnikov
  -1 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-27  5:58 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: Andrew Morton, linux-mm, linux-kernel

Guan Xuetao wrote:
> On 03/21/2012 02:56 PM, Konstantin Khlebnikov wrote:
>> The same magic like in arm: assembler code wants to test VM_EXEC,
>> but for big-endian we should get upper word for this.
>>
>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>> Cc: Guan Xuetao<gxt@mprc.pku.edu.cn>
>> ---
>>    arch/unicore32/kernel/asm-offsets.c |    6 +++++-
>>    arch/unicore32/mm/fault.c           |    2 +-
>>    2 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/unicore32/kernel/asm-offsets.c b/arch/unicore32/kernel/asm-offsets.c
>> index ffcbe75..e3199b5 100644
>> --- a/arch/unicore32/kernel/asm-offsets.c
>> +++ b/arch/unicore32/kernel/asm-offsets.c
>> @@ -87,9 +87,13 @@ int main(void)
>>    	DEFINE(S_FRAME_SIZE,	sizeof(struct pt_regs));
>>    	BLANK();
>>    	DEFINE(VMA_VM_MM,	offsetof(struct vm_area_struct, vm_mm));
>> +#if defined(CONFIG_CPU_BIG_ENDIAN)&&   (NR_VMA_FLAGS>   32)
>> +	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags) + 4);
>> +#else
> CONFIG_CPU_BIG/LITTLE_ENDIAN is defined only in some archs, and not
> supported by unicore32.

Ok, I'll drop this in v2

>
>>    	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags));
>> +#endif
>>    	BLANK();
>> -	DEFINE(VM_EXEC,		VM_EXEC);
>> +	DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);

> Is this check useful for asm-offsets.h?

this forced-typecast to make sparse happy, because  we use here only (int) part of vma->vm_flags.

>
>>    	BLANK();
>>    	DEFINE(PAGE_SZ,		PAGE_SIZE);
>>    	BLANK();
>> diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
>> index 283aa4b..9137996 100644
>> --- a/arch/unicore32/mm/fault.c
>> +++ b/arch/unicore32/mm/fault.c
>> @@ -158,7 +158,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
>>     */
>>    static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
>>    {
>> -	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
>> +	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
>
> I am confused  for the type of vm_flags in vm_area_struct being
> 'unsigned long',  not vm_flags_t.

Second patch in this patchset changes it.
vm_flags_t will be unsigned long or or unsigned long long depending on vma flags count.
But more likely it will be unsigned int, because I have another patchset in work,
which currently drop four bits in vm_flags, so we can postpone its expansion.

>
> Regards,
>
> Guan Xuetao
>
> --
> 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/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email:<a href=mailto:"dont@kvack.org">  email@kvack.org</a>


^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 08/16] mm/unicore32: use vm_flags_t for vma flags
@ 2012-03-27  5:58       ` Konstantin Khlebnikov
  0 siblings, 0 replies; 104+ messages in thread
From: Konstantin Khlebnikov @ 2012-03-27  5:58 UTC (permalink / raw)
  To: Guan Xuetao; +Cc: Andrew Morton, linux-mm, linux-kernel

Guan Xuetao wrote:
> On 03/21/2012 02:56 PM, Konstantin Khlebnikov wrote:
>> The same magic like in arm: assembler code wants to test VM_EXEC,
>> but for big-endian we should get upper word for this.
>>
>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>> Cc: Guan Xuetao<gxt@mprc.pku.edu.cn>
>> ---
>>    arch/unicore32/kernel/asm-offsets.c |    6 +++++-
>>    arch/unicore32/mm/fault.c           |    2 +-
>>    2 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/unicore32/kernel/asm-offsets.c b/arch/unicore32/kernel/asm-offsets.c
>> index ffcbe75..e3199b5 100644
>> --- a/arch/unicore32/kernel/asm-offsets.c
>> +++ b/arch/unicore32/kernel/asm-offsets.c
>> @@ -87,9 +87,13 @@ int main(void)
>>    	DEFINE(S_FRAME_SIZE,	sizeof(struct pt_regs));
>>    	BLANK();
>>    	DEFINE(VMA_VM_MM,	offsetof(struct vm_area_struct, vm_mm));
>> +#if defined(CONFIG_CPU_BIG_ENDIAN)&&   (NR_VMA_FLAGS>   32)
>> +	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags) + 4);
>> +#else
> CONFIG_CPU_BIG/LITTLE_ENDIAN is defined only in some archs, and not
> supported by unicore32.

Ok, I'll drop this in v2

>
>>    	DEFINE(VMA_VM_FLAGS,	offsetof(struct vm_area_struct, vm_flags));
>> +#endif
>>    	BLANK();
>> -	DEFINE(VM_EXEC,		VM_EXEC);
>> +	DEFINE(VM_EXEC,		(__force unsigned int)VM_EXEC);

> Is this check useful for asm-offsets.h?

this forced-typecast to make sparse happy, because  we use here only (int) part of vma->vm_flags.

>
>>    	BLANK();
>>    	DEFINE(PAGE_SZ,		PAGE_SIZE);
>>    	BLANK();
>> diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
>> index 283aa4b..9137996 100644
>> --- a/arch/unicore32/mm/fault.c
>> +++ b/arch/unicore32/mm/fault.c
>> @@ -158,7 +158,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
>>     */
>>    static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
>>    {
>> -	unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
>> +	vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
>
> I am confused  for the type of vm_flags in vm_area_struct being
> 'unsigned long',  not vm_flags_t.

Second patch in this patchset changes it.
vm_flags_t will be unsigned long or or unsigned long long depending on vma flags count.
But more likely it will be unsigned int, because I have another patchset in work,
which currently drop four bits in vm_flags, so we can postpone its expansion.

>
> Regards,
>
> Guan Xuetao
>
> --
> 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/ .
> Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
> Don't email:<a href=mailto:"dont@kvack.org">  email@kvack.org</a>

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 08/16] mm/unicore32: use vm_flags_t for vma flags
  2012-03-27  5:58       ` Konstantin Khlebnikov
@ 2012-03-27  7:50         ` Guan Xuetao
  -1 siblings, 0 replies; 104+ messages in thread
From: Guan Xuetao @ 2012-03-27  7:50 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: Andrew Morton, linux-mm, linux-kernel

On 03/27/2012 01:58 PM, Konstantin Khlebnikov wrote:
> Guan Xuetao wrote:
>> On 03/21/2012 02:56 PM, Konstantin Khlebnikov wrote:
>>> The same magic like in arm: assembler code wants to test VM_EXEC,
>>> but for big-endian we should get upper word for this.
>>>
>>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>>> Cc: Guan Xuetao<gxt@mprc.pku.edu.cn>
>>> ---
>>>    arch/unicore32/kernel/asm-offsets.c |    6 +++++-
>>>    arch/unicore32/mm/fault.c           |    2 +-
>>>    2 files changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/unicore32/kernel/asm-offsets.c 
>>> b/arch/unicore32/kernel/asm-offsets.c
>>> index ffcbe75..e3199b5 100644
>>> --- a/arch/unicore32/kernel/asm-offsets.c
>>> +++ b/arch/unicore32/kernel/asm-offsets.c
>>> @@ -87,9 +87,13 @@ int main(void)
>>>        DEFINE(S_FRAME_SIZE,    sizeof(struct pt_regs));
>>>        BLANK();
>>>        DEFINE(VMA_VM_MM,    offsetof(struct vm_area_struct, vm_mm));
>>> +#if defined(CONFIG_CPU_BIG_ENDIAN)&&   (NR_VMA_FLAGS>   32)
>>> +    DEFINE(VMA_VM_FLAGS,    offsetof(struct vm_area_struct, 
>>> vm_flags) + 4);
>>> +#else
>> CONFIG_CPU_BIG/LITTLE_ENDIAN is defined only in some archs, and not
>> supported by unicore32.
>
> Ok, I'll drop this in v2
>
>>
>>>        DEFINE(VMA_VM_FLAGS,    offsetof(struct vm_area_struct, 
>>> vm_flags));
>>> +#endif
>>>        BLANK();
>>> -    DEFINE(VM_EXEC,        VM_EXEC);
>>> +    DEFINE(VM_EXEC,        (__force unsigned int)VM_EXEC);
>
>> Is this check useful for asm-offsets.h?
>
> this forced-typecast to make sparse happy, because  we use here only 
> (int) part of vma->vm_flags.
Perhaps,  vm_flags_t,  not unsigned int is more proper.

>
>>
>>>        BLANK();
>>>        DEFINE(PAGE_SZ,        PAGE_SIZE);
>>>        BLANK();
>>> diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
>>> index 283aa4b..9137996 100644
>>> --- a/arch/unicore32/mm/fault.c
>>> +++ b/arch/unicore32/mm/fault.c
>>> @@ -158,7 +158,7 @@ void do_bad_area(unsigned long addr, unsigned 
>>> int fsr, struct pt_regs *regs)
>>>     */
>>>    static inline bool access_error(unsigned int fsr, struct 
>>> vm_area_struct *vma)
>>>    {
>>> -    unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
>>> +    vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
>>
>> I am confused  for the type of vm_flags in vm_area_struct being
>> 'unsigned long',  not vm_flags_t.
>
> Second patch in this patchset changes it.
> vm_flags_t will be unsigned long or or unsigned long long depending on 
> vma flags count.
> But more likely it will be unsigned int, because I have another 
> patchset in work,
> which currently drop four bits in vm_flags, so we can postpone its 
> expansion.
I see. Thanks for your explanation.

Regards,
Guan Xuetao


^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 08/16] mm/unicore32: use vm_flags_t for vma flags
@ 2012-03-27  7:50         ` Guan Xuetao
  0 siblings, 0 replies; 104+ messages in thread
From: Guan Xuetao @ 2012-03-27  7:50 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: Andrew Morton, linux-mm, linux-kernel

On 03/27/2012 01:58 PM, Konstantin Khlebnikov wrote:
> Guan Xuetao wrote:
>> On 03/21/2012 02:56 PM, Konstantin Khlebnikov wrote:
>>> The same magic like in arm: assembler code wants to test VM_EXEC,
>>> but for big-endian we should get upper word for this.
>>>
>>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>>> Cc: Guan Xuetao<gxt@mprc.pku.edu.cn>
>>> ---
>>>    arch/unicore32/kernel/asm-offsets.c |    6 +++++-
>>>    arch/unicore32/mm/fault.c           |    2 +-
>>>    2 files changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/arch/unicore32/kernel/asm-offsets.c 
>>> b/arch/unicore32/kernel/asm-offsets.c
>>> index ffcbe75..e3199b5 100644
>>> --- a/arch/unicore32/kernel/asm-offsets.c
>>> +++ b/arch/unicore32/kernel/asm-offsets.c
>>> @@ -87,9 +87,13 @@ int main(void)
>>>        DEFINE(S_FRAME_SIZE,    sizeof(struct pt_regs));
>>>        BLANK();
>>>        DEFINE(VMA_VM_MM,    offsetof(struct vm_area_struct, vm_mm));
>>> +#if defined(CONFIG_CPU_BIG_ENDIAN)&&   (NR_VMA_FLAGS>   32)
>>> +    DEFINE(VMA_VM_FLAGS,    offsetof(struct vm_area_struct, 
>>> vm_flags) + 4);
>>> +#else
>> CONFIG_CPU_BIG/LITTLE_ENDIAN is defined only in some archs, and not
>> supported by unicore32.
>
> Ok, I'll drop this in v2
>
>>
>>>        DEFINE(VMA_VM_FLAGS,    offsetof(struct vm_area_struct, 
>>> vm_flags));
>>> +#endif
>>>        BLANK();
>>> -    DEFINE(VM_EXEC,        VM_EXEC);
>>> +    DEFINE(VM_EXEC,        (__force unsigned int)VM_EXEC);
>
>> Is this check useful for asm-offsets.h?
>
> this forced-typecast to make sparse happy, because  we use here only 
> (int) part of vma->vm_flags.
Perhaps,  vm_flags_t,  not unsigned int is more proper.

>
>>
>>>        BLANK();
>>>        DEFINE(PAGE_SZ,        PAGE_SIZE);
>>>        BLANK();
>>> diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
>>> index 283aa4b..9137996 100644
>>> --- a/arch/unicore32/mm/fault.c
>>> +++ b/arch/unicore32/mm/fault.c
>>> @@ -158,7 +158,7 @@ void do_bad_area(unsigned long addr, unsigned 
>>> int fsr, struct pt_regs *regs)
>>>     */
>>>    static inline bool access_error(unsigned int fsr, struct 
>>> vm_area_struct *vma)
>>>    {
>>> -    unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
>>> +    vm_flags_t mask = VM_READ | VM_WRITE | VM_EXEC;
>>
>> I am confused  for the type of vm_flags in vm_area_struct being
>> 'unsigned long',  not vm_flags_t.
>
> Second patch in this patchset changes it.
> vm_flags_t will be unsigned long or or unsigned long long depending on 
> vma flags count.
> But more likely it will be unsigned int, because I have another 
> patchset in work,
> which currently drop four bits in vm_flags, so we can postpone its 
> expansion.
I see. Thanks for your explanation.

Regards,
Guan Xuetao

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
  2012-03-23 16:19           ` KOSAKI Motohiro
@ 2012-03-30  2:19             ` Al Viro
  -1 siblings, 0 replies; 104+ messages in thread
From: Al Viro @ 2012-03-30  2:19 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: akpm, khlebnikov, minchan, linux-mm, linux-kernel, torvalds,
	hughd, benh, linux

On Fri, Mar 23, 2012 at 12:19:36PM -0400, KOSAKI Motohiro wrote:
> On 3/22/2012 5:28 PM, Al Viro wrote:
> > On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
> >> It would be nice to find some way of triggering compiler warnings or
> >> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
> >> thoughts on this?
> >>
> >> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
> >> describe it)
> > 
> > Use __bitwise for that - check how gfp_t is handled.
> 
> Hmm..
> 
> If now we activate __bitwise, really plenty driver start create lots warnings.
> Does it make sense?

Huh?  Why would they?  Just adjust definitions of VM_... to include
force-cast to vm_flags_t and we should be OK...

> In fact, x86-32 keep 32bit vma_t forever. thus all x86 specific driver don't
> need any change. Moreover many ancient drivers has no maintainer and I can't
> expect such driver will be fixed even though a warning occur.

What warning?  If something does manual vma->vm_flags = 0xwhatever, then yes,
we do want it dealt with.  If it's vma->vm_flags |= VM_something, there should
be no warnings at all...

^ permalink raw reply	[flat|nested] 104+ messages in thread

* Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit
@ 2012-03-30  2:19             ` Al Viro
  0 siblings, 0 replies; 104+ messages in thread
From: Al Viro @ 2012-03-30  2:19 UTC (permalink / raw)
  To: KOSAKI Motohiro
  Cc: akpm, khlebnikov, minchan, linux-mm, linux-kernel, torvalds,
	hughd, benh, linux

On Fri, Mar 23, 2012 at 12:19:36PM -0400, KOSAKI Motohiro wrote:
> On 3/22/2012 5:28 PM, Al Viro wrote:
> > On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
> >> It would be nice to find some way of triggering compiler warnings or
> >> sparse warnings if someone mixes a 32-bit type with a vm_flags_t.  Any
> >> thoughts on this?
> >>
> >> (Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
> >> describe it)
> > 
> > Use __bitwise for that - check how gfp_t is handled.
> 
> Hmm..
> 
> If now we activate __bitwise, really plenty driver start create lots warnings.
> Does it make sense?

Huh?  Why would they?  Just adjust definitions of VM_... to include
force-cast to vm_flags_t and we should be OK...

> In fact, x86-32 keep 32bit vma_t forever. thus all x86 specific driver don't
> need any change. Moreover many ancient drivers has no maintainer and I can't
> expect such driver will be fixed even though a warning occur.

What warning?  If something does manual vma->vm_flags = 0xwhatever, then yes,
we do want it dealt with.  If it's vma->vm_flags |= VM_something, there should
be no warnings at all...

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 104+ messages in thread

end of thread, other threads:[~2012-03-30  2:20 UTC | newest]

Thread overview: 104+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-21  6:56 [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit Konstantin Khlebnikov
2012-03-21  6:56 ` Konstantin Khlebnikov
2012-03-21  6:56 ` [PATCH 01/16] mm: introduce NR_VMA_FLAGS Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:56 ` [PATCH 02/16] mm: use vm_flags_t for vma flags Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:56 ` [PATCH 03/16] mm/shmem: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:56 ` [PATCH 04/16] mm/nommu: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  7:08   ` Greg Ungerer
2012-03-21  7:08     ` Greg Ungerer
2012-03-21  7:20     ` Konstantin Khlebnikov
2012-03-21  7:20       ` Konstantin Khlebnikov
2012-03-21 12:01   ` [PATCH v2 " Konstantin Khlebnikov
2012-03-21 12:01     ` Konstantin Khlebnikov
2012-03-23  6:47     ` Greg Ungerer
2012-03-23  6:47       ` Greg Ungerer
2012-03-21  6:56 ` [PATCH 05/16] mm/drivers: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21 10:34   ` Laurent Pinchart
2012-03-21 10:34     ` Laurent Pinchart
2012-03-21 14:46   ` Greg Kroah-Hartman
2012-03-21 14:46     ` Greg Kroah-Hartman
2012-03-21  6:56 ` [PATCH 06/16] mm/x86: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:57   ` H. Peter Anvin
2012-03-21  6:57     ` H. Peter Anvin
2012-03-21  6:56 ` [PATCH 07/16] mm/arm: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-22 21:21   ` Andrew Morton
2012-03-22 21:21     ` Andrew Morton
2012-03-22 21:21     ` Andrew Morton
2012-03-21  6:56 ` [PATCH 08/16] mm/unicore32: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-27  3:38   ` Guan Xuetao
2012-03-27  3:38     ` Guan Xuetao
2012-03-27  5:58     ` Konstantin Khlebnikov
2012-03-27  5:58       ` Konstantin Khlebnikov
2012-03-27  7:50       ` Guan Xuetao
2012-03-27  7:50         ` Guan Xuetao
2012-03-21  6:56 ` [PATCH 09/16] mm/ia64: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:56 ` [PATCH 10/16] mm/powerpc: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:56 ` [PATCH 11/16] mm/s390: " Konstantin Khlebnikov
2012-03-21  6:56   ` Konstantin Khlebnikov
2012-03-21  6:57 ` [PATCH 12/16] mm/mips: " Konstantin Khlebnikov
2012-03-21  6:57   ` Konstantin Khlebnikov
2012-03-21  6:57 ` [PATCH 13/16] mm/parisc: " Konstantin Khlebnikov
2012-03-21  6:57   ` Konstantin Khlebnikov
2012-03-21  6:57 ` [PATCH 14/16] mm/score: " Konstantin Khlebnikov
2012-03-21  6:57   ` Konstantin Khlebnikov
2012-03-21  6:57 ` [PATCH 15/16] mm: cast vm_flags_t to u64 before printing Konstantin Khlebnikov
2012-03-21  6:57   ` Konstantin Khlebnikov
2012-03-21  6:57 ` [PATCH 16/16] mm: vm_flags_t strict type checking Konstantin Khlebnikov
2012-03-21  6:57   ` Konstantin Khlebnikov
2012-03-21 12:11   ` [PATCH v2 " Konstantin Khlebnikov
2012-03-21 12:11     ` Konstantin Khlebnikov
2012-03-21 10:06 ` [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit Minchan Kim
2012-03-21 10:06   ` Minchan Kim
2012-03-21 13:16   ` Konstantin Khlebnikov
2012-03-21 13:16     ` Konstantin Khlebnikov
2012-03-22  5:39     ` Minchan Kim
2012-03-22  5:39       ` Minchan Kim
2012-03-22  6:22       ` Benjamin Herrenschmidt
2012-03-22  6:22         ` Benjamin Herrenschmidt
2012-03-24 14:46         ` Konstantin Khlebnikov
2012-03-24 14:46           ` Konstantin Khlebnikov
2012-03-24 15:00           ` Konstantin Khlebnikov
2012-03-24 15:00             ` Konstantin Khlebnikov
2012-03-24 23:50           ` Benjamin Herrenschmidt
2012-03-24 23:50             ` Benjamin Herrenschmidt
2012-03-25  7:55             ` Konstantin Khlebnikov
2012-03-25  7:55               ` Konstantin Khlebnikov
2012-03-22 21:26     ` Andrew Morton
2012-03-22 21:26       ` Andrew Morton
2012-03-22 21:28       ` Al Viro
2012-03-22 21:28         ` Al Viro
2012-03-22 21:41         ` Andrew Morton
2012-03-22 21:41           ` Andrew Morton
2012-03-22 21:57           ` Al Viro
2012-03-22 21:57             ` Al Viro
2012-03-22 22:05           ` Konstantin Khlebnikov
2012-03-22 22:05             ` Konstantin Khlebnikov
2012-03-22 22:24             ` Konstantin Khlebnikov
2012-03-22 22:24               ` Konstantin Khlebnikov
2012-03-22 22:39               ` Linus Torvalds
2012-03-22 22:39                 ` Linus Torvalds
2012-03-22 22:52                 ` Konstantin Khlebnikov
2012-03-22 22:52                   ` Konstantin Khlebnikov
2012-03-22 23:09                   ` Andrew Morton
2012-03-22 23:09                     ` Andrew Morton
2012-03-23  1:42                     ` Al Viro
2012-03-23  1:42                       ` Al Viro
2012-03-22 22:08           ` Linus Torvalds
2012-03-22 22:08             ` Linus Torvalds
2012-03-23 16:19         ` KOSAKI Motohiro
2012-03-23 16:19           ` KOSAKI Motohiro
2012-03-30  2:19           ` Al Viro
2012-03-30  2:19             ` Al Viro

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.