From nobody Tue Feb 01 08:12:51 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 B562019AF3D7; Tue, 1 Feb 2022 08:12:52 +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 4JnyNN1dtqz3jbN; Tue, 1 Feb 2022 08:12:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643703172; 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=VDclJBzbbm0ZUNc7qQwpkUY0Hx2S7i+WFsalUfVLlPs=; b=fZIKXAhfYmlFneyY7YG8vCa5MPDfXlTLpOfpB9WYRxa7VQeUN1y4uVT0eFonN7AtMDITKz kvRF7yQ1nlBlr4kFXBGTm6Md00lM2Yn9Lf5POU3WeArO9G3xTw+yAuwXFToO73p/hV+USA UFl5tgBppbIMzGjAYGy43K0pi3YRKMvVKkTTVIWTlEDvZ2lZBTLTBMHzKzvULPzBY6vkZp haAj8dncDWV4D2RUhvt8UI6kNkbUmxFVKbGPJXSAZkEIkPc+UCwT8k4hbunVYP7XZUGVkp qxqDBVd+z2RU3T1ZeFx/fDAsSbelULAFTJdZ72R7u4UXNOiW9ltE/my3LNaYTg== 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 A11B94D41; Tue, 1 Feb 2022 08:12:51 +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 2118Cpca076023; Tue, 1 Feb 2022 08:12:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2118CpBL076022; Tue, 1 Feb 2022 08:12:51 GMT (envelope-from git) Date: Tue, 1 Feb 2022 08:12:51 GMT Message-Id: <202202010812.2118CpBL076022@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: eacdf85d4410 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: eacdf85d44101c945f9e39c0af58147e334a1b75 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643703172; 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=VDclJBzbbm0ZUNc7qQwpkUY0Hx2S7i+WFsalUfVLlPs=; b=rfHCN7xHFCYP9X6zibCKwe8Y/kL1fPPqvqetTJvu68W7/Gw5o5mL/Fz39k7iAtX7jer2Jg u5fG85icHLvjSs+RnS5zGWhzAjg5V3f1snHh5FIA1PQZb3hCXAxv4p0lxDhgEbA1TvcnGz Yry4XOWANl6AIuqvtHWONn0n14oyFp0tJkpo48Tt7XWARzUWX0eeHYqrNRimqCNGWV1Q5R tgx7tJ4KqvaG4k3VxOwuu27Tjbuf2qHrKkqqKLg5airgz2LsnIROH4xu+0fGw5/cYNAfLo +fxbGW6ZIqTrWl8qxIbyO3N67xWeEoawXEqVuFHYzBTYYwqAA8ccj6ZinT0dGw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643703172; a=rsa-sha256; cv=none; b=A0yL4YckqVd5BpgwzuA81pFUZ1qz+ubjsCDfZ6qCN9Q4G6UGIziGKvQDraJevJQJ+20hdD nnoLAtC7Q3Y0MXBaxvP6Fw+8LOReiwQVfjIS9gf97cSvy2D3lnoddq3ErCQuMlQcZBsXdT 6OgCy1nw0iO3AElNmkY/wTNhf5Ej/D5IRHVcggMKDH4EgZ+k5UAhQV29Q2KxCgXw8Y44NY aRaQuku9ssc4gcOuQUCV868AMeEKhycfMxKkNVtBrvYBYrLUOyO5PDyQzELI2xmTPK2yBH SeB36mhfm/BZBecWfep0MVBWJplJOEueyIeLILo8hvnVesxuzxPhbuTMV4jf4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=eacdf85d44101c945f9e39c0af58147e334a1b75 commit eacdf85d44101c945f9e39c0af58147e334a1b75 Author: Andriy Gapon AuthorDate: 2022-01-11 13:44:46 +0000 Commit: Andriy Gapon CommitDate: 2022-02-01 08:12:03 +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. (cherry picked from commit 7fdf0e883567d96d27d929c49a74d5fdb84d550b) --- 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 40ef286805ab..dfdd2834d4cc 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");