From owner-svn-src-stable@FreeBSD.ORG Sun May 25 18:19:58 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7D801C8E; Sun, 25 May 2014 18:19:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5DD812541; Sun, 25 May 2014 18:19:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4PIJw8e091160; Sun, 25 May 2014 18:19:58 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4PIJvnJ091155; Sun, 25 May 2014 18:19:57 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201405251819.s4PIJvnJ091155@svn.freebsd.org> From: Mark Johnston Date: Sun, 25 May 2014 18:19:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r266667 - in stable/10: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering cddl/contrib/opensolaris/lib/libdtrace/common sys/cddl/compat/opensolaris/sys sys/cddl/contrib/open... X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 May 2014 18:19:58 -0000 Author: markj Date: Sun May 25 18:19:57 2014 New Revision: 266667 URL: http://svnweb.freebsd.org/changeset/base/266667 Log: MFC r262329: Define the KM_NORMALPRI flag for kmem_alloc(), as it is used in some upstream DTrace code. MFC r262330: 1452 DTrace buffer autoscaling should be less violent illumos/illumos-gate@6fb4854bed54ce82bd8610896b64ddebcd4af706 Modified: stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize1.d stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize2.d stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c stable/10/sys/cddl/compat/opensolaris/sys/kmem.h stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Directory Properties: stable/10/ (props changed) Modified: stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize1.d ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize1.d Sun May 25 18:15:37 2014 (r266666) +++ stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize1.d Sun May 25 18:19:57 2014 (r266667) @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * ASSERTION: * Checks that setting "bufresize" to "auto" will cause buffer @@ -34,14 +32,8 @@ * SECTION: Buffers and Buffering/Buffer Resizing Policy; * Options and Tunables/bufsize; * Options and Tunables/bufresize - * - * NOTES: - * We use the undocumented "preallocate" option to make sure dtrace(1M) - * has enough space in its heap to allocate a buffer as large as the - * kernel's trace buffer. */ -#pragma D option preallocate=100t #pragma D option bufresize=auto #pragma D option bufsize=100t Modified: stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize2.d ============================================================================== --- stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize2.d Sun May 25 18:15:37 2014 (r266666) +++ stable/10/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/buffering/tst.resize2.d Sun May 25 18:19:57 2014 (r266667) @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * ASSERTION: * Checks that setting "bufresize" to "auto" will cause buffer @@ -34,14 +32,8 @@ * SECTION: Buffers and Buffering/Buffer Resizing Policy; * Options and Tunables/aggsize; * Options and Tunables/bufresize - * - * NOTES: - * We use the undocumented "preallocate" option to make sure dtrace(1M) - * has enough space in its heap to allocate a buffer as large as the - * kernel's trace buffer. */ -#pragma D option preallocate=100t #pragma D option bufresize=auto #pragma D option aggsize=100t Modified: stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c ============================================================================== --- stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c Sun May 25 18:15:37 2014 (r266666) +++ stable/10/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c Sun May 25 18:19:57 2014 (r266667) @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Copyright (c) 2012 by Delphix. All rights reserved. */ @@ -906,30 +904,6 @@ dt_options_load(dtrace_hdl_t *dtp) return (0); } -/*ARGSUSED*/ -static int -dt_opt_preallocate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) -{ - dtrace_optval_t size; - void *p; - - if (arg == NULL || dt_optval_parse(arg, &size) != 0) - return (dt_set_errno(dtp, EDT_BADOPTVAL)); - - if (size > SIZE_MAX) - size = SIZE_MAX; - - if ((p = dt_zalloc(dtp, size)) == NULL) { - do { - size /= 2; - } while ((p = dt_zalloc(dtp, size)) == NULL); - } - - dt_free(dtp, p); - - return (0); -} - typedef struct dt_option { const char *o_name; int (*o_func)(dtrace_hdl_t *, const char *, uintptr_t); @@ -968,7 +942,6 @@ static const dt_option_t _dtrace_ctoptio { "linktype", dt_opt_linktype }, { "nolibs", dt_opt_cflags, DTRACE_C_NOLIBS }, { "pgmax", dt_opt_pgmax }, - { "preallocate", dt_opt_preallocate }, { "pspec", dt_opt_cflags, DTRACE_C_PSPEC }, { "setenv", dt_opt_setenv, 1 }, { "stdc", dt_opt_stdc }, Modified: stable/10/sys/cddl/compat/opensolaris/sys/kmem.h ============================================================================== --- stable/10/sys/cddl/compat/opensolaris/sys/kmem.h Sun May 25 18:15:37 2014 (r266666) +++ stable/10/sys/cddl/compat/opensolaris/sys/kmem.h Sun May 25 18:19:57 2014 (r266667) @@ -47,6 +47,7 @@ MALLOC_DECLARE(M_SOLARIS); #define KM_PUSHPAGE M_WAITOK #define KM_NOSLEEP M_NOWAIT #define KM_NODEBUG M_NODUMP +#define KM_NORMALPRI 0 #define KMC_NODEBUG UMA_ZONE_NODUMP #define KMC_NOTOUCH 0 Modified: stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c ============================================================================== --- stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Sun May 25 18:15:37 2014 (r266666) +++ stable/10/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c Sun May 25 18:19:57 2014 (r266667) @@ -10809,17 +10809,20 @@ dtrace_buffer_activate(dtrace_state_t *s static int dtrace_buffer_alloc(dtrace_buffer_t *bufs, size_t size, int flags, - processorid_t cpu) + processorid_t cpu, int *factor) { #if defined(sun) cpu_t *cp; #endif dtrace_buffer_t *buf; + int allocated = 0, desired = 0; #if defined(sun) ASSERT(MUTEX_HELD(&cpu_lock)); ASSERT(MUTEX_HELD(&dtrace_lock)); + *factor = 1; + if (size > dtrace_nonroot_maxsize && !PRIV_POLICY_CHOICE(CRED(), PRIV_ALL, B_FALSE)) return (EFBIG); @@ -10843,7 +10846,8 @@ dtrace_buffer_alloc(dtrace_buffer_t *buf ASSERT(buf->dtb_xamot == NULL); - if ((buf->dtb_tomax = kmem_zalloc(size, KM_NOSLEEP)) == NULL) + if ((buf->dtb_tomax = kmem_zalloc(size, + KM_NOSLEEP | KM_NORMALPRI)) == NULL) goto err; buf->dtb_size = size; @@ -10854,7 +10858,8 @@ dtrace_buffer_alloc(dtrace_buffer_t *buf if (flags & DTRACEBUF_NOSWITCH) continue; - if ((buf->dtb_xamot = kmem_zalloc(size, KM_NOSLEEP)) == NULL) + if ((buf->dtb_xamot = kmem_zalloc(size, + KM_NOSLEEP | KM_NORMALPRI)) == NULL) goto err; } while ((cp = cp->cpu_next) != cpu_list); @@ -10868,27 +10873,29 @@ err: continue; buf = &bufs[cp->cpu_id]; + desired += 2; if (buf->dtb_xamot != NULL) { ASSERT(buf->dtb_tomax != NULL); ASSERT(buf->dtb_size == size); kmem_free(buf->dtb_xamot, size); + allocated++; } if (buf->dtb_tomax != NULL) { ASSERT(buf->dtb_size == size); kmem_free(buf->dtb_tomax, size); + allocated++; } buf->dtb_tomax = NULL; buf->dtb_xamot = NULL; buf->dtb_size = 0; } while ((cp = cp->cpu_next) != cpu_list); - - return (ENOMEM); #else int i; + *factor = 1; #if defined(__amd64__) || defined(__mips__) || defined(__powerpc__) /* * FreeBSD isn't good at limiting the amount of memory we @@ -10896,7 +10903,7 @@ err: * to do something that might well end in tears at bedtime. */ if (size > physmem * PAGE_SIZE / (128 * (mp_maxid + 1))) - return(ENOMEM); + return (ENOMEM); #endif ASSERT(MUTEX_HELD(&dtrace_lock)); @@ -10918,7 +10925,8 @@ err: ASSERT(buf->dtb_xamot == NULL); - if ((buf->dtb_tomax = kmem_zalloc(size, KM_NOSLEEP)) == NULL) + if ((buf->dtb_tomax = kmem_zalloc(size, + KM_NOSLEEP | KM_NORMALPRI)) == NULL) goto err; buf->dtb_size = size; @@ -10929,7 +10937,8 @@ err: if (flags & DTRACEBUF_NOSWITCH) continue; - if ((buf->dtb_xamot = kmem_zalloc(size, KM_NOSLEEP)) == NULL) + if ((buf->dtb_xamot = kmem_zalloc(size, + KM_NOSLEEP | KM_NORMALPRI)) == NULL) goto err; } @@ -10945,16 +10954,19 @@ err: continue; buf = &bufs[i]; + desired += 2; if (buf->dtb_xamot != NULL) { ASSERT(buf->dtb_tomax != NULL); ASSERT(buf->dtb_size == size); kmem_free(buf->dtb_xamot, size); + allocated++; } if (buf->dtb_tomax != NULL) { ASSERT(buf->dtb_size == size); kmem_free(buf->dtb_tomax, size); + allocated++; } buf->dtb_tomax = NULL; @@ -10962,9 +10974,10 @@ err: buf->dtb_size = 0; } +#endif + *factor = desired / (allocated > 0 ? allocated : 1); return (ENOMEM); -#endif } /* @@ -12917,7 +12930,7 @@ dtrace_dstate_init(dtrace_dstate_t *dsta if (size < (min = dstate->dtds_chunksize + sizeof (dtrace_dynhash_t))) size = min; - if ((base = kmem_zalloc(size, KM_NOSLEEP)) == NULL) + if ((base = kmem_zalloc(size, KM_NOSLEEP | KM_NORMALPRI)) == NULL) return (ENOMEM); dstate->dtds_size = size; @@ -13369,7 +13382,7 @@ dtrace_state_buffer(dtrace_state_t *stat { dtrace_optval_t *opt = state->dts_options, size; processorid_t cpu = 0;; - int flags = 0, rval; + int flags = 0, rval, factor, divisor = 1; ASSERT(MUTEX_HELD(&dtrace_lock)); ASSERT(MUTEX_HELD(&cpu_lock)); @@ -13399,7 +13412,7 @@ dtrace_state_buffer(dtrace_state_t *stat flags |= DTRACEBUF_INACTIVE; } - for (size = opt[which]; size >= sizeof (uint64_t); size >>= 1) { + for (size = opt[which]; size >= sizeof (uint64_t); size /= divisor) { /* * The size must be 8-byte aligned. If the size is not 8-byte * aligned, drop it down by the difference. @@ -13417,7 +13430,7 @@ dtrace_state_buffer(dtrace_state_t *stat return (E2BIG); } - rval = dtrace_buffer_alloc(buf, size, flags, cpu); + rval = dtrace_buffer_alloc(buf, size, flags, cpu, &factor); if (rval != ENOMEM) { opt[which] = size; @@ -13426,6 +13439,9 @@ dtrace_state_buffer(dtrace_state_t *stat if (opt[DTRACEOPT_BUFRESIZE] == DTRACEOPT_BUFRESIZE_MANUAL) return (rval); + + for (divisor = 2; divisor < factor; divisor <<= 1) + continue; } return (ENOMEM); @@ -13527,7 +13543,8 @@ dtrace_state_go(dtrace_state_t *state, p goto out; } - spec = kmem_zalloc(nspec * sizeof (dtrace_speculation_t), KM_NOSLEEP); + spec = kmem_zalloc(nspec * sizeof (dtrace_speculation_t), + KM_NOSLEEP | KM_NORMALPRI); if (spec == NULL) { rval = ENOMEM; @@ -13538,7 +13555,8 @@ dtrace_state_go(dtrace_state_t *state, p state->dts_nspeculations = (int)nspec; for (i = 0; i < nspec; i++) { - if ((buf = kmem_zalloc(bufsize, KM_NOSLEEP)) == NULL) { + if ((buf = kmem_zalloc(bufsize, + KM_NOSLEEP | KM_NORMALPRI)) == NULL) { rval = ENOMEM; goto err; }