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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1B07C636CC for ; Wed, 8 Feb 2023 17:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231764AbjBHRrN (ORCPT ); Wed, 8 Feb 2023 12:47:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbjBHRqz (ORCPT ); Wed, 8 Feb 2023 12:46:55 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C3825356C for ; Wed, 8 Feb 2023 09:45:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=jtZ9usIqG10mDaEiQbcVXECDWkMgFMufDpS54uMpync=; b=ogX0Ke7Lx2PsPOC0o8QOf7t6j1 u6S+DZmGyBpy+o2bYp1R2GA0dLpUU/+FJQUBk7Q5eMxyrOdn8D6Eh9edkiQ7d0sQuTyA5Ks4NyIDx bnFNHfIQT09ig+fEaUyFJfrOaRn468ebvpyl5KLXwMm72CsNV/vSvIohWaJtpoI0ggmnvSL/Ez5N+ wz9dxcfv1I7/r3rVXIy3cWtBa6Q1JDSR+TKQ6tWWlNlGt0VYZw6ymZEdgNo4E1nfFv+c2Z9a3iUp7 e1nl/3dhnS4SX2N2Z9hi7cH7DoiCCf2yrJmp01wpOZ8Lkr2o/u7WP6Y9BFbrK4Os7jLSeyFqLD3aM GBWQgxqg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPoVP-001QMo-0x; Wed, 08 Feb 2023 17:45:15 +0000 Date: Wed, 8 Feb 2023 17:45:14 +0000 From: Matthew Wilcox To: Luis Chamberlain Cc: hughd@google.com, akpm@linux-foundation.org, linux-mm@kvack.org, p.raghav@samsung.com, dave@stgolabs.net, a.manzanares@samsung.com, linux-kernel@vger.kernel.org Subject: Re: [RFC 2/2] shmem: add support to ignore swap Message-ID: References: <20230207025259.2522793-1-mcgrof@kernel.org> <20230207025259.2522793-3-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 08, 2023 at 08:01:01AM -0800, Luis Chamberlain wrote: > On Tue, Feb 07, 2023 at 04:01:51AM +0000, Matthew Wilcox wrote: > > On Mon, Feb 06, 2023 at 06:52:59PM -0800, Luis Chamberlain wrote: > > > @@ -1334,11 +1336,15 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) > > > struct shmem_inode_info *info; > > > struct address_space *mapping = folio->mapping; > > > struct inode *inode = mapping->host; > > > + struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); > > > swp_entry_t swap; > > > pgoff_t index; > > > > > > BUG_ON(!folio_test_locked(folio)); > > > > > > + if (wbc->for_reclaim && unlikely(sbinfo->noswap)) > > > + return AOP_WRITEPAGE_ACTIVATE; > > > > Not sure this is the best way to handle this. We'll still incur the > > oevrhead of tracking shmem pages on the LRU, only to fail to write them > > out when the VM thinks we should get rid of them. We'd be better off > > not putting them on the LRU in the first place. > > Ah, makes sense, so in effect then if we do that then on reclaim > we should be able to even WARN_ON(sbinfo->noswap) assuming we did > everthing right. > > Hrm, we have invalidate_mapping_pages(mapping, 0, -1) but that seems a bit > too late how about d_mark_dontcache() on shmem_get_inode() instead? I was thinking that the two calls to folio_add_lru() in mm/shmem.c should be conditional on sbinfo->noswap.