From patchwork Tue Jun 11 03:01:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13692786 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9D02C27C4F for ; Tue, 11 Jun 2024 03:02:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 541856B00A5; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F10C6B00A6; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A6AF6B00AB; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 01AEE6B00A5 for ; Mon, 10 Jun 2024 23:02:10 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id A9F4E1C1D84 for ; Tue, 11 Jun 2024 03:02:10 +0000 (UTC) X-FDA: 82217108820.09.EF2272E Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id 17084C0017 for ; Tue, 11 Jun 2024 03:02:07 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=f6ZgZOTM; spf=none (imf28.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718074928; a=rsa-sha256; cv=none; b=mBSw2nKdzdHHOsOC/hdbyFiI5IE5xVnr3WLc5GNRGsHDsRmWQeQJrTb250XPC6GUzQ71MN G/VQQHA5r3aG3iWtdZXXyzCgiLhrK7QO3WI5ZrhGPbe1U+YXencxB6p+GE9jYuPCsq8av9 QwfXpmubTN3UymbXDzu4GK0B8Mvj8xc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=f6ZgZOTM; spf=none (imf28.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718074928; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CX8GkoD1lrWdXbOILcd8kqt0xs0WnOHnk3dNstWrvmw=; b=KZrNOjAu7a5g4fYbMbk391cC9noZpr0MpkDeegRpf6MVaBCd9s7Brqsp3cMw4S9FIh2bZG YgbzNKeb84B1wmxaorP8g8s7X9WLkpwa0tgugNgWJsP8RDJZhiKHrWpWHbaNKdrqkuU8F7 4mSxRo73BnXoXhsPzGHjV9+//CzYxmY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=CX8GkoD1lrWdXbOILcd8kqt0xs0WnOHnk3dNstWrvmw=; b=f6ZgZOTMdrlAqlPZArCc35aXQc 0aob4eDMIoMJkwFReDEAOGuj6u8becvRxbtlACrVJNRLnjaLW8kM4gtbNmH4ipl+dTmUKXdu5cKNv O5uMhahpgsMC9NZ5XOYDrOB+nKftYJKZGKziK/q9RjP9A9KLWVM/fz2nN8JrEJxwjkZXavn3QC9js W9+kXvgP6ELe5TgSlYmME+GX9WbTTeey/kmwkOiwwROLeOIcCebexa14Nz+WIyUe4IS57A9xiTO1M Tu8jih2vYCWzTf1TkwiZDX9+KGmpENr+zcIl77MtyiPhvhlcOoq85yYBwz1WViJLPP7mrhR5zdBZn W72QhX4A==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGrls-00000007DDG-1iC3; Tue, 11 Jun 2024 03:02:04 +0000 From: Luis Chamberlain To: patches@lists.linux.dev, fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, ziy@nvidia.com, vbabka@suse.cz, seanjc@google.com, willy@infradead.org, david@redhat.com, hughd@google.com, linmiaohe@huawei.com, muchun.song@linux.dev, osalvador@suse.de, p.raghav@samsung.com, da.gomez@samsung.com, hare@suse.de, john.g.garry@oracle.com, mcgrof@kernel.org, "Darrick J. Wong" Subject: [PATCH 1/5] common: move mread() to generic helper _mread() Date: Mon, 10 Jun 2024 20:01:58 -0700 Message-ID: <20240611030203.1719072-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240611030203.1719072-1-mcgrof@kernel.org> References: <20240611030203.1719072-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 17084C0017 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: 88gnrxwwc8j8bzaz736srzkpc93pon9q X-HE-Tag: 1718074927-409231 X-HE-Meta: U2FsdGVkX19xq5l7PRiaGAwhQtXuwgGPe/2rtp/0SLQppQfAL7p///TL23U32Z3q7v2cFAG2djYIQ1mTXSKAB4Xhulb8lr90nxpS/8tY3KFe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wh6Hn8zNZMlI4D/7znSr9U0Uz/1mhFXUNns0HM+FRuQ5aAcs72yHkdo09V5oMpGZu7vtsU9UyWVJIyb1pKPOhTZgLk2T3HXVXOqA2hbN4eMQfC+Te2lsEmpTPsS9ILwq5fHjneDwxfEt+9+cywNufbu/j9gL19Sr2lMfug1LUVsdk2TS6+G/7BaU1Wx4/N+x/5WK7FGiApiDZPl5+9s/2xkTyxGijqDTh3HKRANaVbGGAz3MuAYTMfZOiO9BRGuKIES X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We want a shared way to use mmap in a way that we can test for the SIGBUS, provide a shared routine which other tests can leverage. Suggested-by: "Darrick J. Wong" Signed-off-by: Luis Chamberlain Reviewed-by: Darrick J. Wong --- common/rc | 28 ++++++++++++++++++++++++++++ tests/generic/574 | 36 ++++-------------------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/common/rc b/common/rc index 163041fea5b9..fa7942809d6c 100644 --- a/common/rc +++ b/common/rc @@ -52,6 +52,34 @@ _pwrite_byte() { $XFS_IO_PROG $xfs_io_args -f -c "pwrite -S $pattern $offset $len" "$file" } +_round_up_to_page_boundary() +{ + local n=$1 + local page_size=$(_get_page_size) + + echo $(( (n + page_size - 1) & ~(page_size - 1) )) +} + +_mread() +{ + local file=$1 + local offset=$2 + local length=$3 + local map_len=$(_round_up_to_page_boundary $(_get_filesize $file)) + + # Some callers expect xfs_io to crash with SIGBUS due to the mread, + # causing the shell to print "Bus error" to stderr. To allow this + # message to be redirected, execute xfs_io in a new shell instance. + # However, for this to work reliably, we also need to prevent the new + # shell instance from optimizing out the fork and directly exec'ing + # xfs_io. The easiest way to do that is to append 'true' to the + # commands, so that xfs_io is no longer the last command the shell sees. + # Don't let it write core files to the filesystem. + bash -c "trap '' SIGBUS; ulimit -c 0; $XFS_IO_PROG -r $file \ + -c 'mmap -r 0 $map_len' \ + -c 'mread -v $offset $length'; true" +} + # mmap-write a byte into a range of a file _mwrite_byte() { local pattern="$1" diff --git a/tests/generic/574 b/tests/generic/574 index cb42baaa67aa..d44c23e5abc2 100755 --- a/tests/generic/574 +++ b/tests/generic/574 @@ -52,34 +52,6 @@ setup_zeroed_file() cmp $fsv_orig_file $fsv_file } -round_up_to_page_boundary() -{ - local n=$1 - local page_size=$(_get_page_size) - - echo $(( (n + page_size - 1) & ~(page_size - 1) )) -} - -mread() -{ - local file=$1 - local offset=$2 - local length=$3 - local map_len=$(round_up_to_page_boundary $(_get_filesize $file)) - - # Some callers expect xfs_io to crash with SIGBUS due to the mread, - # causing the shell to print "Bus error" to stderr. To allow this - # message to be redirected, execute xfs_io in a new shell instance. - # However, for this to work reliably, we also need to prevent the new - # shell instance from optimizing out the fork and directly exec'ing - # xfs_io. The easiest way to do that is to append 'true' to the - # commands, so that xfs_io is no longer the last command the shell sees. - # Don't let it write core files to the filesystem. - bash -c "trap '' SIGBUS; ulimit -c 0; $XFS_IO_PROG -r $file \ - -c 'mmap -r 0 $map_len' \ - -c 'mread -v $offset $length'; true" -} - corruption_test() { local block_size=$1 @@ -142,7 +114,7 @@ corruption_test() fi # Reading the full file via mmap should fail. - mread $fsv_file 0 $file_len >/dev/null 2>$tmp.err + _mread $fsv_file 0 $file_len >/dev/null 2>$tmp.err if ! grep -q 'Bus error' $tmp.err; then echo "Didn't see SIGBUS when reading file via mmap" cat $tmp.err @@ -150,7 +122,7 @@ corruption_test() # Reading just the corrupted part via mmap should fail. if ! $is_merkle_tree; then - mread $fsv_file $zap_offset $zap_len >/dev/null 2>$tmp.err + _mread $fsv_file $zap_offset $zap_len >/dev/null 2>$tmp.err if ! grep -q 'Bus error' $tmp.err; then echo "Didn't see SIGBUS when reading corrupted part via mmap" cat $tmp.err @@ -174,10 +146,10 @@ corrupt_eof_block_test() head -c $zap_len /dev/zero | tr '\0' X \ | _fsv_scratch_corrupt_bytes $fsv_file $file_len - mread $fsv_file $file_len $zap_len >$tmp.out 2>$tmp.err + _mread $fsv_file $file_len $zap_len >$tmp.out 2>$tmp.err head -c $file_len /dev/zero >$tmp.zeroes - mread $tmp.zeroes $file_len $zap_len >$tmp.zeroes_out + _mread $tmp.zeroes $file_len $zap_len >$tmp.zeroes_out grep -q 'Bus error' $tmp.err || diff $tmp.out $tmp.zeroes_out } From patchwork Tue Jun 11 03:01:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13692784 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D1C1C27C4F for ; Tue, 11 Jun 2024 03:02:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD2CF6B00A8; Mon, 10 Jun 2024 23:02:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B59F86B00A6; Mon, 10 Jun 2024 23:02:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DE936B00A7; Mon, 10 Jun 2024 23:02:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7DB7A6B00A4 for ; Mon, 10 Jun 2024 23:02:10 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 25008810CD for ; Tue, 11 Jun 2024 03:02:10 +0000 (UTC) X-FDA: 82217108820.22.4B55503 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id 2F9641C000C for ; Tue, 11 Jun 2024 03:02:07 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=OInBicyN; spf=none (imf21.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718074928; a=rsa-sha256; cv=none; b=OE98WaqO1zU1wp8x79WBdxziOMhWEgqqnbGQ15pYbeZlgaCHb0YnsJVDtMi+YprH6acUSP XDscVZ+IYy2zbxEjb2zd3NSvqKyxHB58gE/5MFtYLqi10pb0NwVmIv4MLy5XZiqJmT71U9 etctBNNyW/1XGGS2PNt9NDlE+nwfUxM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=OInBicyN; spf=none (imf21.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718074928; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=X20aGf13pHClluFWu9rdKRIp4/K80BReNWAfi/7xV0w=; b=XV18nreFjkxfEiG77BK/OTnFx79KLmE+oAzdV/LtdIR37iMbfmQV2ZM2XYPGcqYvrF7nAd dd8OZ5ojo1VFZNduYo7dmgD/lWR77i7ldg5qPqcpIjYyWvqamu408vnLKBGEfwBj0xqu3Z keXhr1AIeVcSUczVoeoo2Io/hlaln9k= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=X20aGf13pHClluFWu9rdKRIp4/K80BReNWAfi/7xV0w=; b=OInBicyN3WpoZTYbSGVw9oTxSZ 36n8WHTUQSHiAfFgkbSwFkR00UxQbl9zLmHLzWoHGolD7ErnDE7t19NmqlO/fey64CvkSXe9LR4Ag qva+dDNr+8AzbhTQvhVkUrCQaI1v0iHEq9HN6HGJDYUYax1pWSv4aRfDB/76pmOiQEB7+ic+YGSD1 DtRUzjAIRzIpUPQYTiR1ZfPHL8aEFIFLF8Y05gf2VkBfNABYEmXnFZ7VzPp1QRxWtXgmRgIcHCeEd 4unXHAJTDyOO9XXOjA0jgtsoPyWuPbyQiitjnjr3iwGfQjmEUCmoFPi1sGAUOuAM/1rQzP/gz6/F4 9op2ukeg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGrls-00000007DDI-1vyh; Tue, 11 Jun 2024 03:02:04 +0000 From: Luis Chamberlain To: patches@lists.linux.dev, fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, ziy@nvidia.com, vbabka@suse.cz, seanjc@google.com, willy@infradead.org, david@redhat.com, hughd@google.com, linmiaohe@huawei.com, muchun.song@linux.dev, osalvador@suse.de, p.raghav@samsung.com, da.gomez@samsung.com, hare@suse.de, john.g.garry@oracle.com, mcgrof@kernel.org Subject: [PATCH 2/5] fstests: add mmap page boundary tests Date: Mon, 10 Jun 2024 20:01:59 -0700 Message-ID: <20240611030203.1719072-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240611030203.1719072-1-mcgrof@kernel.org> References: <20240611030203.1719072-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Stat-Signature: efjmo9u1dfumqyhuxcdbkr4pk9zmrzak X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yJNW9gbx0lf1fkn96tzu2ku8fWs+iYl4l67RlunGGaBHfKsGc4s7ggp5KvDnmVBANA+L2BiLHZR9bQZO+UlTYlyJAyVZAnyjR/BcQWHEm+fyprRvxxKTEkAuaMTrDBbrNaLhKHqPs1wCNBYyjom3rsjqyCyGqrPG6jpVTPp7F66jKzTZP2FNXM02y93T9h7WXm3s36pR7SbcVdAcyaFu4EqUPto51P+DJmJVjwyttRh1H6obR8fGdntJi2DIlN5UeTAhKsWFlGExxt/oq59kwkJc9RvOwpjsvJ4LCJ6GTqlzk/y+PKPI4lqF1hVG7N84lxwqYdVpaJt1ySsAdOrw79GcAOm6GZTWTZJ6HAs2UYGUh2nOypjNEYe5PFdGq8PkCagmVHn655D0X9uw6qWxqG7EgxpK/7v4l1fDFl/axQ2ca/HTP8/YqyWPnpu09/J6CIQAmqF4QosvtDyJrz4nLyMiNbLPYzUSJu39/9NhBgdE2fbB/KUVjyUdZKW0He X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: mmap() POSIX compliance says we should zero fill data beyond a file size up to page boundary, and issue a SIGBUS if we go beyond. While fsx helps us test zero-fill sometimes, fsstress also let's us sometimes test for SIGBUS however that is based on a random value and its not likely we always test it. Dedicate a specic test for this to make testing for this specific situation and to easily expand on other corner cases. The only filesystem currently known to fail is tmpfs with huge pages, but the pending upstream patch "filemap: cap PTE range to be created to allowed zero fill in folio_map_range()" fixes this issue for tmpfs and also for LBS support. Suggested-by: Matthew Wilcox Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain --- common/rc | 5 +- tests/generic/749 | 238 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/749.out | 2 + 3 files changed, 244 insertions(+), 1 deletion(-) create mode 100755 tests/generic/749 create mode 100644 tests/generic/749.out diff --git a/common/rc b/common/rc index fa7942809d6c..e812a2f7cc67 100644 --- a/common/rc +++ b/common/rc @@ -60,12 +60,15 @@ _round_up_to_page_boundary() echo $(( (n + page_size - 1) & ~(page_size - 1) )) } +# You can override the $map_len but its optional, by default we use the +# max allowed size. If you use a length greater than the default you can +# expect a SIBGUS and test for it. _mread() { local file=$1 local offset=$2 local length=$3 - local map_len=$(_round_up_to_page_boundary $(_get_filesize $file)) + local map_len=${4:-$(_round_up_to_page_boundary $(_get_filesize $file)) } # Some callers expect xfs_io to crash with SIGBUS due to the mread, # causing the shell to print "Bus error" to stderr. To allow this diff --git a/tests/generic/749 b/tests/generic/749 new file mode 100755 index 000000000000..c1d3a2028549 --- /dev/null +++ b/tests/generic/749 @@ -0,0 +1,238 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) Luis Chamberlain. All Rights Reserved. +# +# FS QA Test 749 +# +# As per POSIX NOTES mmap(2) maps multiples of the system page size, but if the +# data mapped is not multiples of the page size the remaining bytes are zeroed +# out when mapped and modifications to that region are not written to the file. +# On Linux when you write data to such partial page after the end of the +# object, the data stays in the page cache even after the file is closed and +# unmapped and even though the data is never written to the file itself, +# subsequent mappings may see the modified content. If you go *beyond* this +# page, you should get a SIGBUS. This test verifies we zero-fill to page +# boundary and ensures we get a SIGBUS if we write to data beyond the system +# page size even if the block size is greater than the system page size. +. ./common/preamble +. ./common/rc +_begin_fstest auto quick prealloc + +# Import common functions. +. ./common/filter + +# real QA test starts here +_supported_fs generic +_require_scratch_nocheck +_require_test +_require_xfs_io_command "truncate" +_require_xfs_io_command "falloc" + +# _fixed_by_git_commit kernel \ +# "filemap: cap PTE range to be created to allowed zero fill in folio_map_range()" + +filter_xfs_io_data_unique() +{ + _filter_xfs_io_offset | sed -e 's| |\n|g' | grep -E -v "\.|XX|\*" | \ + sort -u | tr -d '\n' +} + + +setup_zeroed_file() +{ + local file_len=$1 + local sparse=$2 + + if $sparse; then + $XFS_IO_PROG -f -c "truncate $file_len" $test_file + else + $XFS_IO_PROG -f -c "falloc 0 $file_len" $test_file + fi +} + +mwrite() +{ + local file=$1 + local offset=$2 + local length=$3 + local map_len=${4:-$(_round_up_to_page_boundary $(_get_filesize $file)) } + + # Some callers expect xfs_io to crash with SIGBUS due to the mread, + # causing the shell to print "Bus error" to stderr. To allow this + # message to be redirected, execute xfs_io in a new shell instance. + # However, for this to work reliably, we also need to prevent the new + # shell instance from optimizing out the fork and directly exec'ing + # xfs_io. The easiest way to do that is to append 'true' to the + # commands, so that xfs_io is no longer the last command the shell sees. + bash -c "trap '' SIGBUS; ulimit -c 0; \ + $XFS_IO_PROG $file \ + -c 'mmap -w 0 $map_len' \ + -c 'mwrite $offset $length'; \ + true" +} + +do_mmap_tests() +{ + local block_size=$1 + local file_len=$2 + local offset=$3 + local len=$4 + local use_sparse_file=${5:-false} + local new_filelen=0 + local map_len=0 + local csum=0 + local fs_block_size=$(_get_file_block_size $SCRATCH_MNT) + + echo -en "\n\n==> Testing blocksize $block_size " >> $seqres.full + echo -en "file_len: $file_len offset: $offset " >> $seqres.full + echo -e "len: $len sparse: $use_sparse_file" >> $seqres.full + + if ((fs_block_size != block_size)); then + _fail "Block size created ($block_size) doesn't match _get_file_block_size on mount ($fs_block_size)" + fi + + rm -rf "${SCRATCH_MNT:?}"/* + + # This let's us also test against sparse files + setup_zeroed_file $file_len $use_sparse_file + + # This will overwrite the old data, the file size is the + # delta between offset and len now. + $XFS_IO_PROG -f -c "pwrite -S 0xaa -b 512 $offset $len" \ + $test_file >> $seqres.full + + sync + new_filelen=$(_get_filesize $test_file) + map_len=$(_round_up_to_page_boundary $new_filelen) + csum_orig="$(_md5_checksum $test_file)" + + # A couple of mmap() tests: + # + # We are allowed to mmap() up to the boundary of the page size of a + # data object, but there a few rules to follow we must check for: + # + # a) zero-fill test for the data: POSIX says we should zero fill any + # partial page after the end of the object. Verify zero-fill. + # b) do not write this bogus data to disk: on Linux, if we write data + # to a partially filled page, it will stay in the page cache even + # after the file is closed and unmapped even if it never reaches the + # file. Subsequent mappings *may* see the modified content, but it + # also can get other data. Since the data read after the actual + # object data can vary we just verify the filesize does not change. + if [[ $map_len -gt $new_filelen ]]; then + zero_filled_data_len=$((map_len - new_filelen)) + _scratch_cycle_mount + expected_zero_data="00" + zero_filled_data=$($XFS_IO_PROG -r $test_file \ + -c "mmap -r 0 $map_len" \ + -c "mread -v $new_filelen $zero_filled_data_len" \ + -c "munmap" | \ + filter_xfs_io_data_unique) + if [[ "$zero_filled_data" != "$expected_zero_data" ]]; then + echo "Expected data: $expected_zero_data" + echo " Actual data: $zero_filled_data" + _fail "Zero-fill expectations with mmap() not respected" + fi + + _scratch_cycle_mount + $XFS_IO_PROG $test_file \ + -c "mmap -w 0 $map_len" \ + -c "mwrite $new_filelen $zero_filled_data_len" \ + -c "munmap" + sync + csum_post="$(_md5_checksum $test_file)" + if [[ "$csum_orig" != "$csum_post" ]]; then + echo "Expected csum: $csum_orig" + echo " Actual csum: $csum_post" + _fail "mmap() write up to page boundary should not change actual file contents" + fi + + local filelen_test=$(_get_filesize $test_file) + if [[ "$filelen_test" != "$new_filelen" ]]; then + echo "Expected file length: $new_filelen" + echo " Actual file length: $filelen_test" + _fail "mmap() write up to page boundary should not change actual file size" + fi + fi + + # Now lets ensure we get SIGBUS when we go beyond the page boundary + _scratch_cycle_mount + new_filelen=$(_get_filesize $test_file) + map_len=$(_round_up_to_page_boundary $new_filelen) + csum_orig="$(_md5_checksum $test_file)" + _mread $test_file 0 $map_len >> $seqres.full 2>$tmp.err + if grep -q 'Bus error' $tmp.err; then + cat $tmp.err + _fail "Not expecting SIGBUS when reading up to page boundary" + fi + + # This should just work + _mread $test_file 0 $map_len >> $seqres.full 2>$tmp.err + if [[ $? -ne 0 ]]; then + _fail "mmap() read up to page boundary should work" + fi + + # This should just work + mwrite $map_len 0 $map_len >> $seqres.full 2>$tmp.err + if [[ $? -ne 0 ]]; then + _fail "mmap() write up to page boundary should work" + fi + + # If we mmap() on the boundary but try to read beyond it just + # fails, we don't get a SIGBUS + $XFS_IO_PROG -r $test_file \ + -c "mmap -r 0 $map_len" \ + -c "mread 0 $((map_len + 10))" >> $seqres.full 2>$tmp.err + local mread_err=$? + if [[ $mread_err -eq 0 ]]; then + _fail "mmap() to page boundary works as expected but reading beyond should fail: $mread_err" + fi + + $XFS_IO_PROG -w $test_file \ + -c "mmap -w 0 $map_len" \ + -c "mwrite 0 $((map_len + 10))" >> $seqres.full 2>$tmp.err + local mwrite_err=$? + if [[ $mwrite_err -eq 0 ]]; then + _fail "mmap() to page boundary works as expected but writing beyond should fail: $mwrite_err" + fi + + # Now let's go beyond the allowed mmap() page boundary + _mread $test_file 0 $((map_len + 10)) $((map_len + 10)) >> $seqres.full 2>$tmp.err + if ! grep -q 'Bus error' $tmp.err; then + _fail "Expected SIGBUS when mmap() reading beyond page boundary" + fi + + mwrite $test_file 0 $((map_len + 10)) $((map_len + 10)) >> $seqres.full 2>$tmp.err + if ! grep -q 'Bus error' $tmp.err; then + _fail "Expected SIGBUS when mmap() writing beyond page boundary" + fi + + local filelen_test=$(_get_filesize $test_file) + if [[ "$filelen_test" != "$new_filelen" ]]; then + echo "Expected file length: $new_filelen" + echo " Actual file length: $filelen_test" + _fail "reading or writing beyond file size up to mmap() page boundary should not change file size" + fi +} + +test_block_size() +{ + local block_size=$1 + + do_mmap_tests $block_size 512 3 5 + do_mmap_tests $block_size 11k 0 $((4096 * 3 + 3)) + do_mmap_tests $block_size 16k 0 $((16384+3)) + do_mmap_tests $block_size 16k $((16384-10)) $((16384+20)) + do_mmap_tests $block_size 64k 0 $((65536+3)) + do_mmap_tests $block_size 4k 4090 30 true +} + +_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed" +_scratch_mount +test_file=$SCRATCH_MNT/file +block_size=$(_get_file_block_size "$SCRATCH_MNT") +test_block_size $block_size + +echo "Silence is golden" +status=0 +exit diff --git a/tests/generic/749.out b/tests/generic/749.out new file mode 100644 index 000000000000..24658deddb99 --- /dev/null +++ b/tests/generic/749.out @@ -0,0 +1,2 @@ +QA output created by 749 +Silence is golden From patchwork Tue Jun 11 03:02:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13692789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9536BC27C55 for ; Tue, 11 Jun 2024 03:02:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C68776B00A9; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAB996B00AC; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B19F6B00AA; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 61FA16B00AB for ; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 11FD21C1E54 for ; Tue, 11 Jun 2024 03:02:11 +0000 (UTC) X-FDA: 82217108862.12.31458E8 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP id 6A706C0009 for ; Tue, 11 Jun 2024 03:02:09 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="tUD/4hEu"; spf=none (imf22.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718074929; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Hv/cXQiOxKNgXmCwyVTUDGGov4wBn8i/fmF48xSrHJk=; b=1d6GWcG9mH5rPomwdxExGixyQCbt5AJZpb7I/Inn2Xa20N83jej2KG4ge4C6/PYx+xtLa1 b/UE58t7K93gTYCD1yQ1KVNrnjjJ7EF9kxo+hs40EIZoTYBc+vWn8rvID46zQvPv7+9gx3 aRs7njMl/xtEkrEcXa3Jo3vbrnt+uQQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718074929; a=rsa-sha256; cv=none; b=HUoDeZZNR1vDn/gCDu1dQH/BDkFfaGrlQ6izmFYo40FBft8GiMAXOR2HNdByYiZSDf0vBf Vumaudwahys/pDyOqQ37BzSI7KWHw9khv+9756mB8B1bcmGgqNen1crOD+g7oZWBj8xcOo X9u9grDOxQ2uqKFa024VGqIRs8nX6dc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="tUD/4hEu"; spf=none (imf22.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=Hv/cXQiOxKNgXmCwyVTUDGGov4wBn8i/fmF48xSrHJk=; b=tUD/4hEuSCcxRCkWHCYdICg4V1 aQVNu8MES9D2iMfkf0d6CXzkD+DIkcvF8xvtjLGMOZtsBapUP1fOpVyDi55ef/m6fYV9kO3JIGPdO 9Ob4C5GzLJfP0PbEi1m+Gu/HRRRL4+gP3QUFPEw495CaEPQFPLcrZUBdQ5lb76JIJpS5UKI0onozu 5d8/Vzt0VycLoHwFyKUXdqkiPUHM3htT+hGKeaTqq7eo60KpsXwEgCuz1cQPvJJpUYGgPdWPCvmSx wH1HMpvahXkxWBV0csveIVGfqMQ0V27EOOhyLTB8MFKaTBd9P7N18XQ2befZxRfYy8q1PuEBc+Z3z /nVhMneQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGrls-00000007DDK-294X; Tue, 11 Jun 2024 03:02:04 +0000 From: Luis Chamberlain To: patches@lists.linux.dev, fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, ziy@nvidia.com, vbabka@suse.cz, seanjc@google.com, willy@infradead.org, david@redhat.com, hughd@google.com, linmiaohe@huawei.com, muchun.song@linux.dev, osalvador@suse.de, p.raghav@samsung.com, da.gomez@samsung.com, hare@suse.de, john.g.garry@oracle.com, mcgrof@kernel.org Subject: [PATCH 3/5] fstests: add fsstress + compaction test Date: Mon, 10 Jun 2024 20:02:00 -0700 Message-ID: <20240611030203.1719072-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240611030203.1719072-1-mcgrof@kernel.org> References: <20240611030203.1719072-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Stat-Signature: ojb5hc8hhr63zn3kixzysid5yrzgj3m5 X-Rspamd-Queue-Id: 6A706C0009 X-Rspam-User: X-Rspamd-Server: rspam05 X-HE-Tag: 1718074929-614954 X-HE-Meta: U2FsdGVkX19ocfTfS5vGa4TFEGl/gCkoI94nd9jIzjLDi50ughIpUzHeGJ8pYGMaJ6UuJmwHVbdtZehaJk5GH6WcxZjOZ43H7EySMJ6Z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7pDNqPg76rM8W+qLHJm3i3Yk1fJ4x+YisycEzLG3bZzYXvaVFepOkTRePK3fH/J9nXmHaj/eq2Up94ZirsZTTPXZrojB4NVr+HLI9a6CYNQSVzNItjr2wiojkKL436O2RMdxpCD7vIaB+mgc7MdKLZBEVkdtnNs5j1U0OcHq/Xlp1WivivA3OZ4cXaWhv5bLeY6da5Xr2c9pr0f5fWzUr05V7JnZDo8qi5Av6ERw2wQUfFjmTbKiyhG2OEOeF/v X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Running compaction while we run fsstress can crash older kernels as per korg#218227 [0], the fix for that [0] has been posted [1] that patch was merged on v6.9-rc6 fixed by commit d99e3140a4d3 ("mm: turn folio_test_hugetlb into a PageType"). However even on v6.10-rc2 where this kernel commit is already merged we can still deadlock when running fsstress and at the same time triggering compaction, this is a new issue being reported now this through patch, but this patch also serves as a reproducer with a high confidence. It always deadlocks. If you enable CONFIG_PROVE_LOCKING with the defaults you will end up with a complaint about increasing MAX_LOCKDEP_CHAIN_HLOCKS [1], if you adjust that you then end up with a few soft lockup complaints and some possible deadlock candidates to evaluate [2]. Provide a simple reproducer and pave the way so we keep on testing this. Without lockdep enabled we silently deadlock on the first run of the test without the fix applied. With lockdep enabled you get a splat about the possible deadlock on the first run of the test. [0] https://bugzilla.kernel.org/show_bug.cgi?id=218227 [1] https://gist.github.com/mcgrof/824913b645892214effeb1631df75072 [2] https://gist.github.com/mcgrof/926e183d21c5c4c55d74ec90197bd77a Signed-off-by: Luis Chamberlain Reviewed-by: Darrick J. Wong --- common/rc | 7 +++++ tests/generic/750 | 62 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/750.out | 2 ++ 3 files changed, 71 insertions(+) create mode 100755 tests/generic/750 create mode 100644 tests/generic/750.out diff --git a/common/rc b/common/rc index e812a2f7cc67..18ad25662d5c 100644 --- a/common/rc +++ b/common/rc @@ -151,6 +151,13 @@ _require_hugepages() _notrun "Kernel does not report huge page size" } +# Requires CONFIG_COMPACTION +_require_vm_compaction() +{ + if [ ! -f /proc/sys/vm/compact_memory ]; then + _notrun "Need compaction enabled CONFIG_COMPACTION=y" + fi +} # Get hugepagesize in bytes _get_hugepagesize() { diff --git a/tests/generic/750 b/tests/generic/750 new file mode 100755 index 000000000000..334ab011dfa0 --- /dev/null +++ b/tests/generic/750 @@ -0,0 +1,62 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Luis Chamberlain. All Rights Reserved. +# +# FS QA Test 750 +# +# fsstress + memory compaction test +# +. ./common/preamble +_begin_fstest auto rw long_rw stress soak smoketest + +_cleanup() +{ + cd / + rm -f $runfile + rm -f $tmp.* + kill -9 $trigger_compaction_pid > /dev/null 2>&1 + $KILLALL_PROG -9 fsstress > /dev/null 2>&1 + + wait > /dev/null 2>&1 +} + +# Import common functions. + +# real QA test starts here + +_supported_fs generic + +_require_scratch +_require_vm_compaction +_require_command "$KILLALL_PROG" "killall" + +# We still deadlock with this test on v6.10-rc2, we need more work. +# but the below makes things better. +_fixed_by_git_commit kernel d99e3140a4d3 \ + "mm: turn folio_test_hugetlb into a PageType" + +echo "Silence is golden" + +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +nr_cpus=$((LOAD_FACTOR * 4)) +nr_ops=$((25000 * nr_cpus * TIME_FACTOR)) +fsstress_args=(-w -d $SCRATCH_MNT -n $nr_ops -p $nr_cpus) + +# start a background trigger for memory compaction +runfile="$tmp.compaction" +touch $runfile +while [ -e $runfile ]; do + echo 1 > /proc/sys/vm/compact_memory + sleep 5 +done & +trigger_compaction_pid=$! + +test -n "$SOAK_DURATION" && fsstress_args+=(--duration="$SOAK_DURATION") + +$FSSTRESS_PROG $FSSTRESS_AVOID "${fsstress_args[@]}" >> $seqres.full +wait > /dev/null 2>&1 + +status=0 +exit diff --git a/tests/generic/750.out b/tests/generic/750.out new file mode 100644 index 000000000000..bd79507b632e --- /dev/null +++ b/tests/generic/750.out @@ -0,0 +1,2 @@ +QA output created by 750 +Silence is golden From patchwork Tue Jun 11 03:02:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13692787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F5D5C27C5F for ; Tue, 11 Jun 2024 03:02:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 776D56B00A7; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68D666B00AC; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B6C46B00A7; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 10B436B00A9 for ; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B2FBD8011F for ; Tue, 11 Jun 2024 03:02:10 +0000 (UTC) X-FDA: 82217108820.08.3393DD5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id 1A37E140004 for ; Tue, 11 Jun 2024 03:02:07 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1nxKK6ma; spf=none (imf23.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718074929; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wq48ve+ETB2Mn5jcdAIJQV5YnUUyrMAbtjA78ekOIig=; b=B2U2jUFAfhKyakW6kPEQ7R7wNTCa7dwkSPoZ8rYRMTRLfP6IGZoyJfGwbU1ZQ2PDXEdTdt l+9ZeYAJyRCy30M9nJrux2ZXVciEWTaTMvKXqDQ0F9A2MWEgiH2LOueYa8nKffe9hauljv taxPaSBP5jeTRUdyL8rmwNwJGoc3mJY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718074929; a=rsa-sha256; cv=none; b=e/fsKL3/u0zgl01qm/+sIsb+ga6o2yUc725gw7RaXkzshPgKK5y/uy6AQZHK4g4bGcv3A7 puMePqDc+iV8RyNegFqc+Szmg+4V4lDhpDouNcVj+nLmGO+SWbwE7bHFvvbGxMT7T5qQzF 97m+S1ll0goJZR2eLPOjDXX3fPOHvro= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1nxKK6ma; spf=none (imf23.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=wq48ve+ETB2Mn5jcdAIJQV5YnUUyrMAbtjA78ekOIig=; b=1nxKK6manx1sElDBoPJ7VtBtTY bUl6Pc/MH1Qn6kwApk0hinVfqNSWdsKqIzlEM2p3EQzLx3+mdr64EEK3kTORBMs/wLbe+JwHSlqPw 7K2R0BYtlhBN1yrZm01DqMGfYW6gCs1I1Fp83HBuwL+ZKzyFBQzugRo5+bmGx4EEbPZcuCYDis51/ 9NV7/SzoPtC++6KbL6T+xSZGXzIepu+cBx9E+VVrXDlLfs68ICpUjBBHggFw1nHVOMMvb6MRv/Pb2 bOLDveyc4g0PU3iWVttzZCynRA+DjXsCMNyBXzUf2J568Zh2aFYS/YqXR82J2UPRKGdpiaIY7LZ6k 3e2inVsA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGrls-00000007DDM-2LZP; Tue, 11 Jun 2024 03:02:04 +0000 From: Luis Chamberlain To: patches@lists.linux.dev, fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, ziy@nvidia.com, vbabka@suse.cz, seanjc@google.com, willy@infradead.org, david@redhat.com, hughd@google.com, linmiaohe@huawei.com, muchun.song@linux.dev, osalvador@suse.de, p.raghav@samsung.com, da.gomez@samsung.com, hare@suse.de, john.g.garry@oracle.com, mcgrof@kernel.org Subject: [PATCH 4/5] _require_debugfs(): simplify and fix for debian Date: Mon, 10 Jun 2024 20:02:01 -0700 Message-ID: <20240611030203.1719072-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240611030203.1719072-1-mcgrof@kernel.org> References: <20240611030203.1719072-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Stat-Signature: e8qay1qhsd1m3ocg7mr5uc9nqt1875j9 X-Rspamd-Queue-Id: 1A37E140004 X-Rspam-User: X-HE-Tag: 1718074927-295338 X-HE-Meta: U2FsdGVk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NJ1WpmLua5wwJrnehwHsx15FjoZkQ9xVQnGcc/4BxP48x5oqg3Fll6UJGIJ04qha+/KE6LWeN3QDxSOYi1tLWDXjUAag/XLxrxasp6kIvYOGeDfC5P+g0NGio12HANTRY2kxqc39ZMnJO5OSeUcjUGnDrNmC0gYZF0kPrz3HTBMP1oaDhrKnJIyyFMnA5aseNqWjjYUdwLCmyePRSXC2sqzYoq78J08+KehzaSHiZ6RCljlEbgbs6PnAXwd44nIxSjkJ24/EVDa/lnXP17wn+bgruMvt7trC+ZCjGxQqp+ETYe083Agy4caNyjr5ZkxQz2kWtIhno7N5VDAOyTyEAJ9EHle X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Using findmnt -S debugfs arguments does not really output anything on debian, and is not needed, fix that. Fixes: 8e8fb3da709e ("fstests: fix _require_debugfs and call it properly") Signed-off-by: Luis Chamberlain Reviewed-by: Darrick J. Wong Reviewed-by: Zorro Lang --- common/rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/rc b/common/rc index 18ad25662d5c..30beef4e5c02 100644 --- a/common/rc +++ b/common/rc @@ -3025,7 +3025,7 @@ _require_debugfs() local type if [ -d "$DEBUGFS_MNT" ];then - type=$(findmnt -rncv -T $DEBUGFS_MNT -S debugfs -o FSTYPE) + type=$(findmnt -rncv -T $DEBUGFS_MNT -o FSTYPE) [ "$type" = "debugfs" ] && return 0 fi From patchwork Tue Jun 11 03:02:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13692788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0839C27C4F for ; Tue, 11 Jun 2024 03:02:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A1F0D6B00A6; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D8586B00A9; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A20A6B00AA; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0F8306B00A6 for ; Mon, 10 Jun 2024 23:02:11 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B28CB14113C for ; Tue, 11 Jun 2024 03:02:10 +0000 (UTC) X-FDA: 82217108820.07.95644D3 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf18.hostedemail.com (Postfix) with ESMTP id 147971C000A for ; Tue, 11 Jun 2024 03:02:07 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=tyK80xDR; spf=none (imf18.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718074929; a=rsa-sha256; cv=none; b=yqMzjhW1y31vY3K1h8Yl43HZD070bAYJys0/1JstxHDDcp9oV3oQbBkRwmigawYO/y2gSp a28oX5EWreWB9QV/SKRjX2v9JPDf0/0RkPKkpJug65X4V3zdbCb7PGiZRhTgt5dMyvFM9o GcEJ4pYURs4PkScztkY66d5gJXF4y4g= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=tyK80xDR; spf=none (imf18.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718074929; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=w5upqqK3le9bkA35Adh9sB0Tb3TWHmZ5mS+iqjEKnts=; b=M919FRPfwhPlIJ0U5tPxl/eQjzADflfZ/8OlVNtcYvXRFfPq2Z3NpRwcxVMBDbDfeKt+Ks hHJmc58gA7OpzuN/yH7v+6CbUD/zoFtcqZS35hA4yi6SXRSI+nwLv4ZSQ/0euvhqUhsm5x JGyDX39qi2AOK7U/3aPzhuasE6lqtHI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=w5upqqK3le9bkA35Adh9sB0Tb3TWHmZ5mS+iqjEKnts=; b=tyK80xDR4FjkmXamvnGufFwee/ osrHpUf1HtQ7JnZlKRPjDbwP6VxoRLDshUf1idmTDgzPQ+o+IBHMJw4lIaXvBME2ey/SQOv4qJHE0 VoOAOYx1Dw7Xetp3OUDD8IhANx6OsQV38M5S+ialE3F3kBNW+2cWU/ynh9I7FtSqdx20fyr9ly/b/ JdZmLCHGKzswNupQYtEkfjAcNXED2JcUObhdgPkEmjgLTSmJm+An6HmkF8VY9B/DICy229Ek8ILcP /j/RAriVVoSgBiq96+VcYOrrOuvfIOEv2Q5UTveYEUa60fNtFjy28iq9i34Wl6bN+8AWd/CaiRwqx BaXeOayw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGrls-00000007DDO-2Yy9; Tue, 11 Jun 2024 03:02:04 +0000 From: Luis Chamberlain To: patches@lists.linux.dev, fstests@vger.kernel.org Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, ziy@nvidia.com, vbabka@suse.cz, seanjc@google.com, willy@infradead.org, david@redhat.com, hughd@google.com, linmiaohe@huawei.com, muchun.song@linux.dev, osalvador@suse.de, p.raghav@samsung.com, da.gomez@samsung.com, hare@suse.de, john.g.garry@oracle.com, mcgrof@kernel.org Subject: [PATCH 5/5] fstests: add stress truncation + writeback test Date: Mon, 10 Jun 2024 20:02:02 -0700 Message-ID: <20240611030203.1719072-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240611030203.1719072-1-mcgrof@kernel.org> References: <20240611030203.1719072-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Stat-Signature: iagsewa8t6khshq4fawkdkmxzqcxd7gz X-Rspamd-Queue-Id: 147971C000A X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1718074927-440160 X-HE-Meta: U2FsdGVkX1+dpbcLaFYy6/kkbc1gy+B/Ys034DSGMI2nHaWZEoCpIgz3IZFYjAa9DzMrMpn09yLlqSZy83U3yRuGqVE6n7Q9UVEVgTHJXgc3Q9CJK+tzSBG5KqEi/t/b0bhA9IVsXWC9nnG/8UVtKGdwTwM1CTXsq51LHpcSMicMlanRO4h3LbLpYjW9ZgLPyJxK+b8yvUwhqVKBjEwjB09Y9/YEPdWL+mHM67YhFVAOkL1dpjSH0Dl4oRY4cEUY7hmkkpdpDZAsSIVyRN9nPUj6rR6Y83rOyzfF0C2n93Sx0WSY8FOz+X7+r/5sBIFNMOnlUKtuWR9rQCoVRUoRx+Ml5unXuUFUHfvS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-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Stress test folio splits by using the new debugfs interface to a target a new smaller folio order while triggering writeback at the same time. This is known to only creates a crash with min order enabled, so for example with a 16k block sized XFS test profile, an xarray fix for that is merged already. This issue is fixed by kernel commit 2a0774c2886d ("XArray: set the marks correctly when splitting an entry"). If inspecting more closely, you'll want to enable on your kernel boot: dyndbg='file mm/huge_memory.c +p' Since we want to race large folio splits we also augment the full test output log $seqres.full with the test specific number of successful splits from vmstat thp_split_page and thp_split_page_failed. The larger the vmstat thp_split_page the more we stress test this path. This test reproduces a really hard to reproduce crash immediately. Signed-off-by: Luis Chamberlain --- common/rc | 14 +++++ tests/generic/751 | 127 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/751.out | 2 + 3 files changed, 143 insertions(+) create mode 100755 tests/generic/751 create mode 100644 tests/generic/751.out diff --git a/common/rc b/common/rc index 30beef4e5c02..60f572108818 100644 --- a/common/rc +++ b/common/rc @@ -158,6 +158,20 @@ _require_vm_compaction() _notrun "Need compaction enabled CONFIG_COMPACTION=y" fi } + +# Requires CONFIG_DEBUGFS and truncation knobs +_require_split_debugfs() +{ + if [ ! -f $DEBUGFS_MNT/split_huge_pages ]; then + _notrun "Needs CONFIG_DEBUGFS and split_huge_pages" + fi +} + +_split_huge_pages_all() +{ + echo 1 > $DEBUGFS_MNT/split_huge_pages +} + # Get hugepagesize in bytes _get_hugepagesize() { diff --git a/tests/generic/751 b/tests/generic/751 new file mode 100755 index 000000000000..7cc96054a5a9 --- /dev/null +++ b/tests/generic/751 @@ -0,0 +1,127 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2024 Luis Chamberlain. All Rights Reserved. +# +# FS QA Test No. 751 +# +# stress page cache truncation + writeback +# +# This aims at trying to reproduce a difficult to reproduce bug found with +# min order. The issue was root caused to an xarray bug when we split folios +# to another order other than 0. This functionality is used to support min +# order. The crash: +# +# https://gist.github.com/mcgrof/d12f586ec6ebe32b2472b5d634c397df +# +# This may also find future truncation bugs in the future, as truncating any +# mapped file through the collateral of using echo 1 > split_huge_pages will +# always respect the min order. Truncating to a larger order then is excercised +# when this test is run against any filesystem LBS profile or an LBS device. +# +# If you're enabling this and want to check underneath the hood you may want to +# enable: +# +# dyndbg='file mm/huge_memory.c +p' +# +# This tests aims at increasing the rate of successful truncations so we want +# to increase the value of thp_split_page in $seqres.full. Using echo 1 > +# split_huge_pages is extremely aggressive, and even accounts for anonymous +# memory on a system, however we accept that tradeoff for the efficiency of +# doing the work in-kernel for any mapped file too. Our general goal here is to +# race with folio truncation + writeback. + +. ./common/preamble + +_begin_fstest auto long_rw stress soak smoketest + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -f $tmp.* + rm -f $runfile + kill -9 $split_huge_pages_files_pid > /dev/null 2>&1 +} + +fio_config=$tmp.fio +fio_out=$tmp.fio.out + +# real QA test starts here +_supported_fs generic +_require_test +_require_scratch +_require_debugfs +_require_split_debugfs +_require_command "$KILLALL_PROG" "killall" +_fixed_by_git_commit kernel 2a0774c2886d \ + "XArray: set the marks correctly when splitting an entry" + +# we need buffered IO to force truncation races with writeback in the +# page cache +cat >$fio_config <>$seqres.full 2>&1 +_scratch_mount >> $seqres.full 2>&1 + +# used to let our loops know when to stop +runfile="$tmp.keep.running.loop" +touch $runfile + +# The background ops are out of bounds, the goal is to race with fsstress. + +# Force folio split if possible, this seems to be screaming for MADV_NOHUGEPAGE +# for large folios. +while [ -e $runfile ]; do + _split_huge_pages_all >/dev/null 2>&1 +done & +split_huge_pages_files_pid=$! + +split_count_before=0 +split_count_failed_before=0 + +if grep -q thp_split_page /proc/vmstat; then + split_count_before=$(grep ^thp_split_page /proc/vmstat | head -1 | awk '{print $2}') + split_count_failed_before=$(grep ^thp_split_page_failed /proc/vmstat | head -1 | awk '{print $2}') +else + echo "no thp_split_page in /proc/vmstat" >> $seqres.full +fi + +# we blast away with large writes to force large folio writes when +# possible. +echo -e "Running fio with config:\n" >> $seqres.full +cat $fio_config >> $seqres.full +$FIO_PROG $fio_config --alloc-size=$(( $(nproc) * 8192 )) --output=$fio_out + +rm -f $runfile + +wait > /dev/null 2>&1 + +if grep -q thp_split_page /proc/vmstat; then + split_count_after=$(grep ^thp_split_page /proc/vmstat | head -1 | awk '{print $2}') + split_count_failed_after=$(grep ^thp_split_page_failed /proc/vmstat | head -1 | awk '{print $2}') + thp_split_page=$((split_count_after - split_count_before)) + thp_split_page_failed=$((split_count_failed_after - split_count_failed_before)) + + echo "vmstat thp_split_page: $thp_split_page" >> $seqres.full + echo "vmstat thp_split_page_failed: $thp_split_page_failed" >> $seqres.full +fi + +status=0 +exit diff --git a/tests/generic/751.out b/tests/generic/751.out new file mode 100644 index 000000000000..6479fa6f1404 --- /dev/null +++ b/tests/generic/751.out @@ -0,0 +1,2 @@ +QA output created by 751 +Silence is golden