From nobody Sun Jun 04 17:17:58 2023 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 4QZ3N672Vmz4ZMyN; Sun, 4 Jun 2023 17:17:58 +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 4QZ3N66Y0Zz3xxG; Sun, 4 Jun 2023 17:17:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685899078; 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=SWX4oJ0IxoGDYZt8OZm+FOzn5KWpSsjMpT1eUPsfgpc=; b=XzAQ6V2WbK34/Gan29+gxcGC5eYmzJlVl8fjzwsNacfGZNC/xv0vHgZZX2nQgCAzVUQtJD hAef6Ag+4s5I1hbsBNySvvOvI4lA2fo6BZ+TRjxhWs3U0lRv6geJJjI3yO9kPkoxGI1CFQ JaNZprlkcTIR9QO1RQ5P6rhzlaHa0i5yYvLJZ74yehU0L4Aq3dPIXFTj5uH2veK8lk8oi4 hamATMBNwLLfRK0P4ofkJO3TfSvgQxgBgHCycUi8L4jQm9e4r4tqaSzHUfisKfFxisyh4+ c+5ZhizCETe8TLhIk+bVOPsDs8ERMAEGKmL/f8+ck+H6CGalXqsHFavIQ0BgaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685899078; 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=SWX4oJ0IxoGDYZt8OZm+FOzn5KWpSsjMpT1eUPsfgpc=; b=DAZgdWbxTOSfgZuu/rhnWnNeqMq5zUWgeJmLcgfL4EI2hYlGErpXfnJ9YWheF+r+P+vTtx JBI/04F+xn0DsPujE57JV9B/SVu0qtbk4ov2xZW0BeYMmjYUiE0iTFyA+IRCD63Mxaa4Ea ItVz7//d4iZCQU1PxBRAL987+suZ4kOer0oKfSMbwhrnA4qpUvDKXIE6XBrMWnhvD+a4Qx LsG31myQGnyp9jtDrThEGGoKnKx99vXFraPNut7lv0KG2q++QpDUDdgY6+JGVNCFWnIf0S 5vVT3LmT2JSRVlIIH17rP/q588uz4BudeRx1OEM4yPZIgJmal1+xxSc8pEN+dg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685899078; a=rsa-sha256; cv=none; b=HveN2cEi5VOYSLfYWFLO6j5H4pxCGYOlNfwzH6du2RRxU7BBBobDuu7mL1gHOEMF2f1X+A 4x7DUeeNj2Dk6xJP7MCfS75A2RLUvPBc5M0dzZB3CCufdEP7Mma+9QMM/98754Fg8HiUEi NqAhM6r2cwmssosP2/D80e+K1zAXG+ITzyWUtKy+04P5rkzFYoZqWODSPTtnA1T+ASPxlT UNo/wjI0Go8xRvOCCkIDjJltYaWVlgMdE2RTRXuu0JUiYKlBlghiRjHa+Kk8YrBSwcRphp nYUSYUvhTY3ECN1mYxXrFcvoNOghhugQBfCawyO+j1Qb5IcLPJX/jh8UqCU/Kw== 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 4QZ3N65VgDzFjQ; Sun, 4 Jun 2023 17:17:58 +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 354HHw6W009981; Sun, 4 Jun 2023 17:17:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 354HHwUi009980; Sun, 4 Jun 2023 17:17:58 GMT (envelope-from git) Date: Sun, 4 Jun 2023 17:17:58 GMT Message-Id: <202306041717.354HHwUi009980@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 2404380aac7e - main - tslog: Optionally instrument pmap_zero_page 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: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2404380aac7eaf8019aa0939224bbce2d561d01f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=2404380aac7eaf8019aa0939224bbce2d561d01f commit 2404380aac7eaf8019aa0939224bbce2d561d01f Author: Colin Percival AuthorDate: 2023-05-29 23:03:14 +0000 Commit: Colin Percival CommitDate: 2023-06-04 17:16:31 +0000 tslog: Optionally instrument pmap_zero_page Booting an amd64 kernel on Firecracker with 1 CPU and 128 MB of RAM, pmap_zero_page is responsible for 4.6 ms of the 25.0 ms of boot time. This is not in fact time spent zeroing pages though; almost all of that time is spent in a first-touch penalty, presumably due to the host Linux kernel faulting in backing pages one by one. There's probably a way to improve that by teaching Firecracker to fault in all the VM's pages from the start rather than having them faulted in one at a time, but that's outside of FreeBSD's control. This commit adds a TSLOG_PAGEZERO option which enables TSLOG on the amd64 pmap_zero_page function; it's a separate option (turned off by default even if TSLOG is enabled) since zeroing pages happens enough that it can easily fill the TSLOG buffer and prevent other timing information from being recorded. Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D40326 --- sys/amd64/amd64/pmap.c | 9 ++++++++- sys/conf/NOTES | 3 +++ sys/conf/options | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 889311d598d6..657ba67cd619 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -8155,9 +8155,16 @@ pmap_vmspace_copy(pmap_t dst_pmap, pmap_t src_pmap) void pmap_zero_page(vm_page_t m) { - vm_offset_t va = PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)); + vm_offset_t va; +#ifdef TSLOG_PAGEZERO + TSENTER(); +#endif + va = PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)); pagezero((void *)va); +#ifdef TSLOG_PAGEZERO + TSEXIT(); +#endif } /* diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 8725d11a5434..23ec7b5c45c9 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -615,6 +615,9 @@ options NUM_CORE_FILES=5 # before it is possible to use more sophisticated tools like DTrace. # The TSLOGSIZE option controls the size of the (preallocated, fixed # length) buffer used for storing these events (default: 262144 records). +# The TSLOG_PAGEZERO option enables TSLOG of pmap_zero_page; this must be +# enabled separately since it typically generates too many records to be +# useful. # # For security reasons the TSLOG option should not be enabled on systems # used in production. diff --git a/sys/conf/options b/sys/conf/options index a8b441e320cb..7a34fa0f7333 100644 --- a/sys/conf/options +++ b/sys/conf/options @@ -67,6 +67,7 @@ SYSCTL_DEBUG opt_sysctl.h TEXTDUMP_PREFERRED opt_ddb.h TEXTDUMP_VERBOSE opt_ddb.h TSLOG opt_global.h +TSLOG_PAGEZERO opt_global.h TSLOGSIZE opt_global.h # Miscellaneous options.