From nobody Tue Jan 11 13:51:42 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 15DDD193BAF9; Tue, 11 Jan 2022 13:51:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JYBv24mjCz4XYK; Tue, 11 Jan 2022 13:51:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7A7CA1A134; Tue, 11 Jan 2022 13:51:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20BDpg4a050020; Tue, 11 Jan 2022 13:51:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20BDpgjm049989; Tue, 11 Jan 2022 13:51:42 GMT (envelope-from git) Date: Tue, 11 Jan 2022 13:51:42 GMT Message-Id: <202201111351.20BDpgjm049989@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andriy Gapon Subject: git: 7fdf0e883567 - main - dtrace: add a knob to control maximum size of principal buffers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7fdf0e883567d96d27d929c49a74d5fdb84d550b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641909102; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=p0B//UhDjkVS4gNsAU7KlEA2K1xjDOjym3631tVzO6M=; b=MfOT9gSUaKjHUa4z0Mn1Ky9RZRa+eYszqg/RpwxTyuRpBY0ZtZ8ZqKHtRxIV29gYhxYlYS WOBiGOMT31VyDb3NdV82FsWin0uIlWtLFLbw1Is1ykf1aEvqz4ZnWXnxbB9HwflLfrUFZ1 Lb1F486TYLqtjkqaUTBcjSSy2xhZT+QOp6b6MFRz1V/Xc9lierzzG4Ke/vXgdFtsTiOG3Y XqDZx8iB+0n8kcbkX4a6yAKoZrZqZOng86rGAO/BqmdOJ3VEbSMZfLr3pwtbqEiqgnIN5k +U97TJwFqDXZ7X+SlUXfoyafXMTxFHul5gyo1EsXuUA+kpjehug2b7KSCjOWUg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641909102; a=rsa-sha256; cv=none; b=Uyud3tud1dPWzSuc9sP4p3aO1B/lezcP87uHzldlNNQZ2VVetG+t3gt5Wha9QVEGBM5sUD MntH8KiipQqAhmvAOzXN83z6Hzruf7zE9RPcZMplScAUSbOtuUibW2OcWud69uDd3wT6/9 8zkLSW/WBnzAsmaInNeVz2XEUmHVwdIlEoOzTGklcXLdQrTcx6bhcsNVLV5WfLKYcfNpOG 6VL35ZiHgChCoC1t3WTgWOBdIYYTD7JgNTgizAfRL1MiM8mqv9AMlMATfJT74vDNCJQOPg vBj/z3Lbvi/hOe44sTXdHSlwQyjkaIN2xXpyOo+do3yYYr5Px/Aa41CR88mjvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=7fdf0e883567d96d27d929c49a74d5fdb84d550b commit 7fdf0e883567d96d27d929c49a74d5fdb84d550b Author: Andriy Gapon AuthorDate: 2022-01-11 13:44:46 +0000 Commit: Andriy Gapon 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");