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 DE22FC3DA41 for ; Thu, 11 Jul 2024 00:44:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4688D6B008C; Wed, 10 Jul 2024 20:44:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 418AA6B0092; Wed, 10 Jul 2024 20:44:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DF916B0093; Wed, 10 Jul 2024 20:44:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 09C876B008C for ; Wed, 10 Jul 2024 20:44:45 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7AE07A180A for ; Thu, 11 Jul 2024 00:44:44 +0000 (UTC) X-FDA: 82325626488.04.7AF49F2 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf18.hostedemail.com (Postfix) with ESMTP id 4BCAB1C0013 for ; Thu, 11 Jul 2024 00:44:41 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b="I/hoIoKX"; spf=pass (imf18.hostedemail.com: domain of "SRS0=Le2v=OL=zx2c4.com=Jason@kernel.org" designates 145.40.73.55 as permitted sender) smtp.mailfrom="SRS0=Le2v=OL=zx2c4.com=Jason@kernel.org"; dmarc=pass (policy=quarantine) header.from=zx2c4.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720658651; h=from:from: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=kuZ1HiO9Y8r/sLpAoJXiKvAt2rOz6kI6hysFfLehduw=; b=x+ZIl4AWO0wSIyNaElt9iwidGALSKOdLbnBsbFcHhzChv7vLjK+jwPqk+KiL2Kf8t+4Fyc e1YWj1s0v8sz2HZTWJY12yMawr42+LoWuhPl9DitySLYdXFLE41uqQejFRGWfr86MLLlvD /hS6vMpvrmJxQnIx1phS4XUiek714hw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720658651; a=rsa-sha256; cv=none; b=UrV0BK8njp3L1XShvOq+DiqdhL6NifxrcilPqqqRvbIfItKveIfvWUkmKyfUxjPeHXxEuF /KY+a/w6ImeBJocpHmCnB4zHir1QTeXefN5vuuNW9YetazOgAVOEgeH62rKfQKJefbm9L4 +3s6UVzE5csG5SVNPtKbLaTr2uSEPoc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b="I/hoIoKX"; spf=pass (imf18.hostedemail.com: domain of "SRS0=Le2v=OL=zx2c4.com=Jason@kernel.org" designates 145.40.73.55 as permitted sender) smtp.mailfrom="SRS0=Le2v=OL=zx2c4.com=Jason@kernel.org"; dmarc=pass (policy=quarantine) header.from=zx2c4.com Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7C435CE17D2; Thu, 11 Jul 2024 00:44:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4082BC32781; Thu, 11 Jul 2024 00:44:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1720658674; 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=kuZ1HiO9Y8r/sLpAoJXiKvAt2rOz6kI6hysFfLehduw=; b=I/hoIoKXpOqAebd3Q6dksAur7IWQreJQrmqOgPBMkC41LbV+Gs3qlm8HJ0RI+AFTxwd953 viC6VBVudlnaoF2hIZUN2etOR/EiC0Xh3yyaw7xLtvuCCWqidFzW3T36Y5ndCbsFbEXgTF tv3YxeXL9aOyryZYPrRJhqe4InMV1jc= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 78ba0ae2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 11 Jul 2024 00:44:33 +0000 (UTC) Date: Thu, 11 Jul 2024 02:44:29 +0200 From: "Jason A. Donenfeld" To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, tglx@linutronix.de, linux-crypto@vger.kernel.org, linux-api@vger.kernel.org, x86@kernel.org, Linus Torvalds , Greg Kroah-Hartman , Adhemerval Zanella Netto , Carlos O'Donell , Florian Weimer , Arnd Bergmann , Jann Horn , Christian Brauner , David Hildenbrand , linux-mm@kvack.org Subject: Re: [PATCH v22 1/4] mm: add MAP_DROPPABLE for designating always lazily freeable mappings Message-ID: References: <20240709130513.98102-1-Jason@zx2c4.com> <20240709130513.98102-2-Jason@zx2c4.com> <378f23cb-362e-413a-b221-09a5352e79f2@redhat.com> <9b400450-46bc-41c7-9e89-825993851101@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <9b400450-46bc-41c7-9e89-825993851101@redhat.com> X-Rspamd-Queue-Id: 4BCAB1C0013 X-Stat-Signature: 3aprthro6qy8drzfjypjbbix94mp1d8g X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1720658681-573860 X-HE-Meta: U2FsdGVkX1+I2mtmT8Ndx5mQBLvwPqj4j3MeHd+xK3mhrS/G4aXY9UD9n3HopFQnDWTlpjRI4C+q7exHV9zucL9H3YnggA7u5lqSZTI69kiLUmT1JFL7iOq9XkG4SV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YtRAbQdGK+bDfmwAaSLvZfsNWRFuZXIGTXweabq7TSeh4cDJlU/BPg+lRET8jqzdP2DakdA7Ac4Ht33PzXDxW3ZFBXT2zevmGBVP1xdOC3+X4L29gNxx3D+po6q7Ag9AClCX9X7QNCZO1himE/iqsMsQ8Xlc+JXTJVqq469PetmRfNweQyeB9e8pZKcMuJFVEWMFyW1ooCVUbrESnNU+kvzTA5h29oRrGLh0yLvu8Olbz6IPNJzPEE= 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: List-Subscribe: List-Unsubscribe: Hi David, On Wed, Jul 10, 2024 at 06:05:34AM +0200, David Hildenbrand wrote: > BTW, do we have to handle the folio_set_swapbacked() in sort_folio() as well? > > > /* dirty lazyfree */ > if (type == LRU_GEN_FILE && folio_test_anon(folio) && folio_test_dirty(folio)) { > success = lru_gen_del_folio(lruvec, folio, true); > VM_WARN_ON_ONCE_FOLIO(!success, folio); > folio_set_swapbacked(folio); > lruvec_add_folio_tail(lruvec, folio); > return true; > } > > Maybe more difficult because we don't have a VMA here ... hmm > > IIUC, we have to make sure that no folio_set_swapbacked() would ever get > performed on these folios, correct? Hmmm, I'm trying to figure out what to do here, and if we have to do something. All three conditions in that if statement will be true for a folio in a droppable mapping. That's supposed to match MADV_FREE mappings. What is the context of this, though? It's scanning pages for good ones to evict into swap, right? So if it encounters one that's an MADV_FREE page, it actually just wants to delete it, rather than sending it to swap. So it looks like it does just that, and then sets the swapbacked bit back to true, in case the folio is used for something differnet later? If that's correct, then I don't think we need to do anything for this one. If that's not correct, then we'll need to propagate the droppableness to the folio level. But hopefully we don't need to do that. What's your analysis of this like? Jason