> Date: Sun, 3 Apr 2016 16:11:40 +0200
> From: Stefan Kempf <sisnk...@gmail.com>
> 
> This flag caused amaps to be allocated with additional spare slots, to
> make extending them cheaper. However, the kernel never extends amaps,
> so allocating spare slots is pointless. Also UVM_FLAG_AMAPPAD only
> has an effect in combination with UVM_FLAG_OVERLAY. The only function
> that used both flags was sys_obreak, but that function had the use of
> UVM_FLAG_OVERLAY removed recently.
> 
> While there, kill the unused prototypes amap_flags and amap_refs.
> They're defined as macros already.
> 
> ok?

You're deleteing the wrong comments in the bit that deletes the
prototypes. Otherwise this is ok kettenis@

> Index: uvm/uvm_amap.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_amap.c,v
> retrieving revision 1.63
> diff -u -p -r1.63 uvm_amap.c
> --- uvm/uvm_amap.c    27 Mar 2016 09:51:37 -0000      1.63
> +++ uvm/uvm_amap.c    3 Apr 2016 14:00:29 -0000
> @@ -65,7 +65,7 @@ static char amap_slot_pool_names[UVM_AMA
>   * local functions
>   */
>  
> -static struct vm_amap *amap_alloc1(int, int, int);
> +static struct vm_amap *amap_alloc1(int, int);
>  static __inline void amap_list_insert(struct vm_amap *);
>  static __inline void amap_list_remove(struct vm_amap *);   
>  
> @@ -177,7 +177,7 @@ amap_init(void)
>   *   init the overlay.
>   */
>  static inline struct vm_amap *
> -amap_alloc1(int slots, int padslots, int waitf)
> +amap_alloc1(int slots, int waitf)
>  {
>       struct vm_amap *amap;
>       int totalslots;
> @@ -187,7 +187,7 @@ amap_alloc1(int slots, int padslots, int
>       if (amap == NULL)
>               return(NULL);
>  
> -     totalslots = slots + padslots;
> +     totalslots = slots;
>       KASSERT(totalslots > 0);
>  
>       if (totalslots > UVM_AMAP_CHUNK)
> @@ -233,15 +233,14 @@ fail1:
>   * => reference count to new amap is set to one
>   */
>  struct vm_amap *
> -amap_alloc(vaddr_t sz, vaddr_t padsz, int waitf)
> +amap_alloc(vaddr_t sz, int waitf)
>  {
>       struct vm_amap *amap;
> -     int slots, padslots;
> +     int slots;
>  
>       AMAP_B2SLOT(slots, sz);         /* load slots */
> -     AMAP_B2SLOT(padslots, padsz);
>  
> -     amap = amap_alloc1(slots, padslots, waitf);
> +     amap = amap_alloc1(slots, waitf);
>       if (amap) {
>               memset(amap->am_anon, 0,
>                   amap->am_maxslot * sizeof(struct vm_anon *));
> @@ -361,7 +360,7 @@ amap_copy(struct vm_map *map, struct vm_
>               }
>  
>               entry->aref.ar_pageoff = 0;
> -             entry->aref.ar_amap = amap_alloc(entry->end - entry->start, 0,
> +             entry->aref.ar_amap = amap_alloc(entry->end - entry->start,
>                   waitf);
>               if (entry->aref.ar_amap != NULL)
>                       entry->etype &= ~UVM_ET_NEEDSCOPY;
> @@ -381,7 +380,7 @@ amap_copy(struct vm_map *map, struct vm_
>  
>       /* looks like we need to copy the map. */
>       AMAP_B2SLOT(slots, entry->end - entry->start);
> -     amap = amap_alloc1(slots, 0, waitf);
> +     amap = amap_alloc1(slots, waitf);
>       if (amap == NULL)
>               return;
>       srcamap = entry->aref.ar_amap;
> Index: uvm/uvm_amap.h
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_amap.h,v
> retrieving revision 1.22
> diff -u -p -r1.22 uvm_amap.h
> --- uvm/uvm_amap.h    27 Mar 2016 09:51:37 -0000      1.22
> +++ uvm/uvm_amap.h    3 Apr 2016 14:00:29 -0000
> @@ -66,15 +66,13 @@ struct vm_amap;
>  void         amap_add(struct vm_aref *, vaddr_t, struct vm_anon *,
>                   boolean_t);
>                                       /* allocate a new amap */
> -struct vm_amap       *amap_alloc(vaddr_t, vaddr_t, int);
> +struct vm_amap       *amap_alloc(vaddr_t, int);
>                                       /* clear amap needs-copy flag */
>  void         amap_copy(vm_map_t, vm_map_entry_t, int, boolean_t, vaddr_t,
>                   vaddr_t);
>                                       /* resolve all COW faults now */
>  void         amap_cow_now(vm_map_t, vm_map_entry_t);
>                                       /* get amap's flags */
> -int          amap_flags(struct vm_amap *);
> -                                     /* free amap */
>  void         amap_free(struct vm_amap *);
>                                       /* init amap module (at boot time) */
>  void         amap_init(void);
> @@ -85,8 +83,6 @@ void                amap_lookups(struct vm_aref *, vad
>                                       /* add a reference to an amap */
>  void         amap_ref(struct vm_amap *, vaddr_t, vsize_t, int);
>                                       /* get number of references of amap */
> -int          amap_refs(struct vm_amap *);
> -                                     /* split reference to amap into two */
>  void         amap_splitref(struct vm_aref *, struct vm_aref *, vaddr_t);
>                                       /* remove an anon from an amap */
>  void         amap_unadd(struct vm_aref *, vaddr_t);
> Index: uvm/uvm_extern.h
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_extern.h,v
> retrieving revision 1.137
> diff -u -p -r1.137 uvm_extern.h
> --- uvm/uvm_extern.h  2 Dec 2015 09:50:46 -0000       1.137
> +++ uvm/uvm_extern.h  3 Apr 2016 14:00:29 -0000
> @@ -106,12 +106,11 @@ typedef int             vm_prot_t;
>  #define UVM_FLAG_OVERLAY 0x0020000 /* establish overlay */
>  #define UVM_FLAG_NOMERGE 0x0040000 /* don't merge map entries */
>  #define UVM_FLAG_COPYONW 0x0080000 /* set copy_on_write flag */
> -#define UVM_FLAG_AMAPPAD 0x0100000 /* for bss: pad amap to reduce malloc() */
> -#define UVM_FLAG_TRYLOCK 0x0200000 /* fail if we can not lock map */
> -#define UVM_FLAG_HOLE    0x0400000 /* no backend */
> -#define UVM_FLAG_QUERY   0x0800000 /* do everything, except actual execution 
> */
> -#define UVM_FLAG_NOFAULT 0x1000000 /* don't fault */
> -#define UVM_FLAG_UNMAP   0x2000000 /* unmap to make space */
> +#define UVM_FLAG_TRYLOCK 0x0100000 /* fail if we can not lock map */
> +#define UVM_FLAG_HOLE    0x0200000 /* no backend */
> +#define UVM_FLAG_QUERY   0x0400000 /* do everything, except actual execution 
> */
> +#define UVM_FLAG_NOFAULT 0x0800000 /* don't fault */
> +#define UVM_FLAG_UNMAP   0x1000000 /* unmap to make space */
>  
>  
>  /* macros to extract info */
> Index: uvm/uvm_map.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_map.c,v
> retrieving revision 1.210
> diff -u -p -r1.210 uvm_map.c
> --- uvm/uvm_map.c     27 Mar 2016 09:51:37 -0000      1.210
> +++ uvm/uvm_map.c     3 Apr 2016 14:00:30 -0000
> @@ -1084,9 +1084,7 @@ uvm_mapanon(struct vm_map *map, vaddr_t 
>       if (flags & UVM_FLAG_OVERLAY) {
>               KERNEL_LOCK();
>               entry->aref.ar_pageoff = 0;
> -             entry->aref.ar_amap = amap_alloc(sz,
> -                 ptoa(flags & UVM_FLAG_AMAPPAD ? UVM_AMAP_CHUNK : 0),
> -                 M_WAITOK);
> +             entry->aref.ar_amap = amap_alloc(sz, M_WAITOK);
>               KERNEL_UNLOCK();
>       }
>  
> @@ -1342,9 +1340,7 @@ uvm_map(struct vm_map *map, vaddr_t *add
>       }
>       if (flags & UVM_FLAG_OVERLAY) {
>               entry->aref.ar_pageoff = 0;
> -             entry->aref.ar_amap = amap_alloc(sz,
> -                 ptoa(flags & UVM_FLAG_AMAPPAD ? UVM_AMAP_CHUNK : 0),
> -                 M_WAITOK);
> +             entry->aref.ar_amap = amap_alloc(sz, M_WAITOK);
>       }
>  
>       /* Update map and process statistics. */
> Index: uvm/uvm_unix.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_unix.c,v
> retrieving revision 1.57
> diff -u -p -r1.57 uvm_unix.c
> --- uvm/uvm_unix.c    15 Mar 2016 18:16:47 -0000      1.57
> +++ uvm/uvm_unix.c    3 Apr 2016 14:00:30 -0000
> @@ -86,8 +86,7 @@ sys_obreak(struct proc *p, void *v, regi
>                   UVM_UNKNOWN_OFFSET, 0,
>                   UVM_MAPFLAG(PROT_READ | PROT_WRITE,
>                   PROT_READ | PROT_WRITE | PROT_EXEC, MAP_INHERIT_COPY,
> -                 MADV_NORMAL, UVM_FLAG_AMAPPAD|UVM_FLAG_FIXED|
> -                 UVM_FLAG_COPYONW));
> +                 MADV_NORMAL, UVM_FLAG_FIXED|UVM_FLAG_COPYONW));
>               if (error) {
>                       uprintf("sbrk: grow %ld failed, error = %d\n",
>                           new - old, error);
> 
> 

Reply via email to