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 A8BDDC3DA45 for ; Thu, 11 Jul 2024 20:07:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2F2D76B009C; Thu, 11 Jul 2024 16:07:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A2A26B009F; Thu, 11 Jul 2024 16:07:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16A2E6B00A1; Thu, 11 Jul 2024 16:07:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E24CE6B009C for ; Thu, 11 Jul 2024 16:07:40 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 310F1A07E2 for ; Thu, 11 Jul 2024 20:07:40 +0000 (UTC) X-FDA: 82328557080.22.86E7352 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id 5967280021 for ; Thu, 11 Jul 2024 20:07:38 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=lgQNcIYt; dmarc=pass (policy=quarantine) header.from=zx2c4.com; spf=pass (imf02.hostedemail.com: domain of "SRS0=Le2v=OL=zx2c4.com=Jason@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=Le2v=OL=zx2c4.com=Jason@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720728421; 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=DNdo2jHrY/IOSCFrJ93vxKtkJPtxtIos5+7ObgdaWQc=; b=T9qE3w2Yu9NcWoIfezJVMU2LGwUwVCCGHy2q2vJsPTdtFopIHWLElRpp78ANvpu4YZi9BG MOnENQvAlRtLnfLnxXqNnD5EB+4nBl9Q1cbOqJSUQbHYBgL23E/n+3R6IJPISffZSY/aZE yTmwyAr+9n3KeTKUjl8bbp42lT/2J+k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720728421; a=rsa-sha256; cv=none; b=w8gV6cp9QkaTSpqNZRWnXv+D7eWsqWPfrmrMmmsEbCXbXkADd2rwMIOpvSu4lv/iKns3tB W2a+D7dlckvcvsPsmPMIOYiFTznKDno+zf8ljFU0ANNj8DyLQyuxkgbEDRJmdAclV0DKiW YhQpdkk6U6pqyNmQ2YC7X1VQy1bw5GE= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=zx2c4.com header.s=20210105 header.b=lgQNcIYt; dmarc=pass (policy=quarantine) header.from=zx2c4.com; spf=pass (imf02.hostedemail.com: domain of "SRS0=Le2v=OL=zx2c4.com=Jason@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=Le2v=OL=zx2c4.com=Jason@kernel.org" Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6457A61DDB; Thu, 11 Jul 2024 20:07:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72243C116B1; Thu, 11 Jul 2024 20:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1720728453; 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=DNdo2jHrY/IOSCFrJ93vxKtkJPtxtIos5+7ObgdaWQc=; b=lgQNcIYtqgWSPoe7Cx4AcSLb9J+QfSbCUixBhBJvYlxEE1Lzsyh6WkLBb6U/EWGhY0760F 1SNYJbibFL67nsr+nkaJKo9u0ehTmV2CCIByy0wQFwW6RK6nqdnXn4dJNCeTU6WJVq8fcw m+k5ajRjjWlfcvMXDyCJC2EbqnJdNVo= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id a218a39f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 11 Jul 2024 20:07:33 +0000 (UTC) Date: Thu, 11 Jul 2024 22:07:30 +0200 From: "Jason A. Donenfeld" To: Linus Torvalds Cc: David Hildenbrand , 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, 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: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 5967280021 X-Stat-Signature: 6x1uo47i9jxdinoqe56y4dnszeqp861x X-Rspam-User: X-HE-Tag: 1720728458-597186 X-HE-Meta: U2FsdGVkX18Dz2elFV/ZT5xWgzelFD6BB53s0xt283Vxed2GSPeVNTym1inzBNZNBxzF3ZxgRGH8hSe9M/U4JjJ/L/yQqLVyVfTRHhOakmedXLg+s7pdJaY+BUxc7mSbEv94B5MexiioYXwNfnfPg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eHwio9A3SE2XUPVeJwG8efXgvtDVxU8tV7xR5vaYpn7nh6DNf9bTSy/YLLOB2elFjR95MXTRw2XcYIz7aBjFkhn2Q6HbSVr0VEhB26SYyJnj58JfpYzEwoFvfuUl0tOLzpBAhJbkNnXED1g10tdRX08UZYLi//61VJYIOrRCHevtfMChdfqNxLW6MwZAJz4XNNH91B0I1VK0WNHMZZBPARfGTYA134UQ4IlrqdP097hK5Ms550Jix+1jqF+bjB4as8tJVQ6FtooyD0Ge5bDX0dlQbqeHUu1fRT4Qw+NM2BBeHdV9nJ1+FP/YW9xlz4A 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 Linus, On Thu, Jul 11, 2024 at 10:57:17AM -0700, Linus Torvalds wrote: > May I suggest a slightly different approach: do what we did for "pte_mkwrite()". > > It needed the vma too, for not too dissimilar reasons: special dirty > bit handling for the shadow stack. See Thanks for the suggestion. That seems pretty clean. It still needs to avoid setting swapbacked in the first place, but ensuring that it's never dirty means it won't get turned back on. The first patch renames pte_dirty() to pte_dirty_novma(). The second patch adds an inline function, pte_dirty(pte, vma) that just forwards the pte to pte_dirty_novma(), and then converts callers that have a vma available to pass to call pte_dirty(). And then the VM_DROPPABLE patch simply adds the `&& !(vma->vm_flags & VM_DROPPABLE)` condition to pte_dirty(). I put these in https://git.zx2c4.com/linux-rng/log/ per usual, and I'll post a new version to the list not before long (unless objections). Jason