From nobody Sat Nov 14 00:23:27 2026 X-Original-To: dev-commits-src-main@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 4jRFGR1dw0z6yxTm for ; Sat, 14 Nov 2026 00:23:27 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jRFGR10zCz4TKp for ; Sat, 14 Nov 2026 00:23:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794615807; 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=oQnfgOg2Rzuw7A+0estFvl5qPHTuvUeUo0dxLdran+8=; b=ufBxZmm3wt4dbRpFegi9dCXJSnZjaeKGDm0I6iYOhEZO3sM68zyIf95UnKQagSF+1xJH6X I0cO2U2kW0AlfxawuwSphwNqRBqqYvPExLoWwP1WJvkuKfGrva1c6DIcUkc43BFT8zeO3L MCBzcahfLb/Lj7Eq/dGskYQRKgPKFQj20KFIoR07m/axz/yIo/6IIAVFZXzSvsO68vy2vy GwipXHh3qYogq//6rq1dl5mX2weK3M9EXgMexRWjBeTyWOtQcfKlhkrhY7AhrmaantiESQ p2MgsxJx1kk7uiXHAqPYf/UuvccjS9BEQCNXQaDDnLmSgkIFze/HZSFokiijnQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794615807; b=fnqflARgMPzHnlATSHufKrHdQpvLyFZDdsaavEtR7p8T4dzh1iB2I9jKlJ3FG4rBnGVSo2 UsOoP5c4F7hDgLO6P0QlLQTN+KgV8otDGLf5W8NrEzIsc/9HG78yMorUJc48jTHHj5rZ2z HYQaa8tnJ2aKbUu+R6IZrXcW/PThcBL648Ct8emwCE52il3/2JQzBIpjp6xDVQNwhRkT2O yd1PbiTQK69k/cAVpP3q2fOLPntDRsY9h5PDpwyhdsM3UgmowqVPPj5NdFfxolsyFda4le MIL1cVhgozgpVhp4KlsrEQfHwLV31diLoHzEs46ZPbx3m3UbhmTR/zj4dy4clg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794615807; 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=oQnfgOg2Rzuw7A+0estFvl5qPHTuvUeUo0dxLdran+8=; b=WAGIt/uB0ysA2rD0g6N1BPGlDejrhXxIzDhZrMYxFX8s6dtFCtJjV9BRXiB/KVkMjyl7In WhQ2HuTHjkALRHeaaKX2RFJKzIXRM6cXxzk4uiYffYfIeDWpspbHtzwiusJ+ueIMoStS0r xV6N+1Xe3KsL0pCQgWraixBre6w8I+4yymLOWf9SkErs9Kv9BqEssbG3wEJZVtONeD4XxW 2jZNgoQmCgI7fiLc1kSA7h7Q84YMvLmNm5BILnkH6CbBCM3K/6gPgC+mVLzZFJNAis6BlU qz/V4DdxDq/AO39SwF7X/CUJkxnL9dS7iId0ft2d7d3uybGTd+noWGI8H35EHw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jRFGR0ghgzykg for ; Sat, 14 Nov 2026 00:23:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1b9c5 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 00:23:27 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: c5cff3df96c3 - main - tests: Improve vn_io_fault1 test List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org List-Id: Commit messages for the main branch of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c5cff3df96c35aa3613c083f151e853b532d88cb Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 00:23:27 +0000 Message-Id: <6af7a9ff.1b9c5.1990f6ea@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=c5cff3df96c35aa3613c083f151e853b532d88cb commit c5cff3df96c35aa3613c083f151e853b532d88cb Author: Dag-Erling Smørgrav AuthorDate: 2026-11-14 00:22:40 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-14 00:23:24 +0000 tests: Improve vn_io_fault1 test * Declare that the test needs 4 GB of memory so it can be automatically skipped on systems with low memory. * Switch back to mmap() as in my initial prototype. Using malloc() is simpler, but on systems with malloc debugging enabled, malloc() will prefault the entire buffer, resulting in a false positive. Using mmap() also guarantees that the buffer is page-aligned, which renders the test determinstic: we now only need to prefault exactly 2 GB, and the difference between ret and len will be exactly the amount that we prefaulted. * To prefault the buffer, instead of a simple loop that writes zeroes to it, which a compiler might recognize as dead stores and eliminate, read the first INT_MAX bytes from the file into it. PR: 298159 Fixes: ba02bbbe86ae ("tests: Add test for vn_io_fault1 bug") Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D61508 --- tests/sys/kern/vn_io_fault1.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/sys/kern/vn_io_fault1.c b/tests/sys/kern/vn_io_fault1.c index d393d9d6b089..eabb35d2c9be 100644 --- a/tests/sys/kern/vn_io_fault1.c +++ b/tests/sys/kern/vn_io_fault1.c @@ -4,8 +4,11 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include + #include #include +#include #include #include #include @@ -15,6 +18,7 @@ ATF_TC_HEAD(big_unmapped_read, tc) { atf_tc_set_md_var(tc, "descr", "Read a large amount of data " "into a partially unmapped buffer"); + atf_tc_set_md_var(tc, "require.memory", "4G"); } ATF_TC_BODY(big_unmapped_read, tc) { @@ -24,20 +28,26 @@ ATF_TC_BODY(big_unmapped_read, tc) int fd; /* allocate a large buffer */ - if ((buf = malloc(len)) == NULL) + buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + if (buf == MAP_FAILED) atf_tc_skip("failed to allocate buffer"); - /* fault in just a tad more than the first 2 GB */ - for (size_t i = 0; i <= 2LU << 30; i += 4096) - buf[i] = 0; - /* create a large file */ fd = open("big", O_RDWR | O_CREAT | O_TRUNC, 0600); ATF_REQUIRE(fd >= 0); ATF_REQUIRE_EQ_MSG(0, ftruncate(fd, len), "failed to extend file: %m"); - /* read the file into the buffer */ + /* read part of the file into the buffer */ + ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET)); + ret = read(fd, buf, INT_MAX); + ATF_REQUIRE_MSG(ret >= 0, + "failed to read from file: %m"); + ATF_REQUIRE_EQ_MSG(INT_MAX, (size_t)ret, + "requested %zu bytes, got %zd", (size_t)INT_MAX, ret); + + /* read the entire file into the buffer */ + ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET)); ret = read(fd, buf, len); ATF_REQUIRE_MSG(ret >= 0, "failed to read from file: %m"); @@ -46,7 +56,7 @@ ATF_TC_BODY(big_unmapped_read, tc) /* done */ ATF_CHECK_EQ(0, close(fd)); - free(buf); + ATF_CHECK_EQ(0, munmap(buf, len)); } ATF_TP_ADD_TCS(tp)