From nobody Thu Jun 9 18:06:11 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 3F03C854FFB; Thu, 9 Jun 2022 18:06:12 +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 4LJsTw16Tpz4mQg; Thu, 9 Jun 2022 18:06:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654797972; 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=zlGUCBJrBVk5az+3HRCbC2XKCju9xVwRNHUNZlb+cJ8=; b=WgRQP4dlRPGQwuChb7mo/GX8p6ixVTvLuARK5BbXGkBVfs7C+EY6YpxliU3ieVW6pISnmO 9GlUT4MTuxRs93grjMufHJVyZjZL/mFkXeU2d/OKwHjyAAFxM3ILMnF3I6CKRwhMxkv76w baa1b5CZWOMs1fCkkYAQ1BLVYObQXKaHQGVhyG2LBjXl9/QfP30Y7Euida4STAH0PPsk2H Zr5wv8/jQtepogpakGz8mmntcRP+GUR3SEz7MzTHD0r7BSaBaZEMkos37mBHZyMFGOw6j2 mRRllkiDIx4K8l3Dd9uG8l7MjhcIWZahjsQ1serke1C0CyHPi5MWCt9B211SXA== 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 075AB744; Thu, 9 Jun 2022 18:06:12 +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 259I6BVs020273; Thu, 9 Jun 2022 18:06:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 259I6Blb020272; Thu, 9 Jun 2022 18:06:11 GMT (envelope-from git) Date: Thu, 9 Jun 2022 18:06:11 GMT Message-Id: <202206091806.259I6Blb020272@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: ca341f3cf52f - main - hwpmc: Permit the minimum sampling count to be set as a sysctl. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ca341f3cf52f8cb036d93cd611d8f3f5b552ea8e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654797972; 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=zlGUCBJrBVk5az+3HRCbC2XKCju9xVwRNHUNZlb+cJ8=; b=ePb5Pxkj9zlCT/39ida7i8CRfYiWYuJsVmddSK3p1cVFNIPjOFxNMRg8POCvu35NUdy0bD 8tzfYr4ew5QzYK4Bn0xOi/GYM766yj7LTKVHmM29W6lcGuE+v+39U/ChUQ4o3BIHMrJ1lQ q9tDgGBqBdIZkDIhcTUIcM9NXQJ5uyE2vucH2IC1kEIy1t/4WlHi1AEHwgoALC1xxgSzbE ZrfSun1h3xWNzhLas+V7ueAZrHEnQaQ47bXArIU+57EJaxPS6aOG+ozWP/w26XF9pUxGgW zdNpi1v9bdggKwiycP+ZGJ1ukNPsVpdIXm66YDSouMj3blmwGvAgRBELTCUK8Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654797972; a=rsa-sha256; cv=none; b=eP4EvfEy4Oy46XTBwGrCgfI8lwsMjUUFYO3yLd4WwbQ6khmdM2IGd8ybzk11Mya5l9DfpW xgVfW0O9/yybTklXNlAKlKNeV3NWq+fFVvQqXu7nTlX0R5FQP2SOG6oSOkHs/af4dyH/gO LVAecSqJ4xl5Er03g9bKvsaYztuOJ78ZOyGDLhSXayiKLlpYRkKoZSqO+UIgl3Ux3y0vIU r5/61NLT9fXK8nEsAFFCN7fhzszT4TrSPh22pcpIjcSfABTZHA4cMHqRuVBvXOHtdjJ/Ck uW4AJH5mAfcxlaaLd3YMYLDHM7UIpA2RFsljdG+4/PFfghLHJ1+TzuDeCLVn2A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=ca341f3cf52f8cb036d93cd611d8f3f5b552ea8e commit ca341f3cf52f8cb036d93cd611d8f3f5b552ea8e Author: John Baldwin AuthorDate: 2022-06-09 18:05:34 +0000 Commit: John Baldwin CommitDate: 2022-06-09 18:05:34 +0000 hwpmc: Permit the minimum sampling count to be set as a sysctl. A rarely occurring event (e.g. an event that occurs less than 1000 times during execution of a program) may require a lower minimum threshold than 1000. Replace the hardcoded 1000 with a sysctl that the administrator can use to permit smaller sampling count values. Reviewed by: mhorne, mav Sponsored by: University of Cambridge, Google, Inc. Differential Revision: https://reviews.freebsd.org/D35400 --- share/man/man4/hwpmc.4 | 3 +++ sys/dev/hwpmc/hwpmc_mod.c | 38 ++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/share/man/man4/hwpmc.4 b/share/man/man4/hwpmc.4 index 77fe4b9a075a..806c2ee701c5 100644 --- a/share/man/man4/hwpmc.4 +++ b/share/man/man4/hwpmc.4 @@ -416,6 +416,9 @@ The size in kilobytes of each log buffer used by .Nm Ns 's logging function. The default buffer size is 4KB. +.It Va kern.hwpmc.mincount Pq integer, read-write +The minimum sampling rate for sampling mode PMCs. +The default count is 1000 events. .It Va kern.hwpmc.mtxpoolsize Pq integer, read-only The size of the spin mutex pool used by the PMC driver. The default is 32. diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 18b8bb1674a3..21987c310b94 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -363,6 +363,14 @@ SYSCTL_INT(_kern_hwpmc, OID_AUTO, threadfreelist_max, CTLFLAG_RW, "maximum number of available thread entries before freeing some"); +/* + * kern.hwpmc.mincount -- minimum sample count + */ +static u_int pmc_mincount = 1000; +SYSCTL_INT(_kern_hwpmc, OID_AUTO, mincount, CTLFLAG_RWTUN, + &pmc_mincount, 0, + "minimum count for sampling counters"); + /* * security.bsd.unprivileged_syspmcs -- allow non-root processes to * allocate system-wide PMCs. @@ -3950,13 +3958,16 @@ pmc_syscall_handler(struct thread *td, void *syscall_args) /* XXX set lower bound on sampling for process counters */ if (PMC_IS_SAMPLING_MODE(mode)) { /* - * Don't permit requested sample rate to be less than 1000 + * Don't permit requested sample rate to be + * less than pmc_mincount. */ - if (pa.pm_count < 1000) - log(LOG_WARNING, - "pmcallocate: passed sample rate %ju - setting to 1000\n", - (uintmax_t)pa.pm_count); - pmc->pm_sc.pm_reloadcount = MAX(1000, pa.pm_count); + if (pa.pm_count < MAX(1, pmc_mincount)) + log(LOG_WARNING, "pmcallocate: passed sample " + "rate %ju - setting to %u\n", + (uintmax_t)pa.pm_count, + MAX(1, pmc_mincount)); + pmc->pm_sc.pm_reloadcount = MAX(MAX(1, pmc_mincount), + pa.pm_count); } else pmc->pm_sc.pm_initial = pa.pm_count; @@ -4474,13 +4485,16 @@ pmc_syscall_handler(struct thread *td, void *syscall_args) if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm))) { /* - * Don't permit requested sample rate to be less than 1000 + * Don't permit requested sample rate to be + * less than pmc_mincount. */ - if (sc.pm_count < 1000) - log(LOG_WARNING, - "pmcsetcount: passed sample rate %ju - setting to 1000\n", - (uintmax_t)sc.pm_count); - pm->pm_sc.pm_reloadcount = MAX(1000, sc.pm_count); + if (sc.pm_count < MAX(1, pmc_mincount)) + log(LOG_WARNING, "pmcsetcount: passed sample " + "rate %ju - setting to %u\n", + (uintmax_t)sc.pm_count, + MAX(1, pmc_mincount)); + pm->pm_sc.pm_reloadcount = MAX(MAX(1, pmc_mincount), + sc.pm_count); } else pm->pm_sc.pm_initial = sc.pm_count; }