kernel - SWAP CACHE part 13/many - More vm_pindex_t work for vm_objects on i386
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 6 Feb 2010 19:26:39 +0000 (11:26 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 6 Feb 2010 19:26:39 +0000 (11:26 -0800)
* vm_object->size also needs to be a vm_pindex_t, e.g. when mmap()ing regular
  HAMMER files or block devices or HAMMER's own use of block devices,
  in order to support vm_object operations past the 16TB mark.

* Introduce a 64-bit-friendly trunc_page64() and round_page64(), just to
  make sure we don't cut off page alignment operations on 64-bit offsets.

sys/sys/param.h
sys/vm/default_pager.c
sys/vm/device_pager.c
sys/vm/phys_pager.c
sys/vm/swap_pager.c
sys/vm/swap_pager.h
sys/vm/vm_object.c
sys/vm/vm_object.h
sys/vm/vm_page.c
sys/vm/vnode_pager.c

index 523be29..bad9045 100644 (file)
 #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
 #define powerof2(x)    ((((x)-1)&(x))==0)
 
+/*
+ * VM objects can be larger than the virtual address space, make sure
+ * we don't cut-off the mask.
+ */
+#define trunc_page64(x)           ((x) & ~(int64_t)PAGE_MASK)
+#define round_page64(x)           (((x) + PAGE_MASK) & ~(int64_t)PAGE_MASK)
+
 /* Macros for min/max. */
 #define MIN(a,b) (((a)<(b))?(a):(b))
 #define MAX(a,b) (((a)>(b))?(a):(b))
index a1a6ac4..b8222e6 100644 (file)
@@ -72,10 +72,14 @@ struct pagerops defaultpagerops = {
 static vm_object_t
 default_pager_alloc(void *handle, off_t size, vm_prot_t prot, off_t offset)
 {
+       vm_object_t object;
+
        if (handle != NULL)
                panic("default_pager_alloc: handle specified");
 
-       return vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(round_page(offset + size)));
+       object = vm_object_allocate(OBJT_DEFAULT,
+                                   OFF_TO_IDX(round_page64(offset + size)));
+       return (object);
 }
 
 /*
index 167f550..12dff3a 100644 (file)
@@ -100,7 +100,7 @@ dev_pager_alloc(void *handle, off_t size, vm_prot_t prot, off_t foff)
        if (foff & PAGE_MASK)
                return (NULL);
 
-       size = round_page(size);
+       size = round_page64(size);
 
        /*
         * Check that the specified range of the device allows the desired
index 1129567..5df8f63 100644 (file)
@@ -52,7 +52,7 @@ phys_pager_alloc(void *handle, off_t size, vm_prot_t prot, off_t foff)
        if (foff & PAGE_MASK)
                return (NULL);
 
-       size = round_page(size);
+       size = round_page64(size);
 
        KKASSERT(handle == NULL);
 #if 0
index e7c0e24..8afbf57 100644 (file)
@@ -604,7 +604,7 @@ swap_pager_freespace_all(vm_object_t object)
 static int swap_pager_condfree_callback(struct swblock *swap, void *data);
 
 int
-swap_pager_condfree(vm_object_t object, vm_size_t *basei, int count)
+swap_pager_condfree(vm_object_t object, vm_pindex_t *basei, int count)
 {
        struct swfreeinfo info;
 
index 3a995a0..a50f4b9 100644 (file)
@@ -101,7 +101,7 @@ int swap_pager_swp_alloc (vm_object_t, int);
 void swap_pager_copy (vm_object_t, vm_object_t, vm_pindex_t, int);
 void swap_pager_freespace (vm_object_t, vm_pindex_t, vm_pindex_t);
 void swap_pager_freespace_all (vm_object_t);
-int swap_pager_condfree(vm_object_t, vm_size_t *, int);
+int swap_pager_condfree(vm_object_t, vm_pindex_t *, int);
 
 void swap_pager_page_inserted(vm_page_t);
 void swap_pager_swap_init (void);
index 4ae7fb3..e18b55f 100644 (file)
@@ -140,7 +140,7 @@ static int object_hash_rand;
 static struct vm_object vm_objects_init[VM_OBJECTS_INIT];
 
 void
-_vm_object_allocate(objtype_t type, vm_size_t size, vm_object_t object)
+_vm_object_allocate(objtype_t type, vm_pindex_t size, vm_object_t object)
 {
        int incr;
        RB_INIT(&object->rb_memq);
@@ -214,7 +214,7 @@ vm_object_init2(void)
  */
 
 vm_object_t
-vm_object_allocate(objtype_t type, vm_size_t size)
+vm_object_allocate(objtype_t type, vm_pindex_t size)
 {
        vm_object_t result;
 
index e5deda1..4f29436 100644 (file)
@@ -145,7 +145,7 @@ struct vm_object {
        LIST_ENTRY(vm_object) shadow_list; /* chain of shadow objects */
        RB_HEAD(vm_page_rb_tree, vm_page) rb_memq;      /* resident pages */
        int generation;                 /* generation ID */
-       vm_size_t size;                 /* Object size */
+       vm_pindex_t size;               /* Object size */
        int ref_count;                  /* How many refs?? */
        int shadow_count;               /* how many objects that this is a shadow for */
        int hash_rand;                  /* vm hash table randomizer     */
@@ -278,8 +278,8 @@ vm_object_pip_wait(vm_object_t object, char *waitid)
                vm_object_pip_sleep(object, waitid);
 }
 
-vm_object_t vm_object_allocate (objtype_t, vm_size_t);
-void _vm_object_allocate (objtype_t, vm_size_t, vm_object_t);
+vm_object_t vm_object_allocate (objtype_t, vm_pindex_t);
+void _vm_object_allocate (objtype_t, vm_pindex_t, vm_object_t);
 boolean_t vm_object_coalesce (vm_object_t, vm_pindex_t, vm_size_t, vm_size_t);
 void vm_object_collapse (vm_object_t);
 void vm_object_deallocate (vm_object_t);
index cf7652c..fcb2d49 100644 (file)
@@ -218,8 +218,8 @@ vm_page_startup(vm_offset_t vaddr)
        vaddr = round_page(vaddr);
 
        for (i = 0; phys_avail[i + 1]; i += 2) {
-               phys_avail[i] = round_page(phys_avail[i]);
-               phys_avail[i + 1] = trunc_page(phys_avail[i + 1]);
+               phys_avail[i] = round_page64(phys_avail[i]);
+               phys_avail[i + 1] = trunc_page64(phys_avail[i + 1]);
        }
 
        for (i = 0; phys_avail[i + 1]; i += 2) {
index 749f40c..2aabc9f 100644 (file)
@@ -145,7 +145,7 @@ vnode_pager_alloc(void *handle, off_t size, vm_prot_t prot, off_t offset)
                 * And an object of the appropriate size
                 */
                object = vm_object_allocate(OBJT_VNODE,
-                                           OFF_TO_IDX(round_page(size)));
+                                           OFF_TO_IDX(round_page64(size)));
                object->flags = 0;
                object->handle = handle;
                vp->v_object = object;