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=-6.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 9A952C433E1 for ; Thu, 20 Aug 2020 05:05:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68F3820758 for ; Thu, 20 Aug 2020 05:05:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68F3820758 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 074096B009F; Thu, 20 Aug 2020 01:05:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F3F9F6B00A0; Thu, 20 Aug 2020 01:05:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E569A8D0003; Thu, 20 Aug 2020 01:05:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0219.hostedemail.com [216.40.44.219]) by kanga.kvack.org (Postfix) with ESMTP id CCC036B009F for ; Thu, 20 Aug 2020 01:05:48 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8B768362D for ; Thu, 20 Aug 2020 05:05:48 +0000 (UTC) X-FDA: 77169759576.04.hen67_3e05ef62702d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 5FA048000FF1 for ; Thu, 20 Aug 2020 05:05:48 +0000 (UTC) X-HE-Tag: hen67_3e05ef62702d X-Filterd-Recvd-Size: 3897 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Aug 2020 05:05:47 +0000 (UTC) IronPort-SDR: EBepSUQmtLnOsN7fLwE5jIflJj4HkDKfDfbGLO+0jSOQXk/vu9+SILNb0/ABQsUmZW7E65dykS /aMxWWE04esg== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="156307362" X-IronPort-AV: E=Sophos;i="5.76,332,1592895600"; d="scan'208";a="156307362" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Aug 2020 22:05:45 -0700 IronPort-SDR: OZXJvMO5PQiH3Cf2UlhbyGFZwCTjlc8v6u8s9AzvCb+Q1uF/+A1WFMIKnvpDPlYKARZ2UU4xK2 FFp6QNT31ZVg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,332,1592895600"; d="scan'208";a="320731690" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.164]) by fmsmga004.fm.intel.com with ESMTP; 19 Aug 2020 22:05:43 -0700 From: "Huang\, Ying" To: Gao Xiang Cc: Andrew Morton , , , Carlos Maiolino , Eric Sandeen , Yang Shi , Rafael Aquini , Dave Chinner , stable Subject: Re: [PATCH v2] mm, THP, swap: fix allocating cluster for swapfile by mistake References: <20200820045323.7809-1-hsiangkao@redhat.com> Date: Thu, 20 Aug 2020 13:05:42 +0800 In-Reply-To: <20200820045323.7809-1-hsiangkao@redhat.com> (Gao Xiang's message of "Thu, 20 Aug 2020 12:53:23 +0800") Message-ID: <87wo1tx5y1.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: 5FA048000FF1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: Gao Xiang writes: > SWP_FS is used to make swap_{read,write}page() go through > the filesystem, and it's only used for swap files over > NFS. So, !SWP_FS means non NFS for now, it could be either > file backed or device backed. Something similar goes with > legacy SWP_FILE. > > So in order to achieve the goal of the original patch, > SWP_BLKDEV should be used instead. > > FS corruption can be observed with SSD device + XFS + > fragmented swapfile due to CONFIG_THP_SWAP=y. > > I reproduced the issue with the following details: > > Environment: > QEMU + upstream kernel + buildroot + NVMe (2 GB) > > Kernel config: > CONFIG_BLK_DEV_NVME=y > CONFIG_THP_SWAP=y > > Some reproducable steps: > mkfs.xfs -f /dev/nvme0n1 > mkdir /tmp/mnt > mount /dev/nvme0n1 /tmp/mnt > bs="32k" > sz="1024m" # doesn't matter too much, I also tried 16m > xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw > xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw > xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw > xfs_io -f -c "pwrite -F -S 0 -b $bs 0 $sz" -c "fdatasync" /tmp/mnt/sw > xfs_io -f -c "pwrite -R -b $bs 0 $sz" -c "fsync" /tmp/mnt/sw > > mkswap /tmp/mnt/sw > swapon /tmp/mnt/sw > > stress --vm 2 --vm-bytes 600M # doesn't matter too much as well > > Symptoms: > - FS corruption (e.g. checksum failure) > - memory corruption at: 0xd2808010 > - segfault > > Fixes: f0eea189e8e9 ("mm, THP, swap: Don't allocate huge cluster for file backed swap device") > Fixes: 38d8b4e6bdc8 ("mm, THP, swap: delay splitting THP during swap out") > Cc: "Huang, Ying" > Cc: Yang Shi > Cc: Rafael Aquini > Cc: Dave Chinner > Cc: stable > Signed-off-by: Gao Xiang Thanks! Reviewed-by: "Huang, Ying" Best Regards, Huang, Ying