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 F286CC433E3 for ; Thu, 20 Aug 2020 05:05:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D760820758 for ; Thu, 20 Aug 2020 05:05:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725910AbgHTFFq (ORCPT ); Thu, 20 Aug 2020 01:05:46 -0400 Received: from mga05.intel.com ([192.55.52.43]:17883 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgHTFFp (ORCPT ); Thu, 20 Aug 2020 01:05:45 -0400 IronPort-SDR: wehtcBhL0Sbn4S/1dLRB32iaRmCMYILlCo9/+1N079sEIwpNKWeQOHp95/9fFIDMElrw+RIJL7 hZzNFQmPkoEw== X-IronPort-AV: E=McAfee;i="6000,8403,9718"; a="240065053" X-IronPort-AV: E=Sophos;i="5.76,332,1592895600"; d="scan'208";a="240065053" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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