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=-5.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 3546DC433E3 for ; Thu, 20 Aug 2020 11:49:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EEC622078B for ; Thu, 20 Aug 2020 11:49:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="D8qbh/xQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEC622078B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7CD758D001C; Thu, 20 Aug 2020 07:49:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77B2E8D0001; Thu, 20 Aug 2020 07:49:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61D138D001C; Thu, 20 Aug 2020 07:49:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id 4B0838D0001 for ; Thu, 20 Aug 2020 07:49:28 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E2811180AD81D for ; Thu, 20 Aug 2020 11:49:27 +0000 (UTC) X-FDA: 77170776774.12.nerve41_000409e27030 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id A26161801ACA6 for ; Thu, 20 Aug 2020 11:49:27 +0000 (UTC) X-HE-Tag: nerve41_000409e27030 X-Filterd-Recvd-Size: 6071 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Aug 2020 11:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597924166; 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=9saac307wOKfkkuwU6eXgFAqSu4oqXrr/wJpcDGuHPE=; b=D8qbh/xQPRhff33jRFuZI6J6lTCaIy7mmv24+cOB/+f1tTv661pXOzDKn0IIhk31GUgPd1 ua10o/SzF5w9ianCBShQS6DRvlBq6iEuY2pGoKKeFPhV9eA3GHWAD9o/51Seh2T+H/FHZC 8nB18ToRvgwhnjkL98o0eWpCf0vpbu8= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-RQ8dtOJCNouWQ1stofRlfQ-1; Thu, 20 Aug 2020 07:49:24 -0400 X-MC-Unique: RQ8dtOJCNouWQ1stofRlfQ-1 Received: by mail-pj1-f71.google.com with SMTP id gf16so1073428pjb.7 for ; Thu, 20 Aug 2020 04:49:24 -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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9saac307wOKfkkuwU6eXgFAqSu4oqXrr/wJpcDGuHPE=; b=swB8MYNwvxTp6Ydi55uWUF1LwJz/Xq7mim2YYI7J2F5ZZuB5vpU4P67Vp/AYFjhtaV F8cOuGBlmE0Buf8vkM89m4nABy0dQFGf/P5H4BPQZiavGRfznZ8EpWWPc3cs/OfbLuLd LVaAPVbbA6kf189Is1bJC3cOqkcS/bgnjtsHKxQu7zQ/jfz6S2wB6bkgntbwN3UG96yc 5Ut7G3hmpRWCl3/j7LQ9QJdt93aVOB7mcp5nPZlw7AH1OYWhJEjoW9hNJONwgiBvP6oe PJxcL83+fr209Vq5T/b38i4JwFHrSZAudJxVcOnyusfij87Ofa9gH1ZxOehMgDTxpvNW 2+AQ== X-Gm-Message-State: AOAM530XQGLOuRJfGc1PPrKOpChlhxrpQlUnRe9EahbzR617zVNVWHJw uw9Oaam0En/KZUHQYl1ZJMSMyfUWPjxVrjMfG9A+ESxYpxuHe16+1M8Ci2SNHjJaEanWNF148EF t7A2RYFGTQ+8= X-Received: by 2002:a17:90a:fca:: with SMTP id 68mr2139378pjz.12.1597924163731; Thu, 20 Aug 2020 04:49:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBjLpZdhtO7F74YwmOts0pQqOWh6y/Tz0vd4MXLA4VdNuTc/QS10DWsZj7Ckm0QBRZGJGSRA== X-Received: by 2002:a17:90a:fca:: with SMTP id 68mr2139363pjz.12.1597924163438; Thu, 20 Aug 2020 04:49:23 -0700 (PDT) Received: from xiangao.remote.csb ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id b22sm2671768pfb.52.2020.08.20.04.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 04:49:23 -0700 (PDT) Date: Thu, 20 Aug 2020 19:49:11 +0800 From: Gao Xiang To: Matthew Wilcox Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Carlos Maiolino , Eric Sandeen , "Huang, Ying" , Yang Shi , Rafael Aquini , Dave Chinner , stable Subject: Re: [PATCH v2] mm, THP, swap: fix allocating cluster for swapfile by mistake Message-ID: <20200820114911.GA12068@xiangao.remote.csb> References: <20200820045323.7809-1-hsiangkao@redhat.com> <20200820113448.GM17456@casper.infradead.org> MIME-Version: 1.0 In-Reply-To: <20200820113448.GM17456@casper.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hsiangkao@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Rspamd-Queue-Id: A26161801ACA6 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: Hi Matthew, On Thu, Aug 20, 2020 at 12:34:48PM +0100, Matthew Wilcox wrote: > On Thu, Aug 20, 2020 at 12:53:23PM +0800, Gao Xiang wrote: > > 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. > > This is clearly confusing. I think we need to rename SWP_FS to SWP_FS_OPS. > > More generally, the swap code seems insane. I appreciate that it's an > inherited design from over twenty-five years ago, and nobody wants to > touch it, but it's crazy that it cares about how the filesystem has > mapped file blocks to disk blocks. I understand that the filesystem > has to know not to allocate memory in order to free memory, but this > is already something filesystems have to understand. It's also useful > for filesystems to know that this is data which has no meaning after a > power cycle (so it doesn't need to be journalled or snapshotted or ...), > but again, that's useful functionality which we could stand to present > to userspace anyway. > > I suppose the tricky thing about it is that working on the swap code is > not as sexy as working on a filesystem, and doing the swap code right > is essentially writing a filesystem, so everybody who's capable already > has something better to do. Yeah, I agree with your point. After looking into swap code a bit (swapfile.c and swap.c), I think such code really needs to be cleaned up... But I'm lack of motivation about this since I couldn't guarantee to introduce some new regression and honestly I don't care much about this piece of code. Maybe some new projects based on this could help clean up that as well. :) Anyway, we really need a quick fix to avoid such FS corruption, which looks dangerous on the consumer side. > > Anyway, Gao, please can you submit a follow-on patch to rename SWP_FS? Ok, anyway, that is another stuff and may need some other thread. I will seek some time to send out a patch for further discussion later. Thanks, Gao Xiang >