From nobody Wed Jul 13 16:47:36 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 7EAA717FC154; Wed, 13 Jul 2022 16:47:36 +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 4Ljk7X33W1z3WRV; Wed, 13 Jul 2022 16:47:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657730856; 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=LHzTOUTf7d4ONn9458e4q6CI9dVcr8qSpcTA4tsBTWo=; b=t4kHWgA9KlTcVECft55zGi2UG02xL6/wmDYf+tFxzH6bug1B1KCSLYCBs8IIOdPqRIus19 iskpgGCuzZfKidsfcTZuqYhGkY5PEYK5nwFddawiLqiJQqSnbuHcZAYr2hSy0HhQuv74m1 yZ1rY8vl+Neb0ns5Ki6LIAvcENFeLxZmPtjB8y3rmDZl7SoInQJ9Iktt0PcqU60rSmNwUd NOhPYb33eAcxbHKFJa0fuEC0TpR/T+1tDYlpJcXyuXR0jGQwxh3+6oWe7MHZVz0uXIveJ6 b48FJ0af4GmMhdSiJZU0FJmcfPg+kPsdaETvdVbjVJmMn6iDTk+w2FR4xLBg3A== 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 4Ljk7X28LlzW8l; Wed, 13 Jul 2022 16:47:36 +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 26DGlaJ9052155; Wed, 13 Jul 2022 16:47:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26DGla70052154; Wed, 13 Jul 2022 16:47:36 GMT (envelope-from git) Date: Wed, 13 Jul 2022 16:47:36 GMT Message-Id: <202207131647.26DGla70052154@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 46b46bb77405 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 46b46bb77405c3eaf0dbd0c0c09130f773d88718 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657730856; 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=LHzTOUTf7d4ONn9458e4q6CI9dVcr8qSpcTA4tsBTWo=; b=iZreDJeWHajut+fr28MjoEa4aifhqYePhvhRYL2+kg5O5wAyy/5syJef0tFn2EzZmmJWra 7HtSpGRBZfud0GdpyJ+KWW7kE72tN0910CqVmXcYY85u2fVFxevdofN8OC7DHFZqLL63CI tEy44oMGytm/ACbOsYEXHWUzs7OUqCU9C7017XU49CEu/zkozdYk5wo5/mp/coiKystCrV hEIZYutyhYRqS0JTjplMN15vJ+vo/FAccsDGSEwhQlN6jFQHp9vH2ZTZ0v6U6MxOJE+5LS xLJsfZLMm7FZ6f4HMroj/7GYx6/+ytfrwcKzvp5at8YVw9UVXmbWo9EjoY0Dpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657730856; a=rsa-sha256; cv=none; b=YGFxF3VfEYNlYmp8NGIclfr4YAFtPslbWGvRQ80Z52O0ZWp2b4rSdQOkt6hv/KuyEfh5u+ gNMS3yssewlQy1Y4F4Ja3uW9C6a4TH7lm7Oi39GVItl2ZuD7MHUBE6ztyZb9Yi78tNS4p2 jGo0O9JAsTAY0m7Hdq/8HCjnvyjfof+s9ab8wzMzwEjnNmX9bYX5/IoOfwPHVvA7/dBQzW Ac0JQAjJC0V86WvoX+BNNujWRv7idyXWjwxAk7nAykjflXzGX5rUbSlak/zYPViiiaY7yq sXQoxpHg4emFORAShwhsGW/+/QdbeE0sbMeLRBhNzgxp/sVUS5ZoqtzgWdOHZQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=46b46bb77405c3eaf0dbd0c0c09130f773d88718 commit 46b46bb77405c3eaf0dbd0c0c09130f773d88718 Author: John Baldwin AuthorDate: 2022-06-09 18:05:34 +0000 Commit: John Baldwin CommitDate: 2022-07-13 16:19:13 +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 (cherry picked from commit ca341f3cf52f8cb036d93cd611d8f3f5b552ea8e) --- 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 063313045137..5b3353ff935d 100644 --- a/share/man/man4/hwpmc.4 +++ b/share/man/man4/hwpmc.4 @@ -423,6 +423,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 ac0d542c8a4d..50b4f3bc9d3b 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; }