From patchwork Thu Feb 23 02:44:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 5765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp77650wrd; Wed, 22 Feb 2023 18:45:36 -0800 (PST) X-Google-Smtp-Source: AK7set8ZU30P+JKztWtCss7xtJkqFcJ+DAB33gz81iTb8MyT/mkxkgeayDk4ouZiOj9M3nCK/Pg0 X-Received: by 2002:a05:6a20:4298:b0:c7:6c6f:7722 with SMTP id o24-20020a056a20429800b000c76c6f7722mr14582793pzj.7.1677120336441; Wed, 22 Feb 2023 18:45:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677120336; cv=none; d=google.com; s=arc-20160816; b=ZWUK+eiVXgYi0Htn9G7JT4XA7CargXim2cPq0eJ0yiG8h9Ywa4m5b/8HL7budnbEjI XMui59dQFA1oEfU6s3TrXxLAnDPfF9YPPXN14dZk+DUjlLUkvORt1Os2uxJO67kz9/ni ph7X9fn2WtLPBA265znir7tXWWgKBYo7zM9ifJbJ82+OgtjDkrC7iL7GdX3uydAythAI nwvgl7mSsnTMIP4cgBPIbcwHy6TetmsBSO3VSPKbZQdxxNDIdKmk9s8gp2drhcSvGLeO 2gMxZo3wRDmElbL+L5NEnNBeAyMVY7lv2Mzo96LbYw36Cqzft8vSAVR7r+SXwu+7tpKF CSjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bXX0DMS2swWkMqSYibcCFsHDgPbrh21a4B1H1mImqJM=; b=UbYSBDxF164H+drEioa+GAkTINe2LdxJnYDHc7JuAmy4QB/mSsKgNT3OgYq9pVzLrr XotgUorzq5SMqlOMZIFNjPii8f7074Kl3Kdj3xr8Txh2k2OpyhsCz6YO5unDfGNIs5Dz iSyqu//aFiU2bJ2TXgkyZpyrxDJk6f3xAGJeFpo0rOUDDwdMARNFL4Kc6wp66CvpFUyi Wnyb2A88y3d/wHsyEEiqSKJPZc0w6rE9QPjjjyExMbX4++xlsEwjV0f0Ym8GgXKpimgf mHjBgqH3LsUaGvQOSsfqG8546VWLLH3HacKH4jC6o/Z4XU8FQBRRDiCdtXT+ruIhs+e0 cN/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="mUlD/MPP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a6564c7000000b00478bc014a20si6356844pgv.0.2023.02.22.18.45.05; Wed, 22 Feb 2023 18:45:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="mUlD/MPP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233140AbjBWCog (ORCPT + 99 others); Wed, 22 Feb 2023 21:44:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233068AbjBWCo2 (ORCPT ); Wed, 22 Feb 2023 21:44:28 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F4E28216 for ; Wed, 22 Feb 2023 18:44:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=bXX0DMS2swWkMqSYibcCFsHDgPbrh21a4B1H1mImqJM=; b=mUlD/MPP0fVPyx7NdHMz3zb0YB nmVgJCICeQKODh7hp10D24qRCz0ZhxuWrkIljrcfQJIcQPB3xwNrm63aTNppEDbJMrrbJ3eTducUT meT0EmUMpB9gdr9ADY+5zvAGtFkRpXSvLwr0Vluqq34ZNE7n46NFyjTTwpJfd9bl59YQwBqaMMSz6 m6OVIyv2xw38XY0Mm68dFC0zBEnLMhJq3Gueeet4xmWgjFodCB/sevSVQBjeIGaOVJHXChEsu0NID OxkWZEalI1ch06GvCxIMWD/e6cSc09wckUA+MevURiUImgvOZ7ZG+/ecImJe4vBPkv843CXoKgcJX DX79YhqQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pV1ah-00EmN6-4b; Thu, 23 Feb 2023 02:44:15 +0000 From: Luis Chamberlain To: hughd@google.com, akpm@linux-foundation.org, willy@infradead.org Cc: linux-mm@kvack.org, p.raghav@samsung.com, dave@stgolabs.net, a.manzanares@samsung.com, yosryahmed@google.com, mcgrof@kernel.org, linux-kernel@vger.kernel.org Subject: [RFC v2 0/5] tmpfs: add the option to disable swap Date: Wed, 22 Feb 2023 18:44:07 -0800 Message-Id: <20230223024412.3522465-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 Sender: Luis Chamberlain X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758588134036108260?= X-GMAIL-MSGID: =?utf-8?q?1758588134036108260?= This adds noswap support to tmpfs. This follows up the first RFC [0], you can look at that link for details of the testing done. On this v2 I've addressed the feedback provided by Matthew Wilcox and Yosry Ahmed. I've also made some other changes. Changes on this v2: o Matthew suggested BUG_ON(!folio_test_locked(folio)) is not needed on writepage() callback for shmem so just remove that. o Based on Matthew's feedback the inode is set up early as it is not reset in case we split the folio. So now we move all the variables we can set up really early. o shmem writepage() should only be issued on reclaim, so just move the WARN_ON_ONCE(!wbc->for_reclaim) early so that the code and expectations are easier to read. This also avoid the folio splitting in case of that odd case. o There are a few cases where the shmem writepage() could possibly hit, but in the total_swap_pages we just bail out. We shouldn't be splitting the folio then. Likewise for VM_LOCKED case. But for a writepage() on a VM_LOCKED case is not expected so we want to learn about it so add a WARN_ON_ONCE() on that condition. o Based on Yosry Ahmed's feedback the patch which allows tmpfs to disable swap now just uses mapping_set_unevictable() on inode creation. In that case writepage() should not be called so we augment the WARN_ON_ONCE() for writepage() for that case to ensure that never happens. If this all seems peachy I can move this to PATCH form next. I've tested and indeed just using mapping_set_unevictable() suffices to disable swap upon inode creation. [0] https://lkml.kernel.org/r/20230207025259.2522793-1-mcgrof@kernel.org Luis Chamberlain (5): shmem: remove check for folio lock on writepage() shmem: set shmem_writepage() variables early shmem: move reclaim check early on writepages() shmem: skip page split if we're not reclaiming shmem: add support to ignore swap Documentation/mm/unevictable-lru.rst | 2 + include/linux/shmem_fs.h | 1 + mm/shmem.c | 68 ++++++++++++++++++---------- 3 files changed, 48 insertions(+), 23 deletions(-)