am_maxslot represents the total number of slots an amap can be extended
to. Since we do not extend amaps, this field as well as rounding the
number of slots to the next malloc bucket is not useful.

This also removes the corresponding output from procmap(1).

ok?

Index: sys/uvm/uvm_amap.c
===================================================================
RCS file: /cvs/src/sys/uvm/uvm_amap.c,v
retrieving revision 1.65
diff -u -p -r1.65 uvm_amap.c
--- sys/uvm/uvm_amap.c  12 Apr 2016 16:47:33 -0000      1.65
+++ sys/uvm/uvm_amap.c  16 Apr 2016 14:29:55 -0000
@@ -180,44 +180,37 @@ static inline struct vm_amap *
 amap_alloc1(int slots, int waitf)
 {
        struct vm_amap *amap;
-       int totalslots;
 
        amap = pool_get(&uvm_amap_pool, (waitf == M_WAITOK) ? PR_WAITOK
            : PR_NOWAIT);
        if (amap == NULL)
                return(NULL);
 
-       totalslots = slots;
-       KASSERT(totalslots > 0);
-
-       if (totalslots > UVM_AMAP_CHUNK)
-               totalslots = malloc_roundup(totalslots * MALLOC_SLOT_UNIT) /
-                   MALLOC_SLOT_UNIT;
+       KASSERT(slots > 0);
 
        amap->am_ref = 1;
        amap->am_flags = 0;
 #ifdef UVM_AMAP_PPREF
        amap->am_ppref = NULL;
 #endif
-       amap->am_maxslot = totalslots;
        amap->am_nslot = slots;
        amap->am_nused = 0;
 
-       if (totalslots > UVM_AMAP_CHUNK)
-               amap->am_slots = malloc(totalslots * MALLOC_SLOT_UNIT,
+       if (slots > UVM_AMAP_CHUNK)
+               amap->am_slots = malloc(slots * MALLOC_SLOT_UNIT,
                    M_UVMAMAP, waitf);
        else
                amap->am_slots = pool_get(
-                   &uvm_amap_slot_pools[totalslots - 1],
+                   &uvm_amap_slot_pools[slots - 1],
                    (waitf == M_WAITOK) ? PR_WAITOK : PR_NOWAIT);
 
        if (amap->am_slots == NULL)
                goto fail1;
 
-       amap->am_bckptr = (int *)(((char *)amap->am_slots) + totalslots *
+       amap->am_bckptr = (int *)(((char *)amap->am_slots) + slots *
            sizeof(int));
        amap->am_anon = (struct vm_anon **)(((char *)amap->am_bckptr) +
-           totalslots * sizeof(int));
+           slots * sizeof(int));
 
        return(amap);
 
@@ -243,7 +236,7 @@ amap_alloc(vaddr_t sz, int waitf)
        amap = amap_alloc1(slots, waitf);
        if (amap) {
                memset(amap->am_anon, 0,
-                   amap->am_maxslot * sizeof(struct vm_anon *));
+                   amap->am_nslot * sizeof(struct vm_anon *));
                amap_list_insert(amap);
        }
 
@@ -263,10 +256,10 @@ amap_free(struct vm_amap *amap)
        KASSERT(amap->am_ref == 0 && amap->am_nused == 0);
        KASSERT((amap->am_flags & AMAP_SWAPOFF) == 0);
 
-       if (amap->am_maxslot > UVM_AMAP_CHUNK)
+       if (amap->am_nslot > UVM_AMAP_CHUNK)
                free(amap->am_slots, M_UVMAMAP, 0);
        else
-               pool_put(&uvm_amap_slot_pools[amap->am_maxslot - 1],
+               pool_put(&uvm_amap_slot_pools[amap->am_nslot - 1],
                    amap->am_slots);
 
 #ifdef UVM_AMAP_PPREF
@@ -409,8 +402,7 @@ amap_copy(struct vm_map *map, struct vm_
                amap->am_slots[amap->am_nused] = lcv;
                amap->am_nused++;
        }
-       memset(&amap->am_anon[lcv], 0,
-           (amap->am_maxslot - lcv) * sizeof(struct vm_anon *));
+       KASSERT(lcv == amap->am_nslot);
 
        /*
         * drop our reference to the old amap (srcamap).
@@ -570,7 +562,7 @@ void
 amap_pp_establish(struct vm_amap *amap)
 {
 
-       amap->am_ppref = mallocarray(amap->am_maxslot, sizeof(int),
+       amap->am_ppref = mallocarray(amap->am_nslot, sizeof(int),
            M_UVMAMAP, M_NOWAIT|M_ZERO);
 
        /* if we fail then we just won't use ppref for this amap */
Index: sys/uvm/uvm_amap.h
===================================================================
RCS file: /cvs/src/sys/uvm/uvm_amap.h,v
retrieving revision 1.23
diff -u -p -r1.23 uvm_amap.h
--- sys/uvm/uvm_amap.h  4 Apr 2016 16:34:16 -0000       1.23
+++ sys/uvm/uvm_amap.h  16 Apr 2016 14:29:55 -0000
@@ -124,8 +124,7 @@ boolean_t   amap_swap_off(int, int);
 struct vm_amap {
        int am_ref;             /* reference count */
        int am_flags;           /* flags */
-       int am_maxslot;         /* max # of slots allocated */
-       int am_nslot;           /* # of slots currently in map ( <= maxslot) */
+       int am_nslot;           /* # of slots currently in map */
        int am_nused;           /* # of slots currently in use */
        int *am_slots;          /* contig array of active slots */
        int *am_bckptr;         /* back pointer array to am_slots */
Index: usr.sbin/procmap/procmap.c
===================================================================
RCS file: /cvs/src/usr.sbin/procmap/procmap.c,v
retrieving revision 1.59
diff -u -p -r1.59 procmap.c
--- usr.sbin/procmap/procmap.c  19 Jan 2015 19:25:28 -0000      1.59
+++ usr.sbin/procmap/procmap.c  16 Apr 2016 14:29:56 -0000
@@ -97,7 +97,6 @@ rlim_t maxssiz;
 
 struct sum {
        unsigned long s_am_nslots;
-       unsigned long s_am_maxslots;
        unsigned long s_am_nusedslots;
 };
 
@@ -347,12 +346,10 @@ void
 print_sum(struct sum *sum, struct sum *total_sum)
 {
        const char *t = total_sum == NULL ? "total " : "";
-       printf("%samap allocated slots: %lu\n", t, sum->s_am_maxslots);
        printf("%samap mapped slots: %lu\n", t, sum->s_am_nslots);
        printf("%samap used slots: %lu\n", t, sum->s_am_nusedslots);
 
        if (total_sum) {
-               total_sum->s_am_maxslots += sum->s_am_maxslots;
                total_sum->s_am_nslots += sum->s_am_nslots;
                total_sum->s_am_nusedslots += sum->s_am_nusedslots;
        }
@@ -785,15 +782,13 @@ dump_vm_map_entry(kvm_t *kd, struct kbit
        }
 
        if (print_amap && vme->aref.ar_amap) {
-               printf(" amap - ref: %d fl: 0x%x maxsl: %d nsl: %d nuse: %d\n",
+               printf(" amap - ref: %d fl: 0x%x nsl: %d nuse: %d\n",
                    D(amap, vm_amap)->am_ref,
                    D(amap, vm_amap)->am_flags,
-                   D(amap, vm_amap)->am_maxslot,
                    D(amap, vm_amap)->am_nslot,
                    D(amap, vm_amap)->am_nused);
                if (sum) {
                        sum->s_am_nslots += D(amap, vm_amap)->am_nslot;
-                       sum->s_am_maxslots += D(amap, vm_amap)->am_maxslot;
                        sum->s_am_nusedslots += D(amap, vm_amap)->am_nused;
                }
        }

Reply via email to