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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D86FAC636D6 for ; Thu, 23 Feb 2023 00:53:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 21C966B0072; Wed, 22 Feb 2023 19:53:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CC266B0073; Wed, 22 Feb 2023 19:53:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 094B56B0074; Wed, 22 Feb 2023 19:53:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id EE5A56B0072 for ; Wed, 22 Feb 2023 19:53:35 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9F1CC1A0EAB for ; Thu, 23 Feb 2023 00:53:35 +0000 (UTC) X-FDA: 80496733590.18.5B12A94 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf09.hostedemail.com (Postfix) with ESMTP id 7B47D14001A for ; Thu, 23 Feb 2023 00:53:33 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Rps9j5Y6; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf09.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677113613; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/VWMyfgJQqN+LT+oGtb6fBZ/QWKOOt48ECAn8krTz9w=; b=s0E07FZRaZVSIZSFUU2p4rnciPPVIS55D/xQjsZgY9b78+6LgoYra+7s9Zt3wQoVH/qKou zak9BKL6ybsIeAVEG2MOBBJxVgfE0WidCETcgdNTqEBB0RItBwVISQrul8rfYFgg22FvR7 4ZqwQsKLT2y6nJoQND60r8T6u8BtpPQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Rps9j5Y6; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=none (imf09.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677113613; a=rsa-sha256; cv=none; b=1Ej6j2WxWMTNOZ/GM6noa/T9r0MBOFVXurKEbImv4ulcGRaISPVF7RZz3MSDpb7Fd+t415 ZmfRc8NVJEFwOzQ2hGT+HYt3pcELxxF9wpRdjGU2AxQRTQKvFJ6LxsaoDOUFqeRtxGq1Po BxHMoldnzoMdmYnbCrCfTiBVb8BPnBo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/VWMyfgJQqN+LT+oGtb6fBZ/QWKOOt48ECAn8krTz9w=; b=Rps9j5Y6XUVqHSB4VV2euMpcDb /YBvZMPV2A76Pv5PGCHIKLSP23TbsHymBzuJJ0LG76L67zRW5f26ACnHDZIC0O90XE0LUrkqaS4qT oxsFZP0eq9fo1BqNQEsA2VaRkRfUXqlIOeemmt/mmFR1Waj/FHedXJvDtA7zmZBxZ/wWf7hDnH5wl YjNFSXftDGLgJYmEEYWLtuFDIrdLdgP4GAkGq6UYYc/hXqNL1Z9S2jxQiT9KPZ6fbLy2NnHBO0LBf VKBkhmJvD5JEKIjAjRYtjB7Z7StpqpWv+Dwh/ELUvvEQqfcz3V+XtT6b6ml4qGJA+lElR1SOLhQdv ef2PKDnA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pUzrK-00Ea9B-ON; Thu, 23 Feb 2023 00:53:18 +0000 Date: Wed, 22 Feb 2023 16:53:18 -0800 From: Luis Chamberlain To: Yosry Ahmed , "Eric W. Biederman" Cc: Matthew Wilcox , 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: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 7B47D14001A X-Stat-Signature: 7tzcoqgy4564ddrattu1kdmh1ch8rqsn X-HE-Tag: 1677113613-310419 X-HE-Meta: U2FsdGVkX1/S1pfpQqpoAggJFuniDxDsdvV+shyzcF9ef/POEharvC0KEInzgBz1PNZUmUl5mLf4Cr26duJxQfjXISkp48mptfIqWlcXfiN0nAx+m8J8GalFCLQsF//qUwAodgTCu8f6DNqZTE7f8hrZzB9bj1dnmu3jM4xW8Ld5nVRzAZ+RSRfkjg8kRvqpuIopdj88uY5H0QG0AMmZ4YRWgHzadHrU+UYbqCcD/dAySrzIrI0gNHcwJvTmUA9mUtWmqjTVg56BRON9pfUAiATcABQr72inSZrT4Hk+RPCdTUxK4pJO8tewJtd9Iy79vGoDWGP+/qCaF0N2QoNu9mRzMD8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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: On Wed, Feb 08, 2023 at 12:33:37PM -0800, Yosry Ahmed wrote: > On Wed, Feb 8, 2023 at 9:45 AM Matthew Wilcox wrote: > > > > 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. > > > > Wouldn't this cause the folio to not show up in any lru lists, even > the unevictable one, which may be a strange discrepancy? > > Perhaps we can do something like shmem_lock(), which calls > mapping_set_unevictable(), which will make folio_evictable() return > true and the LRUs code will take care of the rest? If shmem_lock() should take care of that is that because writepages() should not happen or because we have that info->flags & VM_LOCKED stop gap on writepages()? If the earlier then shouldn't we WARN_ON_ONCE() if writepages() is called on info->flags & VM_LOCKED? While I see the value in mapping_set_unevictable() I am not sure I see the point in using shmem_lock(). I don't see why we should constrain noswap tmpfs option to RLIMIT_MEMLOCK Please correct me if I'm wrong but the limit seem to be designed for files / IPC / unprivileged perf limits. On the contrary, we'd bump the count for each new inode. Using shmem_lock() would also complicate the inode allocation on shmem as we'd have to unwind on failure from the user_shm_lock(). It would also beg the question of when to capture a ucount for an inode, should we just share one for the superblock at shmem_fill_super() or do we really need to capture it at every single inode creation? In theory we could end up with different limits. So why not just use mapping_set_unevictable() alone for this use case? Luis