aboutsummaryrefslogtreecommitdiff
path: root/sys/cddl/contrib
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2022-01-11 13:44:46 +0000
committerAndriy Gapon <avg@FreeBSD.org>2022-01-11 13:47:50 +0000
commit7fdf0e883567d96d27d929c49a74d5fdb84d550b (patch)
treebb91cde97dd3d86c4df4345f4707647d2a03fcc2 /sys/cddl/contrib
parent256c8c5df2a4bdd43afd9ec5a2f8be9374284e1e (diff)
downloadsrc-7fdf0e883567d96d27d929c49a74d5fdb84d550b.tar.gz
src-7fdf0e883567d96d27d929c49a74d5fdb84d550b.zip
dtrace: add a knob to control maximum size of principal buffers
We had a hardcoded limit of 1/128-th of physical memory that was further subdivided between all CPUs as principal buffers are allocated on the per-CPU basis. Actually, the buffers could use up 1/64-th of the memmory because with the default switch policy there are two buffers per CPU. This commit allows to change that limit. Note that the discussed limit is per dtrace command invocation. The idea is to limit the size of a single malloc(9) call, not the total memory size used by DTrace buffers. Reviewed by: markj MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D33648
Diffstat (limited to 'sys/cddl/contrib')
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
index 4798db98f6fe..38612a088066 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
@@ -207,6 +207,7 @@ hrtime_t dtrace_deadman_user = (hrtime_t)30 * NANOSEC;
hrtime_t dtrace_unregister_defunct_reap = (hrtime_t)60 * NANOSEC;
#ifndef illumos
int dtrace_memstr_max = 4096;
+int dtrace_bufsize_max_frac = 128;
#endif
/*
@@ -12205,7 +12206,8 @@ err:
* ask to malloc, so let's place a limit here before trying
* to do something that might well end in tears at bedtime.
*/
- if (size > physmem * PAGE_SIZE / (128 * (mp_maxid + 1)))
+ int bufsize_percpu_frac = dtrace_bufsize_max_frac * mp_ncpus;
+ if (size > physmem * PAGE_SIZE / bufsize_percpu_frac)
return (ENOMEM);
#endif