git: 7fdf0e883567 - main - dtrace: add a knob to control maximum size of principal buffers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 11 Jan 2022 13:51:42 UTC
The branch main has been updated by avg:
URL: https://cgit.FreeBSD.org/src/commit/?id=7fdf0e883567d96d27d929c49a74d5fdb84d550b
commit 7fdf0e883567d96d27d929c49a74d5fdb84d550b
Author: Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2022-01-11 13:44:46 +0000
Commit: Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2022-01-11 13:47:50 +0000
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
---
sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c | 4 +++-
sys/cddl/dev/dtrace/dtrace_sysctl.c | 4 ++++
2 files changed, 7 insertions(+), 1 deletion(-)
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
diff --git a/sys/cddl/dev/dtrace/dtrace_sysctl.c b/sys/cddl/dev/dtrace/dtrace_sysctl.c
index 8473c549ddc2..db2c44db0249 100644
--- a/sys/cddl/dev/dtrace/dtrace_sysctl.c
+++ b/sys/cddl/dev/dtrace/dtrace_sysctl.c
@@ -96,5 +96,9 @@ SYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW,
SYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW,
&dtrace_helper_actions_max, 0, "maximum number of allowed helper actions");
+SYSCTL_INT(_kern_dtrace, OID_AUTO, bufsize_max, CTLFLAG_RWTUN,
+ &dtrace_bufsize_max_frac, 0,
+ "maximum fraction (1/n-th) of physical memory for principal buffers");
+
SYSCTL_INT(_security_bsd, OID_AUTO, allow_destructive_dtrace, CTLFLAG_RDTUN,
&dtrace_allow_destructive, 1, "Allow destructive mode DTrace scripts");