From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28FEA345CDC for ; Fri, 27 Feb 2026 06:35:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.214.176 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772174111; cv=pass; b=ciMomrdMB/OECjkso1SyhxY+AaG6lCDEQnYDOGPK9AGmc4w4wlHeeNf+A2TGKYH1RhzVrEeJ/gGn041EVB0+1BSWIrw0VtyND5HSKvkcs1Z4WdP/pUgiSopqo7fXwBMcx+Pwy/zKabzrE9cLqCDxecWggalfGnfOlBxcopYBWFo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772174111; c=relaxed/simple; bh=gGxzmXjY9SbWuXMhHQnBpU0orZgk3BtEHZo3GxuM3Cc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=aWMD2gfi1FoY52DtGKIAvaQ98FDX4cOtGNqg6x1lT1ThBDK3GfUx1S8Mweme1Tjif0y5jW7S2BzENVehjsIS7vx7Q/SD7AirZq8vSHE9/LBxK+fcGEOF6wiAZYL4BWmA79g3QB1IQ9IZXcvfmTovwVI2QmUYNsWX7pSD2q7xZBw= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=udLOHJ9K; arc=pass smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="udLOHJ9K" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2ada9e4ea32so39705ad.1 for ; Thu, 26 Feb 2026 22:35:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772174109; cv=none; d=google.com; s=arc-20240605; b=DruTBd7ymyL/Rmf1+Dt6t9Bf4Hz1IXmY3I7ofmgTOYhz8sr+c19/G0pwSRiYR3kpm1 Q6926wJaMGuIhk9Tp6k/wo/DUMgApmGo/fpzRscKUWnyyZJKmN5hsxmRUYEd5cmEmJHr MpmodXuFJk9y7S7cdZhnWmDixkGUwofCZuaQSrKnE8LqwphqhEjlcvoPIsY5Rq5fe3/y 9Q53/UBgPTsQvyD4f+vZDv2Qrd4R0g53jmKJOSLlldvGyQxFzX43vhApxqb2fcdY2bQu nd5GE848D7PXOtMzz1bNeHOBuHMhi6b9O/PU3uJ/cASMq7DjuvloqPcmRT8HWsocrLgr yhrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=5vaa8akeEgfUaZjeRn+BA3sQx4L7fWbq7ZmVurp4ODs=; fh=0IUit9QaVW80AVD1ACfvob8jtpbZ/zhbSNfuWqTfxyA=; b=dfWjjjxYLePVUWyjfnKnQcvbDG856q+2WN3bsIRexJwY9zS0DbUMbsN9fz4s2HEfJd p9CLsVO62nQmk0h6hSscXFDg08lnLsATYYQvGnKBinFk18B98iHmOMIaRiOyfbOwvuQq Fs6Qyo0BaeG5buKU6fhdtMDM10fhcbh+PKXD4wvNuwzmy+GifCY8YXIAyqE7EkW3ABMV bmDPXVdVx12+wLkm2aCnj6ykKUhWRRXyhWGYUpLFY6FrS3H8lT+Y43NpO+XivkW9B3ms X4C5flVASZS4Fimil0r7J2n1G7KZrgZUXg5GmC8lpgy91sZV09kAqcZZxf8ntJ9B3QTS YeWA==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772174109; x=1772778909; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5vaa8akeEgfUaZjeRn+BA3sQx4L7fWbq7ZmVurp4ODs=; b=udLOHJ9KnAe6WWcjXhYn7r0ms1pxAvcm3bSYcele+NQWjlUoG2EvNeEONsELfNW2EO rzQFLrTsdOiUfvBFaPN5ufgkC9kFcCqbFzxMhaKkLRjeO+IO8KRrATAF8Db/U16F3Svb 5r77NhEELijbyGFXYEbWYzIQdTvCYYiZpmXIfF0uz6kLPyJD8T896Nc8Yh4aimgXR7kJ sfd6xHVVVNyIf61oEo34ZSg3MDSks52qHuSJ7luiugxiTTjhaX/foo8enGBgbBWtsRMd vx4XUAONYlv8jC9UiZR6tZzdk5F6HzZvPtr8sfeQSdCCECyawrM3eST1qNwldGlEmQes ms1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772174109; x=1772778909; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5vaa8akeEgfUaZjeRn+BA3sQx4L7fWbq7ZmVurp4ODs=; b=k3us5u5ZJv9LEAdfgtMWUiJ9wNzvpffg90sloGEBAMbI3m5qMpDGWtM7N2/6SDh89K 61iwU3yntjGgo7EpN5zqQRO/6UrM/gcf7q4YTj4AV80cWmgQZD0fUe0kAFS87qkC6l9R 28iT1im3GR2T3seddtB2l31/y/Wl7+DHWRJmKIWFDh1K3PKmxGRiBlApKniaLIeaRiel zgOOD/JUITMEVakvK7SEczIL+qcVYz3JIQcgxK/5lsjD/CTwyuoeCmAplH9sbrOY1EQP TBCUwwhYAw59tIc1IzSTQnE6TWm5TgQtJdZrIpnl4Bq90GBUUBR+orJJCpekH2sp5+BW 66kw== X-Forwarded-Encrypted: i=1; AJvYcCU2gZsS6KtUw26PnSJiP5PyOWWvM/hFTcZQ9ROYallUHtvO7NQtZ/haJR1J4OQloMGQPzk1hPtSE45BvVA=@vger.kernel.org X-Gm-Message-State: AOJu0YwfQ8C39GFl+uWQdXmdefA84tmsJi9nogPzZPnCObSYOJ19UuXU XRj9ea1evBLIXLLM2wyzIJtLmpwBdaeW/9JOWTaj2XdF71rZoqvI/su+G7Ahw6QaBuKfYaR7cSa ATqSWwQqIOtUUNwi4BjkFKu/nvx2R4+tEsI34tnwO X-Gm-Gg: ATEYQzy3656Ubhgoc1tyOR7qhM6JM0UYn2/BETbJH28pfSwxVZY/cjcuUVVtezH24HE KTFUbmR+PzmqlVeBupBmjKTSvqj+5J5+O/oLbqmCh/bWS3EG9IdgMMGMuR/A2D59rhpr/r4aSt7 vNCIM5UmJDdE3k/5kUfB+SrbmyIGnriTxkZ/0ilcisRJuuQtS3sO9eKPMvifrxkECuWrTXbe+uO vxxrQVFuMrxXzjvBuPEyEP3vgiV+/EiPfAxSbRs6xr5QoU2NSrjzpm9b8qgijTJkvaZYJINAOoJ hoYoxcs/Dk/VgtDgQljeHPcoBUcVew74fpDtq/rD X-Received: by 2002:a17:903:2a86:b0:29e:27f4:bac0 with SMTP id d9443c01a7336-2adf77c692amr4716545ad.16.1772174108996; Thu, 26 Feb 2026 22:35:08 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20250820010415.699353-1-anthony.yznaga@oracle.com> <5tdailzxoywzzunbwhtlk4yjfmzunntniqtudkb52q6hib74ql@oq4mi226dedv> In-Reply-To: <5tdailzxoywzzunbwhtlk4yjfmzunntniqtudkb52q6hib74ql@oq4mi226dedv> From: Kalesh Singh Date: Thu, 26 Feb 2026 22:34:56 -0800 X-Gm-Features: AaiRm50sVIIQTfT7ctHM4g1t99KQJhS99wa_T7m6oioVRZFMpAuvQzucC4RWMJU Message-ID: Subject: Re: [PATCH v3 00/22] Add support for shared PTEs across processes To: Pedro Falcato Cc: "David Hildenbrand (Arm)" , Anthony Yznaga , linux-mm@kvack.org, akpm@linux-foundation.org, andreyknvl@gmail.com, arnd@arndb.de, bp@alien8.de, brauner@kernel.org, bsegall@google.com, corbet@lwn.net, dave.hansen@linux.intel.com, dietmar.eggemann@arm.com, ebiederm@xmission.com, hpa@zytor.com, jakub.wartak@mailbox.org, jannh@google.com, juri.lelli@redhat.com, khalid@kernel.org, liam.howlett@oracle.com, linyongting@bytedance.com, lorenzo.stoakes@oracle.com, luto@kernel.org, markhemm@googlemail.com, maz@kernel.org, mhiramat@kernel.org, mgorman@suse.de, mhocko@suse.com, mingo@redhat.com, muchun.song@linux.dev, neilb@suse.de, osalvador@suse.de, pcc@google.com, peterz@infradead.org, rostedt@goodmis.org, rppt@kernel.org, shakeel.butt@linux.dev, surenb@google.com, tglx@linutronix.de, vasily.averin@linux.dev, vbabka@suse.cz, vincent.guittot@linaro.org, viro@zeniv.linux.org.uk, vschneid@redhat.com, willy@infradead.org, x86@kernel.org, xhao@linux.alibaba.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Isaac Manjarres , "T.J. Mercier" , android-mm Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Feb 26, 2026 at 1:22=E2=80=AFPM Pedro Falcato wr= ote: > > On Wed, Feb 25, 2026 at 03:06:10PM -0800, Kalesh Singh wrote: > > On Tue, Feb 24, 2026 at 1:40=E2=80=AFAM David Hildenbrand (Arm) > > wrote: > > > > > > > I believe that managing a pseudo-filesystem (msharefs) and mapping = via > > > > ioctl during process creation could introduce overhead that impacts > > > > app startup latency. Ideally, child apps shouldn't be aware of this > > > > sharing or need to manage the pseudo-filesystem on their end. > > > All process must be aware of these special semantics. > > > > > > I'd assume that fork() would simply replicate mshare region into the > > > fork'ed child process. So from that point of view, it's "transparent"= as > > > in "no special mshare() handling required after fork". > > > > Hi David, > > > > That's agood point. If fork() simply replicates the mshare region, it > > does achieve transparency in terms of setup. > > > > I am still concerned about transparency in terms of observability. > > Applications and sometimes inspect their own mappings (from > > /proc/self/maps) to locate specific code or data regions for various > > anti-tamper and obfuscation techniques. [2] If those mappings suddenly > > point to an msharefs pseudo-file instead of the expected shared > > library backing, it may break user-space assumptions and cause > > compatibility issues. > > I'm not worried about transparency because this is not supposed to be > transparent. This is not supposed to be used by most core system software= . > This is supposed to help replace hugetlb page table sharing. > Hi Pedro, Thanks for the detailed breakdown. Firstly let me state that my goal definitely isn't to derail or block the current mshare efforts. I'm mostly just trying to gather feedback on what a "transparent", approach might actually look like. > Transparent page table sharing has other constraints. I like the idea, in > theory, but there are a number of constraints that make the idea unfeasib= le > for now. There are a couple of problems we need to solve first: > > 1) Every spot where we modify PTEs needs to be assessed and use different > helpers (that can un-cow page tables). Every pte_offset_map_lock() can no= w > feasibly fail for OOM reasons (and that also needs to be assessed). > What if we strictly limit the scope to just read-only mappings being shared? Would un-COWing still be necessary? > 2) Various bits of PTE modification/unmapping now needs special care wrt = TLB > invalidation. The kernel needs to be aware of how the page tables are sha= red. > I don't think the current rmap data structures are well suited to this ki= nd > of stuff (perhaps with Lorenzo's WIP anon rmap rework we'll get something > better). Basically every spot that goes "modify PTE, flush TLB for mm" no= w > needs to go "modify PTE, for every mm that maps this page table, flush $m= m" > (if you're thinking that COW will save us, it technically won't, or shoul= dn't, > because of stuff like try_to_unmap_one() that is used in reclaim). I think this bit might need to be architecture dependent. With shared TLB partitioning on certain hardware, this becomes much less of an issue. We could potentially gate this behind something like CONFIG_ARCH_HAVE_SHARED_TLB_SUPPORT (or a similarly fitting name) so only architectures that can handle the invalidation efficiently opt in. > > 3) Reclaim loses even more information as now N processes share the same = A > bits. I don't know what effects this can cause. It would require > experimentation. Perhaps something like "if page table is shared, value > pte_young more". I don't know if this can work as a bandaid, but it's not > ideal. I agree this will require some experimentation. Intuitively, I like to think these shared pages might naturally stay "hotter" since multiple processes are accessing them concurrently, but we will definitely need to experiment with the reclaim logic to see hwo ti does in practice. > > 4) It's not known whether page table COW fork() is a real win in most cas= es, > or all cases. Would want measurement. Our preliminary data on Android shows this can save ~200MB or more on mobile devices right after boot. On memory-constrained client devices, that is a significant win. > > 5) It becomes even harder to estimate RSS and PSS for each process. For PSS (PAGE_SIZE / mapcount), I can see that a single mapcount from all the processes mapping the page through the shared page table would skew the result. Though, I find PSS not perfect already; I think processes can artificially lower their PSS by mapping the same file multiple times. For RSS, I'm not sure I see the blockers to aggregating across the private and shared mm_structs? > > For these reasons (and more, certainly), I don't think working mshare() i= nto > a transparent, all-great thing that fits the zygote model can work. It ha= s been > discussed at length how to pull off certain hard bits like TLB invalidati= on and > locking for mshare, and with mshare we have the advantage of not needing = to > support every feature ever (tailoring it more to the big database users o= f > hugetlb). And we'll still need to adapt certain bits of arch code just to= get > it to work efficiently. > > This said, if you want to discuss pulling this off, I'm all ears and it c= ould > be perhaps a fun discussion (too late for LSF, I guess), but I don't thin= k > it's workeable into the current mshare efforts. And, believe me, I would = love > a unified feature here :) I saw Anthony proposed an mshare topic for LSF/MM; I hope to be there as well, it would be great to chat about this in person. Thanks, Kalesh > > -- > Pedro