Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp974126pxa; Wed, 19 Aug 2020 22:07:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+9W6cTPq9u9W0ybji63IWKFG7C//4eC9/rcRUaS+hyDlLyAx0L0zJInaUgYiQJBxdtdoe X-Received: by 2002:a17:906:5f84:: with SMTP id a4mr1560979eju.345.1597900036964; Wed, 19 Aug 2020 22:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597900036; cv=none; d=google.com; s=arc-20160816; b=AFnZVPF0iVsrtYmnylmrX9IxPnAnRUXGBNReMnK7fsNLCeM/do2sKSD3KKBAiZiIlY HZghb+RhcxDMG9Q91mSdtIYkg0xTGdcQd5rwDSae2FblHKd9WvvYFDRjM9tLm1zoQi+k wqiK59OhFLuvXph2SIDXP0l2hF+u/wP1nfs8j7tv4ttRurBtC8ABwhvmgkUkZH8QqX7L xRFNMBDkOQ3CxCVIdcY2hyA+y4FuQS/nQPIQ24dhNFra6mlt0KWAqH7VvbSOihUMAUUK xxAbmfvMhq6lWQh1uKBuV2WYwq6GjvEExza7ehc44zkEFSimVD+R/9cSKSo9inwy6y2b 2K/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:ironport-sdr :ironport-sdr; bh=EqV4WBcgJsOONKoyDVCKDGNwUdLsB27qaZHXMyKwiww=; b=M+JVSHl3qYhniXtBn5kT1e7pAo0ukb32Y/xfKhZbWqtbtAobvs3J4CZzzo1d9vnlWW Bzo1R6OudzkehBq35HIi9togvjLUxYrb9eMu8nub/OyB0XaSi8FB/AjWvKM5P2TB/sJE 95LJkunhxqJf8YmiJCJOOfspO0Rz/M7byuEefv7W2yO6P4iOQu+Vzf01zcPFFgKQ4Oyi fIpCdVedj5+huLwfaT9TnI6nj14LU0vXzFij1X18p9niR+TaMTyV1XpsVirHw90dlKF/ IxqsRMFUxH2WHjvIUuW1hEdIacPEbwEgSf6ADqlvvBlaIxLiOJAgmmw9aPKU9IDFe3w6 Vndg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c90si704784edd.562.2020.08.19.22.06.53; Wed, 19 Aug 2020 22:07:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725823AbgHTFFq (ORCPT + 99 others); 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