Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp773727pxa; Wed, 19 Aug 2020 14:42:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSZo9b0rglJ6Fb+8G2JVtPWdABoaAmplvw8ddav7Gx4HAIVT+0awVJywYl9pGasas5OXIU X-Received: by 2002:a17:906:6413:: with SMTP id d19mr342071ejm.206.1597873342867; Wed, 19 Aug 2020 14:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597873342; cv=none; d=google.com; s=arc-20160816; b=jmWqxnH1TdcREqGnekjQwWJEvec0fbpZB+7b1BUKDU1do7POKrKhoaoXSuZKh/DDos KmrownkXBsZMtPhbG4dUhiZ8cVFD6VsfRzbreIP/lHTW6jz97MozmonIMLdQlvCCWo9d oAdEY830JWNNfR5ZihANdVbR3VtYSJ7aMmDXha1b+0C4t8jS8ya+v8kFp6wOKF3hXdqf r4hfwL/Es6hYWjbuvPj35J38H/lpKdw4trSad5kjBi8sB2h1oqacWe7P0P37BhvC9ZaC coCNytwKBbW7bqC5KoHtReRBwGL/UCAKnYS9Y1pYWs8t/s2jnshgCGcQ/B4mCsU9ssg3 dt0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hTEF7FpoeYL8Q+HCa82yrWFkKA4EpFDf03/6zdi5GWQ=; b=so34hina049xla/hXyiaY/w6bZ8zYVZujN4qNQQWjB7c1eBY4IYuacIPf9yZz1yU7f g7Vd6jS7pcUrNep55VCfgbfxKQUxd/JiBLlooQWLaEtp/c4nDyJngNb26BjYYBUbWqok tsbgtwk78lVRs1uLaTqyraVI4F2iR/97/zxRgk9np2szSgzgRuknKLUkQ5mlDn/Y5XFC OLsXZT28EYAc36bJmZsyK7b9taK/IJSHD17ZX3WllW1n4UgBvPFJ/uNALc4f780zvYcK 1Wfk3yHi+MougMztRpa77q1QcKTtNW1SWDBOiOCRb5Wg4bjCouEVr9hQY0vlmxlekO+p iZmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MwgEkw0y; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb22si151371edb.101.2020.08.19.14.41.58; Wed, 19 Aug 2020 14:42:22 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MwgEkw0y; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbgHSVlZ (ORCPT + 99 others); Wed, 19 Aug 2020 17:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgHSVlY (ORCPT ); Wed, 19 Aug 2020 17:41:24 -0400 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D7AC061757; Wed, 19 Aug 2020 14:41:23 -0700 (PDT) Received: by mail-ej1-x644.google.com with SMTP id jp10so227404ejb.0; Wed, 19 Aug 2020 14:41:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hTEF7FpoeYL8Q+HCa82yrWFkKA4EpFDf03/6zdi5GWQ=; b=MwgEkw0yg/KcYyXPPcMMmJuf+Qw4NS78WxxEs0le3mSafWxPPbgcnXgUhm6VcduzsN zos+oNhxkRkSTRzB4oZU/ZAtqlE70/k8fyJ6g0a+HwjL7t6FjAhyqWhp36AFzBhGgBfG 8V/nAzZWbVGHkfnZU2qx5L7ojmuYaIlIZpuRutUmRW9jdaZUbVy6XzHdVvN+Db2LIRs6 IYScJdHh3UhhSotLlxsvYUvCY7WHRDPkw+X78csVgiPLuc052gSIDlVJU6sMrEYcgOwC 5Mn7gcYB1aRLAuLDKs2dp7VFvXasnKs5hmss60nSmt/zwISwFythi89Hjh0Lf3mAdITW ne+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hTEF7FpoeYL8Q+HCa82yrWFkKA4EpFDf03/6zdi5GWQ=; b=ku9zTTgwLzbCvEX6pyZ1AMu2LbjluklXXtcXmgtBu9ke57gWiMtLWJt4bYXzsGimux /crfJtMHqiGSOyk6W/poyCRLP50eqcL4nQNOcPXgVnlV+9mugKrfFY87vD4QsrlLPFS4 Fpq7b+wq13odT/LKkiMEXHjRirbaq7ItztIY+B155vcOw7xQAi5kRgry+Hst/GlU1P19 zAosDDkA7TIN5gEd/wExY0er66G+X0ib0kJrhJYEHI2+oR5kY6YpArwMJek9IBWHFHRE nti2eKGBMfSfZnniTgl/NNsVytkvG5CqYYZZG4YREtE450UD6rgKaIC/HYlKeZ/WRAJO occw== X-Gm-Message-State: AOAM533Gbup00AwNDtGhZNyaFbAH9Ek/7NC/fUaK+jKJDlSENuqEfxQr ZUgLWPnL0d6yTZIKXotsgmsbPUSHCBsIIfnbkeTyX73oYgIG1g== X-Received: by 2002:a17:906:ca4f:: with SMTP id jx15mr302048ejb.449.1597873282341; Wed, 19 Aug 2020 14:41:22 -0700 (PDT) MIME-Version: 1.0 References: <20200819195613.24269-1-hsiangkao@redhat.com> <20200819130506.eea076dd618644cd7ff875b6@linux-foundation.org> <20200819201509.GA26216@xiangao.remote.csb> In-Reply-To: <20200819201509.GA26216@xiangao.remote.csb> From: Yang Shi Date: Wed, 19 Aug 2020 14:41:08 -0700 Message-ID: Subject: Re: [PATCH] mm, THP, swap: fix allocating cluster for swapfile by mistake To: Gao Xiang Cc: Andrew Morton , Linux MM , Linux Kernel Mailing List , Rafael Aquini , Carlos Maiolino , Eric Sandeen , "Huang, Ying" , stable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 1:15 PM Gao Xiang wrote: > > Hi Andrew, > > On Wed, Aug 19, 2020 at 01:05:06PM -0700, Andrew Morton wrote: > > On Thu, 20 Aug 2020 03:56:13 +0800 Gao Xiang wrote: > > > > > SWP_FS doesn't mean the device is file-backed swap device, > > > which just means each writeback request should go through fs > > > by DIO. Or it'll just use extents added by .swap_activate(), > > > but it also works as file-backed swap device. > > > > This is very hard to understand :( > > Thanks for your reply... > > The related logic is in __swap_writepage() and setup_swap_extents(), > and also see e.g generic_swapfile_activate() or iomap_swapfile_activate()... I think just NFS falls into this case, so you may rephrase it to: SWP_FS is only used for swap files over NFS. So, !SWP_FS means non NFS swap, it could be either file backed or device backed. Does this look more understandable? > I will also talk with "Huang, Ying" in person if no response here. > > > > > > 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. > > > > > > 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") > > > > Why do you think it has taken three years to discover this? > > I'm not sure if the Redhat BZ is available for public, it can be reproduced > since rhel 8 > https://bugzilla.redhat.com/show_bug.cgi?id=1855474 > > It seems hard to believe, but I think just because rare user uses the SSD device + > THP + file-backed swap device combination... maybe I'm wrong here, but my test > shows as it is. > > Thanks, > Gao Xiang > > > > > > > > >