From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-201.mta1.migadu.com [95.215.58.201]) (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 72153451993 for ; Tue, 18 Aug 2026 10:41:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787049676; cv=none; b=nIvcSI0GScHOaStF0AoyaN1gBbjYsJGvr2BaHN1u5DmR7zuEVBYUs0YHhktL8Qml2EQJlRtlu54VX4wO0yQ/aLVHNeEBVcXeGq+iHF+aGliD6V8tipBtLhnVLkROkZZjjBTJ7dJrEJ2u/liBJjmHLxsDBz2jww5Vq0Gb/5MjYfg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787049676; c=relaxed/simple; bh=AdNpCvXjbRVRUh+sR7PvZD45HE1LNZ7V1IsV7Ihzn3w=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=TX7ldUWVhmHJpcVwAdNU2ZiHwYj1htRXDhWAe4hI984SuqDtMFupTNkaccLcB/8x6QhTFnyz9L1qldvJ/m/b0pB7TA9kJUVtapJfgwZvnSQy7msKicbj2phbfHSdxyV1gUSyBMMqA1v4tPmw7sYfn3StM6++HKFEvDTnZzmBoCQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=X4sxeJL+; arc=none smtp.client-ip=95.215.58.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="X4sxeJL+" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=AdNpCvXjbRVRUh+sR7PvZD45HE1LNZ7V1IsV7Ihzn3w=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787049668; v=1; x=1787654468; b=X4sxeJL+H4UR28y4hXeLq56kntuoUsQ4T17Tf8FObKNf166FddwYAUyOxLtTd2vU/4oYLRpA +BE8VXrsbwfWUTrvW005UqlCfV+9UpIyJAIvxS7PbeNCQ+pkzNY5bCRCcsyKMZDjpPv+4RTGdyJ UvX4NXnuHacZPbUQ6iPXRIpE= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost (2a02:168:f6cc:0:a69a:f3a4:8fdd:3332) by smtp.migadu.com with ESMTPS id 675f5a73bd14fb8f; Tue, 18 Aug 2026 10:41:08 +0000 X-Migadu-Flow: FLOW_OUT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 18 Aug 2026 12:41:07 +0200 Message-Id: Cc: "Borislav Petkov" , "Dave Hansen" , "Peter Zijlstra" , "Andrew Morton" , "David Hildenbrand" , "Vlastimil Babka" , "Mike Rapoport" , "Wei Xu" , "Johannes Weiner" , "Zi Yan" , "Lorenzo Stoakes" , , , , "Sumit Garg" , "Will Deacon" , , , "Itazuri, Takahiro" , "Andy Lutomirski" , "David Kaplan" , "Thomas Gleixner" , "Patrick Bellasi" , "Reiji Watanabe" , "Sean Christopherson" , "Nikita Kalyazin" , "Ackerley Tng" Subject: Re: [PATCH v3 03/26] mm: introduce AS_NO_DIRECT_MAP From: "Brendan Jackman" To: "Yosry Ahmed" , "Brendan Jackman" X-Mailer: aerc 0.21.0 References: <20260726-page_alloc-unmapped-v3-0-6f5729aa9832@google.com> <20260726-page_alloc-unmapped-v3-3-6f5729aa9832@google.com> In-Reply-To: On Tue Aug 18, 2026 at 2:32 AM CEST, Yosry Ahmed wrote: >> >> >> diff --git a/mm/mlock.c b/mm/mlock.c >> >> >> index efa6716e4dfbd..045b6779440b1 100644 >> >> >> --- a/mm/mlock.c >> >> >> +++ b/mm/mlock.c >> >> >> @@ -474,7 +474,7 @@ static int mlock_fixup(struct vma_iterator *vm= i, struct vm_area_struct *vma, >> >> >> int ret =3D 0; >> >> >> =20 >> >> >> if (vma_flags_same_pair(&old_vma_flags, new_vma_flags) || >> >> >> - vma_is_secretmem(vma) || !vma_supports_mlock(vma)) { >> >> >> + vma_has_no_direct_map(vma) || !vma_supports_mlock(vma)) { >> >> > >> >> > I don't think this one is correct. From commit 1507f51255c9 ("mm: >> >> > introduce memfd_secret system call to create "secret" memory areas"= ): >> >> > >> >> > Since the secretmem mappings are locked in memory they cannot exc= eed >> >> > RLIMIT_MEMLOCK. Since these mappings are already locked independ= ently >> >> > from mlock(), an attempt to mlock()/munlock() secretmem range wou= ld >> >> > fail and mlockall()/munlockall() will ignore secretmem mappings. >> >> > >> >> > Seems like secretmem pages are just mlock()'d by default, hence the >> >> > check here. Maybe this also works for guest_memfd, but I don't thin= k >> >> > it's a generalization that any pages without a direct mapping shoul= d >> >> > receive the same treatment here. >> >>=20 >> >> Ack, yeah this sounds correct to me. >> >>=20 >> >> I guess you could argue something like "the reason secretmem is >> >> implicitly mlocked is that it can't be reclaimed, because there's no >> >> direct map". But that doesn't generalise IMO, you could imagine letti= ng >> >> the user say "remove this memory from the direct map, but I trust my >> >> swap system, you can swap it" and then use the mermap to implement >> >> reclaim. >> > >> > Exactly, I don't think no direct mapping implicitly means unreclaimabl= e. >> > I don't think you actually need a direct mapping to read/write from >> > disk to memory? >>=20 >> Oh. I never thought about that! I suppose the DMA is gonna happen via >> some other address space, either it's via an IOMMU or it works directly >> on physical RAM. So the kernel's direct map is irrelevant... Is that >> universal though? There must be cases where the CPU's mappings still >> matter... Umm... needs more research! >>=20 >> (Don't think this blocks anything in this series though, let me know if >> you disagree...) > > I think we probably just wanna keep the secretmem check here instead of > generalizing to all unmapped pages being mlocked? Oh yeah I think so too. The above is all just pondering longer-term questions.