On Sun, Oct 30, 2016 at 07:37:27AM +0100, Otto Moerbeek wrote:
> Hi,
>
> remove some old option letters and also make P non-settable. It has
> been the default for ages, and I see no valid reason to be able to
> disable it.
>
> OK?
No feedback,... I will commit this diff soon, unless someone objects
(quickly).
-Otto
>
>
> Index: lib/libc/stdlib/malloc.c
> ===================================================================
> RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v
> retrieving revision 1.208
> diff -u -p -r1.208 malloc.c
> --- lib/libc/stdlib/malloc.c 28 Oct 2016 17:03:22 -0000 1.208
> +++ lib/libc/stdlib/malloc.c 30 Oct 2016 06:32:57 -0000
> @@ -68,10 +68,9 @@
> #define CHUNK_CHECK_LENGTH 32
>
> /*
> - * When the P option is active, we move allocations between half a page
> - * and a whole page towards the end, subject to alignment constraints.
> - * This is the extra headroom we allow. Set to zero to be the most
> - * strict.
> + * We move allocations between half a page and a whole page towards the end,
> + * subject to alignment constraints. This is the extra headroom we allow.
> + * Set to zero to be the most strict.
> */
> #define MALLOC_LEEWAY 0
>
> @@ -177,12 +176,11 @@ struct malloc_readonly {
> int malloc_freenow; /* Free quickly - disable chunk rnd */
> int malloc_freeunmap; /* mprotect free pages PROT_NONE? */
> int malloc_junk; /* junk fill? */
> - int malloc_move; /* move allocations to end of page? */
> int malloc_realloc; /* always realloc? */
> int malloc_xmalloc; /* xmalloc behaviour? */
> int chunk_canaries; /* use canaries after chunks? */
> - size_t malloc_guard; /* use guard pages after allocations? */
> u_int malloc_cache; /* free pages we cache */
> + size_t malloc_guard; /* use guard pages after allocations? */
> #ifdef MALLOC_STATS
> int malloc_stats; /* dump statistics at end */
> #endif
> @@ -493,10 +491,6 @@ omalloc_parseopt(char opt)
> case '<':
> mopts.malloc_cache >>= 1;
> break;
> - case 'a':
> - case 'A':
> - /* ignored */
> - break;
> case 'c':
> mopts.chunk_canaries = 0;
> break;
> @@ -533,15 +527,6 @@ omalloc_parseopt(char opt)
> if (mopts.malloc_junk < 2)
> mopts.malloc_junk++;
> break;
> - case 'n':
> - case 'N':
> - break;
> - case 'p':
> - mopts.malloc_move = 0;
> - break;
> - case 'P':
> - mopts.malloc_move = 1;
> - break;
> case 'r':
> mopts.malloc_realloc = 0;
> break;
> @@ -579,7 +564,6 @@ omalloc_init(void)
> * Default options
> */
> mopts.malloc_junk = 1;
> - mopts.malloc_move = 1;
> mopts.malloc_cache = MALLOC_DEFAULT_CACHE;
>
> for (i = 0; i < 3; i++) {
> @@ -1146,9 +1130,7 @@ omalloc(struct dir_info *pool, size_t sz
> STATS_ADD(pool->malloc_guarded, mopts.malloc_guard);
> }
>
> - if (mopts.malloc_move &&
> - sz - mopts.malloc_guard < MALLOC_PAGESIZE -
> - MALLOC_LEEWAY) {
> + if (sz - mopts.malloc_guard < MALLOC_PAGESIZE - MALLOC_LEEWAY) {
> /* fill whole allocation */
> if (mopts.malloc_junk == 2)
> memset(p, SOME_JUNK, psz - mopts.malloc_guard);
> Index: share/man/man5/malloc.conf.5
> ===================================================================
> RCS file: /cvs/src/share/man/man5/malloc.conf.5,v
> retrieving revision 1.10
> diff -u -p -r1.10 malloc.conf.5
> --- share/man/man5/malloc.conf.5 28 Oct 2016 17:03:47 -0000 1.10
> +++ share/man/man5/malloc.conf.5 30 Oct 2016 06:32:58 -0000
> @@ -89,12 +89,6 @@ the filling pattern is validated and the
> was modified.
> If the junk level is zero, no junking is performed.
> For junk level 2, junking is done without size restrictions.
> -.It Cm P
> -.Dq Move allocations within a page.
> -Allocations larger than half a page but smaller than a page
> -are aligned to the end of a page to catch buffer overruns in more
> -cases.
> -This is the default.
> .It Cm R
> .Dq realloc .
> Always reallocate when