From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85645C4320E for ; Thu, 19 Aug 2021 04:54:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17576610CF for ; Thu, 19 Aug 2021 04:53:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 17576610CF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 8CE686B006C; Thu, 19 Aug 2021 00:53:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 87E566B0071; Thu, 19 Aug 2021 00:53:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76CE46B0072; Thu, 19 Aug 2021 00:53:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id 5CAA06B006C for ; Thu, 19 Aug 2021 00:53:59 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id DC8D718039537 for ; Thu, 19 Aug 2021 04:53:58 +0000 (UTC) X-FDA: 78490612956.05.AD788F4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 7C9495072268 for ; Thu, 19 Aug 2021 04:53:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629348838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DYUR2yrRBDOoqdaGfM0jUoL4Nv+fDfxlMLBm1iQy4og=; b=TIQWqnLW032tqGx7zIe084tew/MouWhdQMccLGzmhKmOIAf1jC6AviJvnFGxD+xGScsIUs 1cYvtqIwrwwZE54Sd9Nzc8SiuJVRVgN97jOgMED3WYHHQXuSJjuIV8EQNvYdcfMZK3BwCR 4t7AqU+RQ7NA0xkuvPc6X99C/sqEaT0= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-548-mK7ug3WtNpaQlDspxMoKLw-1; Thu, 19 Aug 2021 00:53:56 -0400 X-MC-Unique: mK7ug3WtNpaQlDspxMoKLw-1 Received: by mail-pg1-f200.google.com with SMTP id k28-20020a63ff1c0000b029023b84262596so2779702pgi.1 for ; Wed, 18 Aug 2021 21:53:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=DYUR2yrRBDOoqdaGfM0jUoL4Nv+fDfxlMLBm1iQy4og=; b=QPlNWJ7wPtY5RvGSEkSE/ek4sBxuAntqn/tZgouXb31AOEDanoE0Z+fTiTtPdLm0jo BMgGHhTYuUrn4xrS98GWV6y5S58tVTce2v8O3EvZdIW20Szy8v/YjcJVyhTCefoi2toA HbQDXg96z2XdkyDBN6zzGys0BrLJ4sF71Bai7q4SiC+pK0Mzok61R2PRz0ZbohN17iX5 ZvehXkWa4bozwudv6G4eXPL3O+MFoHJLqGotwfPjwSCv3uloo1Gjz4Q1rLqaSCVN9TsB CSiQZDfhV0wj37MhlhTC+gE+m34uxcLwpg9wfuhoZ/OBKj3cmFoCsVuRnIsvvhvXnj6J Rn5w== X-Gm-Message-State: AOAM531cB1GI4Q/0swqrGf1dszFXstBka0o68Y4EBoTGDLVCijFRDMvH RpGMAorKtcPaVDSmwaFKTew5TuoyQhEsR4RmPI3TGDHQk0IdnnOs25yodoZB4Gt6slwkvFXT8X9 RBNn7ENHLHGg= X-Received: by 2002:a17:902:690a:b0:12d:86cf:d981 with SMTP id j10-20020a170902690a00b0012d86cfd981mr10233125plk.39.1629348835459; Wed, 18 Aug 2021 21:53:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTwlPzBxgGrKGY60dayzMAHDaDEDhpkimgsYFVvJXjtkvG82QRU9WAYTDsbNJJ2qLzpmLh9A== X-Received: by 2002:a17:902:690a:b0:12d:86cf:d981 with SMTP id j10-20020a170902690a00b0012d86cfd981mr10233102plk.39.1629348835165; Wed, 18 Aug 2021 21:53:55 -0700 (PDT) Received: from fedora ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id r3sm1478297pff.119.2021.08.18.21.53.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 21:53:54 -0700 (PDT) Date: Thu, 19 Aug 2021 13:14:31 +0800 From: Zorro Lang To: "Darrick J. Wong" Cc: Xu Yu , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@infradead.org, riteshh@linux.ibm.com, tytso@mit.edu, gavin.dg@linux.alibaba.com, fstests , linux-btrfs Subject: Re: [PATCH] generic: add swapfile maxpages regression test Message-ID: <20210819051431.z3q46fswvkwnwmgn@fedora> Mail-Followup-To: "Darrick J. Wong" , Xu Yu , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@infradead.org, riteshh@linux.ibm.com, tytso@mit.edu, gavin.dg@linux.alibaba.com, fstests , linux-btrfs References: <20210819014326.GC12597@magnolia> MIME-Version: 1.0 In-Reply-To: <20210819014326.GC12597@magnolia> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TIQWqnLW; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf01.hostedemail.com: domain of zlang@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=zlang@redhat.com X-Stat-Signature: 77dw6co7iyaedbepzqrbsquwjjsrbn58 X-Rspamd-Queue-Id: 7C9495072268 X-Rspamd-Server: rspam05 X-HE-Tag: 1629348838-302815 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: On Wed, Aug 18, 2021 at 06:43:26PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong > > Add regression test for "mm/swap: consider max pages in > iomap_swapfile_add_extent". > > Cc: Gang Deng > Cc: Xu Yu > Signed-off-by: Darrick J. Wong > --- The code logic looks good to me. And [1][2]... so I think this test is good. But of course, wait for more review points from cc list. Reviewed-by: Zorro Lang [1] Test passed on old kernel without this regression (xfs fails): # ./check generic/727 FSTYP -- ext4 PLATFORM -- Linux/x86_64 xx-xxxx-xx 4.18.0-xxx.el8.x86_64+debug #1 SMP Wed Jul 14 12:35:49 EDT 2021 MKFS_OPTIONS -- /dev/mapper/rhel-xx-xxxx-xx-xfscratch MOUNT_OPTIONS -- -o acl,user_xattr -o context=system_u:object_r:root_t:s0 /dev/mapper/rhel-xx-xxxx-xx-xfscratch /mnt/scratch generic/727 15s Ran: generic/727 Passed all 1 tests [2] Reproduced on new kernel with this regression: # ./check generic/727 FSTYP -- ext4 PLATFORM -- Linux/x86_64 xxx-xxxx-xx 5.14.0-rc4-xfs #14 SMP Thu Aug 12 00:56:07 CST 2021 MKFS_OPTIONS -- /dev/mapper/testvg-scratchdev MOUNT_OPTIONS -- -o acl,user_xattr -o context=system_u:object_r:root_t:s0 /dev/mapper/testvg-scratchdev /mnt/scratch generic/727 - output mismatch (see /root/git/xfstests-dev/results//generic/727.out.bad) --- tests/generic/727.out 2021-08-19 11:20:14.677794743 +0800 +++ /root/git/xfstests-dev/results//generic/727.out.bad 2021-08-19 11:21:46.654450307 +0800 @@ -1,2 +1,3 @@ QA output created by 727 +swapon added 2044 pages, expected 1020 Silence is golden ... (Run 'diff -u /root/git/xfstests-dev/tests/generic/727.out /root/git/xfstests-dev/results//generic/727.out.bad' to see the entire diff) Ran: generic/727 Failures: generic/727 Failed 1 of 1 tests > tests/generic/727 | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ > tests/generic/727.out | 2 ++ > 2 files changed, 64 insertions(+) > create mode 100755 tests/generic/727 > create mode 100644 tests/generic/727.out > > diff --git a/tests/generic/727 b/tests/generic/727 > new file mode 100755 > index 00000000..a546ad51 > --- /dev/null > +++ b/tests/generic/727 > @@ -0,0 +1,62 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2021 Oracle. All Rights Reserved. > +# > +# FS QA Test 727 > +# > +# Regression test for "mm/swap: consider max pages in iomap_swapfile_add_extent" > + > +# Xu Yu found that the iomap swapfile activation code failed to constrain > +# itself to activating however many swap pages that the mm asked us for. This > +# is an deviation in behavior from the classic swapfile code. It also leads to > +# kernel memory corruption if the swapfile is cleverly constructed. > +# > +. ./common/preamble > +_begin_fstest auto swap > + > +# Override the default cleanup function. > +_cleanup() > +{ > + cd / > + rm -f $tmp.* > + test -n "$swapfile" && swapoff $swapfile &> /dev/null > +} > + > +# real QA test starts here > +_supported_fs generic > +_require_scratch_swapfile > + > +_scratch_mkfs >> $seqres.full > +_scratch_mount >> $seqres.full > + > +# Assuming we're not borrowing a FAT16 partition from Windows 3.1, we need an > +# unlikely enough name that we can grep /proc/swaps for this. > +swapfile=$SCRATCH_MNT/386spart.par > +_format_swapfile $swapfile 1m >> $seqres.full > + > +swapfile_pages() { > + local swapfile="$1" > + > + grep "$swapfile" /proc/swaps | awk '{print $3}' > +} > + > +_swapon_file $swapfile > +before_pages=$(swapfile_pages "$swapfile") > +swapoff $swapfile > + > +# Extend the length of the swapfile but do not rewrite the header. > +# The subsequent swapon should set up 1MB worth of pages, not 2MB. > +$XFS_IO_PROG -f -c 'pwrite 1m 1m' $swapfile >> $seqres.full > + > +_swapon_file $swapfile > +after_pages=$(swapfile_pages "$swapfile") > +swapoff $swapfile > + > +# Both swapon attempts should have found the same number of pages. > +test "$before_pages" -eq "$after_pages" || \ > + echo "swapon added $after_pages pages, expected $before_pages" > + > +# success, all done > +echo Silence is golden > +status=0 > +exit > diff --git a/tests/generic/727.out b/tests/generic/727.out > new file mode 100644 > index 00000000..2de2b4b2 > --- /dev/null > +++ b/tests/generic/727.out > @@ -0,0 +1,2 @@ > +QA output created by 727 > +Silence is golden >