From patchwork Sat Jun 15 00:29:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13699197 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 B7F74C27C6E for ; Sat, 15 Jun 2024 00:38:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D87A16B016C; Fri, 14 Jun 2024 20:32:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AF666B0171; Fri, 14 Jun 2024 20:32:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAA936B016E; Fri, 14 Jun 2024 20:31:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E7FBB6B0266 for ; Fri, 14 Jun 2024 20:29:43 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 9EB0CA2127 for ; Sat, 15 Jun 2024 00:29:43 +0000 (UTC) X-FDA: 82231239846.11.164FA00 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP id 125C540002 for ; Sat, 15 Jun 2024 00:29:41 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ivWZ2hSG; spf=none (imf11.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=1718411379; 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=7tr+VAt/VPGCgpSRMR8yi7xw9PLDWB0hThmICKV/0J4=; b=8Us7JZEgMs/0HxxbZxZLo8NYXYbya/11mbOzyybOfPp7iDdnSI+Sk2WGAYrw1i/xxPYpup ODk9skEnbgeYokFpH39euibcfZNT+5uvfhhiDELnaF6fvKN/UJDNfxVnF0dhTvliMXZPaf ytH1QYQ8QQmLe01M6Gi4u+iwxM5bb78= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718411379; a=rsa-sha256; cv=none; b=5FBL4ujUjktIn9Uru3GoAqiPJ0iqFTG8O8yhtkNNzBZyOaUp0qorDE+YucCb+MY+NiC5mq 7fzqA1Zs1Og2yXm7RS01ESPn7WDVbNOXHoKrClTJ+tDV9l+JHqxQPD26e5A4ObGtjzLicZ +RGNy06Umyc/ohfMr5LitqvHINiOlPI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ivWZ2hSG; spf=none (imf11.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=7tr+VAt/VPGCgpSRMR8yi7xw9PLDWB0hThmICKV/0J4=; b=ivWZ2hSG8ZKwP7fFVjGd1XYOM2 NVjY6JTV4uvms7kpXWLbOIZJE4j2Bl8KCRcs7ua+7wg9AxO1tVPSpjYk12PKR3ADghR6XqylLEl8C hBhSmojLlpSCJpZcTYNQVDzjAFtwWXFQFEvmPvixUSScnAMe3uEWXMCQ5Dh8oZpR0qY8T1Xpx17Th RZ+QtX9426rYymJ3iUWg6rxdFjRBh8nJpKmEosAF6ET+ffK3p+JKXPeGYFa4m7gsUBLAv6/m8VQ6G 7JMWxzu1mlTLFw7JCura3zeNhkuwKl9EbVWd5hJRuFAvBbkAUi0g+bz1gqKyNShHkQ304jiZKNjSh qo0KzjmQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIHIV-00000004KkI-3ZVc; Sat, 15 Jun 2024 00:29:35 +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 v2 1/5] common: move mread() to generic helper _mread() Date: Fri, 14 Jun 2024 17:29:30 -0700 Message-ID: <20240615002935.1033031-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240615002935.1033031-1-mcgrof@kernel.org> References: <20240615002935.1033031-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 125C540002 X-Stat-Signature: wge454j5t5mp713gk6ksog4pojtojfem X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718411381-695695 X-HE-Meta: U2FsdGVkX1+K3JO7vb8+5ypXdVgvvs7tBlPdvvnuBi0dsyCcHqMeHA43nujLkEeJIk8ogNIV6lJuMZkD8H2qbFfhuneZZc/3chQ9DTmmwduZL0Z8Dt1/svAnWInkxFgT4NOyTZz3ldpy9oRigwE3RIbJoDp0LA9NVqE4r/H0VpDVobOVPzwqeUpmnMuoe5M67VyCYiLJEceiVVyvAyL8Jx9WOusU3iclluvFqWjgqSDdSFhuFOzfLHP5JpBX0R+t41+rX87xw243ylNzbHJrxEki0MelbAn1E+Gd1ydm3290hTXMdlTuIIAiSp/y/M3VVvgHECisS6IX9HK9qb6+bV1yLmktXe7Dx8r9iES7Byms+1WZVcXlt0VuYhXkTrC+lLH31Cw7/b85k2lM1/TeNr+sjwqOevwyyXyGLjebRVGdm5mtoYSdvugcooRFhSGc+gAxDnlNA+7WUUCMATnQJ49Na/qrr1nulhlD9gRM6EElKaS/kO+NqfeWXKws5XeGPAXmWK/2QdxcJGwaYJJb0Z20ftfq3g+ySza4wm1vmLAO570AUAP6DlKAvBNR9fenkp6s4CC/bWeYAb/tW+/635Yjq+uafkuLvTMi8SwMS0j3/MsiGODgIMNmQcFqtfqGxyCThIOowbo5uehkyVF0GSrvJmCQleEt3euHASf6ZUchwUT9LN/k3bCwpJuFEZUX/WiVw9Mb+zV0FCfIOMRxJJ/6ek9sEyO1AtfW7pALwkU/JYOHjClGFAfXBbxpsk05BxW/jRGimlsC0OqQXJ0MZ+X9ptX3+yBK2PRW5AaRHElgdV0nFWdzUPTI9k3zhTzrIg2gaejV81EVIZ7Xu7Xw8z7TcTDtWjq+dxgSjtgzuO0mdKy4ws/1NAIY/Da0phRi+QA0GqDk3cf+8A27EoSPbBL8anh14NrBHKu51cLI79/31Xnlh/t/0N4SUvQl9jee3/Lw8NEaH1j26E0zaoh Ba8iIHl1 veT/p9/dh+H+XPduSPXDawjQKdfIOsmum8sDYr4pYrnrTjI5BbLL5Bnq2RWsEY3ciwjjJZhNk+RWC2Q0ycYOZz2A4rETwRxxOHnzV2IfuLWD+xZcDrvgRIfXG7SE/5fRExPVvVrDteQdTqkNH4HlRvuDF9d73DEllLHb+pS67kwm9EkWUr+A1u1xl36s329eDunn438g8oQdhfDXKSTHqK6XoM0Ofwx0U+yWPk9xI6D5UDGpIEqyUws4ozvfr2hCGQAACo43kYQz7J23rycxkmMEbuZXc0kmaHS9FgQtQ3IMzlh3xWUnjNkji0TDX/icGCufEdtrFi8TR5A9EQ9k9Z0LwDr+kcIfxztg7e3H/toQxMOHRDfXa5MUjKCQIjRAn4ewqYC4QX1MuVtPoRsNRUdqsV/be23ttyMxsc+rL2IXjQfWgfydoolRzOh5zRzjpQ0w7fq0yj9lrSzoZlXaZSuH1Ex4SPUnCbZtj 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 Reviewed-by: Darrick J. Wong Signed-off-by: Luis Chamberlain --- 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 Sat Jun 15 00:29:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13699195 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 1BE07C27C6E for ; Sat, 15 Jun 2024 00:37:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0027F6B0160; Fri, 14 Jun 2024 20:32:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A907A6B0171; Fri, 14 Jun 2024 20:32:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5052C6B0160; Fri, 14 Jun 2024 20:31:59 -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 022C76B0269 for ; Fri, 14 Jun 2024 20:29:43 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AA36C409AD for ; Sat, 15 Jun 2024 00:29:43 +0000 (UTC) X-FDA: 82231239846.08.DBD10BF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf13.hostedemail.com (Postfix) with ESMTP id 0DDC920002 for ; Sat, 15 Jun 2024 00:29:41 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=0kfkb99+; spf=none (imf13.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=1718411380; 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=a0YpzQbc4885wTLRBldgc5txs7sG8X1GDE95bq1YM1o=; b=eNSfa3kLRbg+mXcKZ79y6qH5efLJJOTT9R2cnj+jZ3QcPGxTghQ+e3TQJoh3px3X4lgbi1 8ceZWm2y8xQOxZfIVWdMaz+teNWKDUknXXSOc/ZeMoeMVJGFRu4TqXMhqPQwFFkcTd5ltl 1b3B+rWckt8PWOJ1aCtHwms4OW3xxkA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=0kfkb99+; spf=none (imf13.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=1718411380; a=rsa-sha256; cv=none; b=RXBVU+GGK1bQLhmvCG2tfcMcwQUAy+agj5EEc3W7hv0BzcS/72rDTlBBHXIDQ9R/B9aOZr zaTdBwu59QfHXQuzOYA3FODKGnOrqde3DnW2vapGML2+aNWxv+Su7cVyZwEBzJmN+taEHY iq9MR4sN1YLLdg2Cj23BpiYox8mr+OE= 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=a0YpzQbc4885wTLRBldgc5txs7sG8X1GDE95bq1YM1o=; b=0kfkb99+FjH5kDAj9MYM1I5d6l jxeaINq1pFg29cDb6SWS5Mdj5UAPGdQhfM0n6hA96InSW1APdhTHyO9HKA5OoJpIRk6TXZiFMa5FU IKDvjyDnCDwl/MX3R3pCEspPjlx4FrEvw9gvJoqCY47hwjymTZzRIFFONZA2aaoUYwZ47llbJGmhP BtGqL8QBWjaPVCbr0LVfJSzBtbWVoeN10ftF3Hv28gm0O6PA+f58FXGiCfg3Rq4F7w7m8RLd72Ubs l6SviYbhycAp+fpceBqSuUwYnwQ4zb/46ljGXve83eSSUp+W5WlcBWrbz3GzSrWTud+PYMEpDtwLr wRJ8oKyw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIHIV-00000004KkK-3mPB; Sat, 15 Jun 2024 00:29:35 +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 v2 2/5] fstests: add mmap page boundary tests Date: Fri, 14 Jun 2024 17:29:31 -0700 Message-ID: <20240615002935.1033031-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240615002935.1033031-1-mcgrof@kernel.org> References: <20240615002935.1033031-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 9gisopkt3dk76y5bzp6z4kc1d69cdj8c X-Rspam-User: X-Rspamd-Queue-Id: 0DDC920002 X-Rspamd-Server: rspam02 X-HE-Tag: 1718411381-969860 X-HE-Meta: U2FsdGVkX1+13KhOvDnzppVf8VQpWv5TngMtM3CYwjSnCcJkQsm4c/Y2KLcF/W5Cyg0uySBPrwlA55plszN2MIFS0DdR428Otwz9woIDbVL5ZIbRG8UQ4ufX8OM7q7N2TDKJ1wgMs/jf4+ghiJD98C32S0PGvPwK1U3abPwaoN8SxL2aKPQV0AX0lrGIgPGO9AyI5Ieu+ye9a9tDP8G5Q9a4qBZq13XUDzCLI0bqNnHoz7OLbvpFnGZkdvrMl/Rd/bVyawRW30xObjvWJC7Dr5Bvp30bYSs3C5F3cFWyf3xxpV7SgpCKN+BDf38DZeGtpFntcnz/wMJ07Gl8LcfhDDgQXdA8aosu3s54snkjAgB+lkgAvdTZGDmhJbtzEHYrnB/lgGYGb3vJ2NBsJrBzkWEJOGQX76Y27/5HFrFEtr3sU2M3Lu53bM76Hp9Q1RU0WAiViC1CLy7xOporPqztG1RUo/XlUKNdjS+tLeKJ9klVMQn/U67A7PFZmwsIoU1OXc01pWuYotfsfppAO68agOTxNFrEcxrxdPYe0UQr6Bi0G//+eHcP2pgkpTR5V8gzxP574uadL6lpWBa0FyyAz5Eaic8ZA/dtzRV53PkN5jhvs4uYc5OgxAAgUJU/zlU939s2KlsSy0AR1PPa+r7QRh+DwiVH+leXWpryMv1GZr8JV9ZDeFmrs29abRcvyw7tPizsG5OTloHkSQk07bVEzFgtvMzvnNs1njh/2iibQqL1m6LY+3S+cko+hKxdswh9MRrvQvwu4AYu+S4LLViBNJ8wZDVzjsbgYX2bt1Mr8lP/XdzywJEBlXfbXKsRYLX2dvbSrMvc+CDRguCV5BpIZQB5vkBQ83qYTfGFG36Nmv80hUnkLaE8lVtHX0gW/CumIZtI+HItS40yCozgsPwaFjFE/rF0V6dLt1WZgzOdqWs8uLJnWoEt03BWvlLXyB/9OaeamCUxFOt/zuxQ+ec OTlSxMJN XA6Nd4bmtpuUQQUZqjzqXNV1DqWBFcKOsf19OGYg8EjYbANnS0EnuCZd9bS5ktdCiEf3h4OZIDSLIBxppvlyjd+rc6ADhbIPjirt1SPUSMEYKMcjbwnCcvrXc8inEcFnu7VcUk+EiDzwawSooBTKa2KPWanAPaPp7fj7GczD51cGC4BpP5m6kJTHdqkib0gGP6avfKVVCWMyidvV4dDOYa8MCkswuqBbyUwaY9eARGGchhpIpV7NdaeeR5yTIvAt9fb5AdzE5F53c3fvkZYQ+/9yvxuJxhtVVPtkmb39a55bRMFRsjaRNnz50U1h6sMagYOTlv+tQk7P45f8hwsYOTjRUzJRl5RgnlWCKzRW/KSE3a9wToOTAByrYkgl2PEwgOpxBKnSjM6eWhFF8z7y+ZCTxZY1kkOnDfYH8Ha7ZrDuq88yDFiW3IkVfLzIkpc1RcDmgNpASZ7jzBy1cE23dVjUwHcwTD5fIVW2Vu6ubH8LVNzskzy+v3/PO/WByB8nYY4tPEMJXHsTH5T+7j75/ztbm0lkdd3B9UN8m 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 on a 4k base page size system, on 64k base page size it does not fail. The pending upstream patch "filemap: cap PTE range to be created to allowed zero fill in folio_map_range()" fixes this issue for tmpfs on 4k base page size with huge pages and it also fixes it for LBS support. Suggested-by: Matthew Wilcox Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain Reviewed-by: Zorro Lang --- common/rc | 5 +- tests/generic/749 | 256 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/749.out | 2 + 3 files changed, 262 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..2dcced4e3c13 --- /dev/null +++ b/tests/generic/749 @@ -0,0 +1,256 @@ +#! /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) + local failed=0 + + 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 -f $SCRATCH_MNT/file + + # 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. As per mmap(2) subsequent mappings *may* see the modified + # content. This means that it also can get other data and we have + # no rules about what this data should be. Since the data read after + # the actual object data can vary this test just verifies that 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 + let failed=$failed+1 + echo "Expected data: $expected_zero_data" + echo " Actual data: $zero_filled_data" + echo "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 + let failed=$failed+1 + echo "Expected csum: $csum_orig" + echo " Actual csum: $csum_post" + echo "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 + let failed=$failed+1 + echo "Expected file length: $new_filelen" + echo " Actual file length: $filelen_test" + echo "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 + failed=1 + cat $tmp.err + echo "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 + let failed=$failed+1 + echo "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 + let failed=$failed+1 + echo "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 + let failed=$failed+1 + echo "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 + let failed=$failed+1 + echo "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 + let failed=$failed+1 + echo "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 + let failed=$failed+1 + echo "Expected SIGBUS when mmap() writing beyond page boundary" + fi + + local filelen_test=$(_get_filesize $test_file) + if [[ "$filelen_test" != "$new_filelen" ]]; then + let failed=$failed+1 + echo "Expected file length: $new_filelen" + echo " Actual file length: $filelen_test" + echo "reading or writing beyond file size up to mmap() page boundary should not change file size" + fi + + if [[ $failed -eq 1 ]]; then + _fail "Test had $failed failures..." + 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 Sat Jun 15 00:29:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13699193 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 6A735C2BA12 for ; Sat, 15 Jun 2024 00:37:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D42836B015E; Fri, 14 Jun 2024 20:31:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F4A36B0162; Fri, 14 Jun 2024 20:31:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B74316B015A; Fri, 14 Jun 2024 20:31:58 -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 B3F966B025B for ; Fri, 14 Jun 2024 20:29:43 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 612ED1208DE for ; Sat, 15 Jun 2024 00:29:43 +0000 (UTC) X-FDA: 82231239846.19.017317C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id BA5D5180009 for ; Sat, 15 Jun 2024 00:29:41 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=BoLCf2GR; spf=none (imf16.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=1718411379; 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=l0z7gTm6DMRVo2mw+7Jc7hKaTrGpQ1Z5iRpAq1N5ksU=; b=1h+UlLHGtxt3Bx3V4YyW/Yzr7bbrZ/tGnQGJq5BNQKEf/zAbHoY+Ls7LB4zj8SAFfMwHN8 WYPdAvNWIM4hJuqkznlrlJTdlmDPKheGTYjwvHWoUXXyrd9BBYxf51b+dEwxi9UgvXcSHw 2u68OudUtjoJPYiPPKouzTv+vsk3Vxc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=BoLCf2GR; spf=none (imf16.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=1718411379; a=rsa-sha256; cv=none; b=EItsko1NEnvzWrw/tQioBOwnZIYPVhtP4RW4F/UjoKQJK5+ILduQQ80bg7IcDOVsFbzW5F fOTjLpN1ArFvZAwPaXof5nnvDCKEtlxlLLxCuiSP1X0/h1tgXXMeKDehInXkAmN6vOuPhC 5y6pxD/FgZ/YjFjk/Sn84foEUFS6Mfc= 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=l0z7gTm6DMRVo2mw+7Jc7hKaTrGpQ1Z5iRpAq1N5ksU=; b=BoLCf2GRTuS3TDDx+N0sqtHOuE obVfJenx066vHCWHo0iL99RY43disTNPjvUf5s3usD1XMVffXlTQTleYtPmVtxQfsrFMNG6Ue11I1 lndSHHge44PxADFi/ZwWpBdN0slBgQ9j28SAmWLRdAc3tnNnShfaMZbGTdOXNtSmf3QD9QN5IMhwQ dq/NDGbnjn4O52QDb+7dQVwmQ/tr+RQMwhdHRTA0spSbPIMNCG5Ky7zNdKIEHxhEsZPNlZq7VMsbt zadWqoTxH8hz+KK+Qd+rcq320hEV20LvXY9/QNZPu/YkuoDtBxdKUjx/CKFhG+wGjGDvciuxznIoB G0KJhXmA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIHIV-00000004KkM-3zHu; Sat, 15 Jun 2024 00:29:35 +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 v2 3/5] fstests: add fsstress + compaction test Date: Fri, 14 Jun 2024 17:29:32 -0700 Message-ID: <20240615002935.1033031-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240615002935.1033031-1-mcgrof@kernel.org> References: <20240615002935.1033031-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Stat-Signature: ga5g51gc6zgoe18km1qpdcsmuuqwsbbw X-Rspam-User: X-Rspamd-Queue-Id: BA5D5180009 X-Rspamd-Server: rspam02 X-HE-Tag: 1718411381-547103 X-HE-Meta: U2FsdGVkX19cyTyOzPKBg7pOYLgiNkWyKv7nzJJVWkM11NetgH755poPaaqgvwMa+/57uSNNbUwGbeL9+vq3KK5K5+cO2KGGZuctVJ/JpwbT8qybXJr4s2W7zYiNSCjqy9mqvrpL2sstkNcoYmb/xPQ+Nk4vLSl2So7kA21CwtMGBXXvMb0Y1uKxjZ8oIQhRFq1XBX7Rgl4VnnEyfBRkLtA0g+qWfwilDHZ/NjClr2VmBG11g8IqxqRqd7iqCD21AArkxmAAPFDwE+duu3pteJ6XuGICjpoZbMpMHJ6x96ZrZj8e37zx7H9L5dnAOwjJ/blu7oQ8Mst7WhUYg/0vTp8eVruOYnZkVfPC+SZniQ7T7/a9mty+8fWuOaFIn8vvWdrhA6q1jeGDXuwq5Qr4ReD/3hgz3GdoW63ZpRfG9B983Y5feTLcy390xtkC0TXPdrNoiI697mcnST9F6dADME7FEKmUHelinZSOsynbnx+FTR7ZA1r5YeUW8eC7P5boiTs49aIGuipVpOKgehgshFUTtDOFe3StmB386/ZUrcSqXeO2EiGegvQSS1VTKnjt35ybT2+rw6iHkxstvLz0dF5qxX6jAKAuWVseYuQifWTOBS8SfQf4T/92W+PJjEu8T3A031S2iFopS5ZWxmrGpm8AXt/UPrukg7abXHk8EXmMsKPmEvXnx6BKuR5PLLAVTO4gfVIA6SZ2VdIi1SxVBj0CJ9bTPJBtVXHf2mPg3Fu4uyq/JuOcGz9SIcnGIPm0K6VjMduydCWY+j5aojQOlZh26j2y2I4c/JQX7EJ4ky7tqrFWnj0xhBpiRlttWPOXreemEEKh2jvD8e1jy56Lq5FlpW1xDOYNLSj2xLZbvanI00iFvjTj/I+2w0kONe/91EjuZKG4WpyUyaTjM4OChPg+UeHzTqYjcbSd6hyEyIOghEMY5fyb6aEnaFCTGQ1n0a2jNJH4CVuGN+4tvu7 Q0YwJ4aK wZzuYbC/q+DmuEHzM91dQ3GJ5K/bIoKXh2zhU+vxcgfgtlaH1pFq2Cp0RU5mXF3Eu3wyjASIIRFwx0wAiPKPBvKh1NbOliLICj6ex6mw605V/+AJtveh13RFD0Fu/Vwx9KlIVPo6d77VzlDAoaohcN0jIUNjfbsIBRBBJKJrznhBDfZzNrpNmwVfgeCjiWMTLbZRGyCvbHvHE2XptEcyw3iM8HzvRiHpuyS+EtfzKphnN4xHcDzvg7/Yxp4o+T0xrEWYoRWSl6p9qhO6RQGeqq4hAQhj7OJPxBDQGX5daT2pCkW67xBk0iCSw/ZSCclj9ssQXL6AT6RvI62TFm3CCNgfMdn8ToIfYGeEOP4gye1JV68F3ubMql9zsMjPW1K4mfHU1XEiyvcZRwLHQzdcEt/LXZRjz4dfTBAkzarB3D1pfTfTZUuYsm+GiNb8LNOJt+b+YHVBvomHxgfvWgCML5Owgut1ggBiLpPgN 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"). This test reproduces that crash right away. But we have more work to do ... 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 through this patch, but this patch also serves as a reproducer with a high confidence. At least for XFS running this test ~ 44 times will deadlock. 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. [0] https://bugzilla.kernel.org/show_bug.cgi?id=218227 [1] https://gist.github.com/mcgrof/824913b645892214effeb1631df75072 [2] https://gist.github.com/mcgrof/926e183d21c5c4c55d74ec90197bd77a Reviewed-by: Darrick J. Wong Signed-off-by: Luis Chamberlain --- common/rc | 7 +++++ tests/generic/750 | 63 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/750.out | 2 ++ 3 files changed, 72 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..3057937d7176 --- /dev/null +++ b/tests/generic/750 @@ -0,0 +1,63 @@ +#! /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) +test -n "$SOAK_DURATION" && fsstress_args+=(--duration="$SOAK_DURATION") + +# 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=$! + +$FSSTRESS_PROG $FSSTRESS_AVOID "${fsstress_args[@]}" >> $seqres.full + +rm -f $runfile +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 Sat Jun 15 00:29:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13699192 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 37B3CC27C6E for ; Sat, 15 Jun 2024 00:37:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2BA976B0154; Fri, 14 Jun 2024 20:31:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE7CE6B015E; Fri, 14 Jun 2024 20:31:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CB8A6B0154; Fri, 14 Jun 2024 20:31:58 -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 511276B026A for ; Fri, 14 Jun 2024 20:29:44 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DC2F58097D for ; Sat, 15 Jun 2024 00:29:43 +0000 (UTC) X-FDA: 82231239846.29.D9B6CF9 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id C8E9940004 for ; Sat, 15 Jun 2024 00:29:40 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sQQroqgX; spf=none (imf17.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=1718411380; 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=N5wlEbcwTNotl6BI6h68OGk4bntX7UNNJ7n+lTWI9O0=; b=iGY1dHm89z+8G0MWnaOPFfZSwOBJoD0FchqZZWkp8B6pZQm6x3kwvM4XBGW2msVcilHvOH okIr+8vcJwBsBwy6kdSD2M5HoLHjUGm4MygcwupKxFW5fqf1OyJ/K3cXAlAvLbwF3ACwj9 OvUJ/Qhv5LRvA5ZOxkb1EzTcVyAx4Ys= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=sQQroqgX; spf=none (imf17.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=1718411380; a=rsa-sha256; cv=none; b=1eGmuJDFmbfEWYeZihRb7qUZ9KYk4zE9v+1/bPPRYRIY9xMtqWXKL6yY2YCcsQFlTowGjh WRx3LZ2ALwFV2myQQoxF5xTKuBZ0hA8ZZhMEwdcuXzv69+vyZeGxf+X14ZAr8xeCBzXCJ1 dQqAVRZKijx7v2vEQse37EyriAfLrLY= 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=N5wlEbcwTNotl6BI6h68OGk4bntX7UNNJ7n+lTWI9O0=; b=sQQroqgXiXfa/w7n73MO9X1bIh Xndg6p5VnAvGUWJpgnZghDl5ruJZV8Sq6LWVYX+eDhakAxG7xkalLeEdyG5lb/k3un30/7EGGnK1S Jst6fB/me/2r2XtIttl7reG3MwSIW7z+LrgRxG67HxCiOgSAd61bEwUApV4/lK6nLrGplPh+/oudM IvvKWcdoFcxoqAguQNbBwNY7wlVj7fNaxrxI8xdXIBfyVMr7SrU1EAmOh2mkCQNMzdRQm0gCjZ/CJ nZJ6F7zEYNnuNl6ELTvDxZrkpcZLGhucB2hdtM873cerRDkGks7hOkOg0IMyysHzWXM7og9ZXUzEv EaY90eRw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIHIW-00000004KkO-00RZ; Sat, 15 Jun 2024 00:29:36 +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" , Zorro Lang Subject: [PATCH v2 4/5] _require_debugfs(): simplify and fix for debian Date: Fri, 14 Jun 2024 17:29:33 -0700 Message-ID: <20240615002935.1033031-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240615002935.1033031-1-mcgrof@kernel.org> References: <20240615002935.1033031-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: C8E9940004 X-Stat-Signature: b41tmnd3q89i3i3p67k9u8ucei6817ak X-HE-Tag: 1718411380-421951 X-HE-Meta: U2FsdGVkX198keWwFVhlbg/kzXiTw0TbW84A/K+FTqxBFAe18JZEvqdYlVdjcKpBN0hfDaM4ZqYBmsOrDmNKz034d+nlHfEf/D4//5ExGWdVIDot72zpPJOUa6mjVDxwbeEt3uoTmOwrIGlZlV5+aPnSummbRMuQBJT1wRwYKt7ZXJ7kiNMvoPHkd/sc69s5emit9/UPoaJYh40roYMrLovZnevTdxG8OWudCcx+AeolY7rGT4815CW2y+NAQQ2lPL3hD+LtwUbbq0Avik3wYZQzQYXBPu2etPMBu22mFrf0gU6u5QlMyA8o2TcythpC+G9lbxHyBShWeYcJW0i5JF2T0um6hqTZSbQ9ah42sHKw4FaZx4sJ26BVOnuajkQMTJMvJPiT5a71HTNg3UfBNiUv/Hsvpzo2Rmf/Dxxw9G1pC26IpRktEjew9a0JD6lSPuiJ+aglfqSrtmjkr1rnlbMuAn4LcTq9eA5tpZ41JQArKwgPOsOZSwAOg2A7by6q+uGW4Fy7dZrxvVt6j0HZ24CSKt7PTGRmBT/QrMzmyQk7k/jp6/m55yMVa6jJ2m9Nr+hnl9AVkXo5IVwBC3EDW462+c8LmlsAP5TN6ljIlkspfUdTKtB++Z3DiSgU8C1vJIY+2mUpb0SY3S0abk5exYb/RFpGLRpu69cPr6EytyAU0i3Q9MfQmKMuWEUyUH9O7nNnIgdb5JcxO6cPLvMX3phrAh1UVj2tGeg/Iew7fo5E5gYfHfeYAIeUUb8tBhwQYTRB3vMiWj8IMuW5fCTTwg0yt1hzIJgdzNcJfB7KThBw+2mi/vmvEVM6Cl3u6zVd5XO0coB7wdpsolTLyvZzzHftmOR/LNK6merbObWgLwVjk98eqsCNNfmxggkFG9WVtSFZiC9mwFhm3Jk72A7nWhgIeFXnZb/jRLJY8nEXQDRoxXdHKeA9NSFAz4SvVq4fkbolWWs6jLHavPy7v/1 7zAzSYT+ kMz3bX31SjzYh7bmSBmkk2ObVYytYQO7DTM+ZOTbuFEQVLDK4+84Eun2VqrVONBIwq6XBv6nacKeHYJ2i4KOrY0b1XRoY/WTtxdl3GWxs/dGes15ABPrmDtY3k8jQ4xzzC6DsnS9IgAqbHqBBaStSzmzz0khHFYDc1YLefvl+/Qy0oKO0DrQSBvk31uUSDAid8xhkEFDbqndnNMhrrQaSjFDFug+l771U2jUkb2m34jwGl4w7Uz3bATofLLh3WiLR8yQviJeFXZTOkTS2iXR6Ns0c02Df88FnEevLRtl53YQDbGyi3uAIVce7AtZ1tYQiW0npBhudxaLhoIU5q+WGW1GiGnSraxFHYfDEh8YEqEmkMu0vniWFw5XsRAUPSMv/1mdV43SFknNQq41a8pObhE0B5fEv2RSZKf+d8uesFCWit4H0UMOFI5hE7bpM212pxug843J/1bUmmeHAky3mXrSGpNMyw4CCS2dLc9xPaLQoHspyyHg+ZNkW2w== 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") Reviewed-by: Darrick J. Wong Reviewed-by: Zorro Lang Signed-off-by: Luis Chamberlain --- 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 Sat Jun 15 00:29:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13699194 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 E1C7CC27C6E for ; Sat, 15 Jun 2024 00:37:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 862D26B0162; Fri, 14 Jun 2024 20:32:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0717A6B0167; Fri, 14 Jun 2024 20:31:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E54456B0152; Fri, 14 Jun 2024 20:31:58 -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 D64446B0261 for ; Fri, 14 Jun 2024 20:29:43 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7DD9AC09D9 for ; Sat, 15 Jun 2024 00:29:43 +0000 (UTC) X-FDA: 82231239846.15.AF61381 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id CFD50100010 for ; Sat, 15 Jun 2024 00:29:41 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3MSpdLBr; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf14.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718411379; a=rsa-sha256; cv=none; b=M8U2X4c5UR1mIAYOHsokJTu/JLNnV7D5bxLIqmPZSVishnOcMZwAk5+sjVtOVuF9BFkmKG 9MtnK5wE6xUUcz4PuS8eJrkl0HrscJpsCxTKmXcnaEOq6FwephM76khgAXO0lm4WUgfyKY tUkJ1Uj7KHUhpQnHiB13mvwjMJFPDBo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3MSpdLBr; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf14.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718411379; 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=u7sKH/EoTHoAcleZsYCTpUg3LOCTJBFwB5grFo4U/wA=; b=frzou1uy16gL+2OC21my1P1FiEbY/h3zjdXFJ/RRybFolv3hqKw9IeT3wK7p+3yDvWTuvJ n7t8C684MaoEWh3cLYlrTzFM64u2xW/5W54GmAOR936KFrmsJnfMjd2HNXT0khVJ5dc6/N EBmbXXk5m/MFUYpp7ltwxxhBGshVGkI= 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=u7sKH/EoTHoAcleZsYCTpUg3LOCTJBFwB5grFo4U/wA=; b=3MSpdLBrKBSHiTPDCXi8f3roPV rMKOIAC1AbLX0GSwAMQwn3Akw+Q44loSSfHgW/L4yWuNky8v+D1IxdAth/0968Yzq+VbfhT5pO9zL IlRtULLdknMEePWE7q5IRloeWWTZS8Onnmjlbxqviv3QpBMnXe1TLdbgHSUnFkUESyKE/s6B6+7O4 xyN5ZhJfgp9C0+DRRIghzAO9AqJx0DhmigdYXAS/0vmzK028AZAQnC5E4GwfcL8/YSX0b0LnacBw6 csYmtAhmyj1c6E19zZKIq/Mokm/2M0l1lLMyx/N6JRRp2pwnKuwHQdH6xB9l6AT0tZnHTXt1JZ6Ll qS+UXReg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sIHIW-00000004KkQ-0DrD; Sat, 15 Jun 2024 00:29:36 +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 v2 5/5] fstests: add stress truncation + writeback test Date: Fri, 14 Jun 2024 17:29:34 -0700 Message-ID: <20240615002935.1033031-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240615002935.1033031-1-mcgrof@kernel.org> References: <20240615002935.1033031-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: CFD50100010 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: orw5gxeij5q3s8f9soqdskdx6d1bhq14 X-HE-Tag: 1718411381-593086 X-HE-Meta: U2FsdGVkX19RzR2tWJ5pox+TPij0sb1snrVBgifEpbVObPiiygQgJpBrxZEIXbgja1xknMqddvyiTKabwjCgX7qRXtM2nreIL+VYK4hV2UjSMle0lw/Hc9Tmepd449oafg93Z0uJqYBc1j56ZJKHwRRWB+Iu2D3bPC9A1q6nk8KYfaDPrt5e70xoNNFud1GBxblNv6Xj/pKG2ruXJUXGiFt5pKCmITa47rhEy/D9hskLnMLtAUJ3yLXVrPmk9r+fIZXDoVZp0FkARAUFmFe00k4lsYZIB3jXqM7io+loxW/ldeQaZJwF7eVQANas6Ow0lw4Je1ulF0+LurXPKyjo7wRMQrRppOJ30TudsIHcYS+8YixH7y+We8tw6zyLCzAYpq1E0tSK9TZQuOnrcQSsSWCksJhp1mOskw/xaoVcF4znV1bWun3npfyDicudIAPUA34nVVCdltK+vyaE20arGxdrEuy9nayuJ8IYDdcwknY9KEb0Yt2vXChsNHkktL/YD46z9G1zWEOGqgrxGjkn+Y2RciGengkLx9zO0wjr6qVBglKavmDW4HBPu37D7hmkuL/aQnS8ZHJQEwIUf7TzEQzxAghBQAaavGwHUgDlfrvVS4TaX5fCJG9V2G+B7LBHItQ53kPWa54Bgh8j98C+OEu48Nz2g3zmdQjHsb0QRorlWABh3/k4D54axlAMu908qghcG81B6HpKoIOOG0gREZrsnDcnoGKTdM59a/kK76Sp8CQRP8cpITy3TFbZ8wTHylpl2OMJv2/6//deW50QeG8dleqLin3PXUMIn+MdAk5lO1efRSNQ2qeL66A61FOjqK/9pCufOcYA7PCHWdzt0TJl3/892QTY9JfMBSmDQbXl2su6axcddH6eqxUbA8N5WGXK/ZSH/7s780b8xsRxbFuneJTCs2gYUEBGH2CPqryROcTYXFWHNXYsorTLnhUXgEL5tz+vKLCFZiPUMOW 8Ybzin/A fNbs2+7zS6Dkw5cBwDg6o2741Ab26fv5MFK7Rn5ftjkHOij/P9TsyXZiOMxSHGstTVahayDROLYHFQtuCBJPXJTBy+PbZdZ4gnjT7tEYVmq6Yiz8o98MnZtO9rkZlPLUHdaC5bP7dO8vJ7m9yGtT0mW80oQ9OKRm7pCmLW6uXGs7Z7FKHRk/MKov0OtAQ1CoUdkNBgFIBYlZN4wDukFh9vJFitNw7lG+3EnBvkQv+Q9HO8ABFLOrZPSbzqD6/rzoUtph2UKwwJ1QiqGzZxOpHA+hSp8qdJ28IHEc9YRMguyJ9KjzmsF0lU100q2Qc9nans6M8hTRnCO/XJpbjZYKfCMApKNIeXqja+DIUG24UVdDF7uDxqiAmFLH/gK4KMxv11TX0wfn/EvI8zR1QmkT+Nu6dj2+2JDc9Cu4QDEUJwEqB6a7nJzTPOuuIBtHq5mwbAqW1ywjzJjeGtmxkwcGPiwgBnq3fR4hOMieY 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: 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 Reviewed-by: Zorro Lang --- common/rc | 14 ++++ tests/generic/751 | 170 ++++++++++++++++++++++++++++++++++++++++++ tests/generic/751.out | 2 + 3 files changed, 186 insertions(+) create mode 100755 tests/generic/751 create mode 100644 tests/generic/751.out diff --git a/common/rc b/common/rc index 30beef4e5c02..31ad30276ca6 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_huge_pages_knob() +{ + 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..ac0ca2f07443 --- /dev/null +++ b/tests/generic/751 @@ -0,0 +1,170 @@ +#! /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 +# Crash excerpt is as follows: +# +# BUG: kernel NULL pointer dereference, address: 0000000000000036 +# #PF: supervisor read access in kernel mode +# #PF: error_code(0x0000) - not-present page +# PGD 0 P4D 0 +# Oops: 0000 [#1] PREEMPT SMP NOPTI +# CPU: 7 PID: 2190 Comm: kworker/u38:5 Not tainted 6.9.0-rc5+ #14 +# Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 +# Workqueue: writeback wb_workfn (flush-7:5) +# RIP: 0010:filemap_get_folios_tag+0xa9/0x200 +# Call Trace: +# +# writeback_iter+0x17d/0x310 +# write_cache_pages+0x42/0xa0 +# iomap_writepages+0x33/0x50 +# xfs_vm_writepages+0x63/0x90 [xfs] +# do_writepages+0xcc/0x260 +# __writeback_single_inode+0x3d/0x340 +# writeback_sb_inodes+0x1ed/0x4b0 +# __writeback_inodes_wb+0x4c/0xe0 +# wb_writeback+0x267/0x2d0 +# wb_workfn+0x2a4/0x440 +# process_one_work+0x189/0x3b0 +# worker_thread+0x273/0x390 +# kthread+0xda/0x110 +# ret_from_fork+0x2d/0x50 +# ret_from_fork_asm+0x1a/0x30 +# +# +# 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 +fio_err=$tmp.fio.err + +# real QA test starts here +_supported_fs generic +_require_test +_require_scratch +_require_debugfs +_require_split_huge_pages_knob +_require_command "$KILLALL_PROG" "killall" +_fixed_by_git_commit kernel 2a0774c2886d \ + "XArray: set the marks correctly when splitting an entry" + +proc_vmstat() +{ + awk -v name="$1" '{if ($1 ~ name) {print($2)}}' /proc/vmstat | head -1 +} + +# 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=$(proc_vmstat thp_split_page) + split_count_failed_before=$(proc_vmstat thp_split_page_failed) +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 2> $fio_err +FIO_ERR=$? + +rm -f $runfile + +wait > /dev/null 2>&1 + +if grep -q thp_split_page /proc/vmstat; then + split_count_after=$(proc_vmstat thp_split_page) + split_count_failed_after=$(proc_vmstat thp_split_page_failed) + 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 + +# exitall_on_error=ENOSPC does not work as it should, so we need this eyesore +if [[ $FIO_ERR -ne 0 ]] && ! grep -q "No space left on device" $fio_err; then + _fail "fio failed with err: $FIO_ERR" +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