#define VM_GROWSDOWN   0x00000100      /* general info on the segment */
 #define VM_GROWSUP     0x00000200
-#define VM_SHM         0x00000400      /* shared memory area, don't swap out */
+#define VM_SHM         0x00000000      /* Means nothing: delete it later */
+#define VM_UNPAGED     0x00000400      /* Pages managed without map count */
 #define VM_DENYWRITE   0x00000800      /* ETXTBSY on write attempts.. */
 
 #define VM_EXECUTABLE  0x00001000
 
 #define VM_DONTCOPY    0x00020000      /* Do not copy this vma on fork */
 #define VM_DONTEXPAND  0x00040000      /* Cannot expand with mremap() */
-#define VM_RESERVED    0x00080000      /* Pages managed in a special way */
+#define VM_RESERVED    0x00080000      /* Count as reserved_vm like IO */
 #define VM_ACCOUNT     0x00100000      /* Is a VM accounted object */
 #define VM_HUGETLB     0x00400000      /* Huge TLB Page VM */
 #define VM_NONLINEAR   0x00800000      /* Is non-linear (remap_file_pages) */
 
 
 /*
  * This function is called to print an error when a pte in a
- * !VM_RESERVED region is found pointing to an invalid pfn (which
+ * !VM_UNPAGED region is found pointing to an invalid pfn (which
  * is an error.
  *
  * The calling function must still handle the error.
                goto out_set_pte;
        }
 
-       /* If the region is VM_RESERVED, the mapping is not
+       /* If the region is VM_UNPAGED, the mapping is not
         * mapped via rmap - duplicate the pte as is.
         */
-       if (vm_flags & VM_RESERVED)
+       if (vm_flags & VM_UNPAGED)
                goto out_set_pte;
 
        pfn = pte_pfn(pte);
        /* If the pte points outside of valid memory but
-        * the region is not VM_RESERVED, we have a problem.
+        * the region is not VM_UNPAGED, we have a problem.
         */
        if (unlikely(!pfn_valid(pfn))) {
                print_bad_pte(vma, pte, addr);
         * readonly mappings. The tradeoff is that copy_page_range is more
         * efficient than faulting.
         */
-       if (!(vma->vm_flags & (VM_HUGETLB|VM_NONLINEAR|VM_RESERVED))) {
+       if (!(vma->vm_flags & (VM_HUGETLB|VM_NONLINEAR|VM_UNPAGED))) {
                if (!vma->anon_vma)
                        return 0;
        }
 
                        (*zap_work) -= PAGE_SIZE;
 
-                       if (!(vma->vm_flags & VM_RESERVED)) {
+                       if (!(vma->vm_flags & VM_UNPAGED)) {
                                unsigned long pfn = pte_pfn(ptent);
                                if (unlikely(!pfn_valid(pfn)))
                                        print_bad_pte(vma, ptent, addr);
         * rest of the world about it:
         *   VM_IO tells people not to look at these pages
         *      (accesses can have side effects).
-        *   VM_RESERVED tells the core MM not to "manage" these pages
-         *     (e.g. refcount, mapcount, try to swap them out).
+        *   VM_RESERVED is specified all over the place, because
+        *      in 2.4 it kept swapout's vma scan off this vma; but
+        *      in 2.6 the LRU scan won't even find its pages, so this
+        *      flag means no more than count its pages in reserved_vm,
+        *      and omit it from core dump, even when VM_IO turned off.
+        *   VM_UNPAGED tells the core MM not to "manage" these pages
+         *     (e.g. refcount, mapcount, try to swap them out): in
+        *      particular, zap_pte_range does not try to free them.
         */
-       vma->vm_flags |= VM_IO | VM_RESERVED;
+       vma->vm_flags |= VM_IO | VM_RESERVED | VM_UNPAGED;
 
        BUG_ON(addr >= end);
        pfn -= addr >> PAGE_SHIFT;
        pte_t entry;
        int ret = VM_FAULT_MINOR;
 
-       BUG_ON(vma->vm_flags & VM_RESERVED);
+       BUG_ON(vma->vm_flags & VM_UNPAGED);
 
        if (unlikely(!pfn_valid(pfn))) {
                /*
                        inc_mm_counter(mm, anon_rss);
                        lru_cache_add_active(new_page);
                        page_add_anon_rmap(new_page, vma, address);
-               } else if (!(vma->vm_flags & VM_RESERVED)) {
+               } else if (!(vma->vm_flags & VM_UNPAGED)) {
                        inc_mm_counter(mm, file_rss);
                        page_add_file_rmap(new_page);
                }
        gate_vma.vm_start = FIXADDR_USER_START;
        gate_vma.vm_end = FIXADDR_USER_END;
        gate_vma.vm_page_prot = PAGE_READONLY;
-       gate_vma.vm_flags = VM_RESERVED;
+       gate_vma.vm_flags = 0;
        return 0;
 }
 __initcall(gate_vma_init);