From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96C2C3D4128; Wed, 19 Aug 2026 06:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787122360; cv=none; b=ldGrxMFgTawmSVUBI7TvGIlE2OxBZnX3clb+olGRN5yLMBnF23zUwhIVfgn/geK/NC7APR2hOWWgExZEfuShPDA6FaX5upT5zcpDHd+4ukLkCR0sk348qCWanowhScKZSlVrre1KSJILgvarGn/JA3tkEuNsSb3Iqbdkus5Nia4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787122360; c=relaxed/simple; bh=ONtBQ2kZ+7dkxiGpao17uLBP4vsrPT+zPy1RD7Ksg5U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hRqTlfS6Wb0pY9+W5XFeQhPNRizMyfNPDE6sE5tIAczR44ypTEBLF/3dlhBFodUv4LD8AkG4+dpx98RBPDBa2LAVajJQk2de5MeyzjGfS1kUJsccFdE8I8cPzwQqCfVd4CnBUBbnyfJkYvNxksKRDcXQ1SaKuiuFPisn/clH0i0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WkLTMf+q; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WkLTMf+q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D7811F000E9; Wed, 19 Aug 2026 06:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787122357; bh=7d351kwETeBhwKUAevfFIdhiS/3pPYk4RDmKm2u9Xu0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=WkLTMf+qpN/io805Y+2gkeOkMbkpIKzf/6QzY2J/6Bl2FWOx3hYwxZqHUNh5M4dgw NmuyAHXcBRvh2GxscHJW61nXGUBR8lNKbUmLxqWPpQcQgLHWUAVlSWz6LVoosdqCUL ZEmosEMGQfwSgXLsUlMUGHaMqKfk3Jvw8lbWY34WrNbJ3DRB7qmc/YZZa7OShj2kZU 9F9gzCeo4nBVxNMDWaMYPftvg52ti3BnqeVARRjJq5cVbN2pVAHAoYGhFw0l1dFtDu nWSAaMBzSD2S1DqUVmDAMWvEN7eDywpx8rVr2/eMxUkxs3qh6vnl3GoJDWDRt0ReB8 kGYH6E45e0M5Q== Date: Wed, 19 Aug 2026 09:52:22 +0300 From: Mike Rapoport To: Brendan Jackman Cc: Andrew Morton , Adrian =?utf-8?Q?Barna=C5=9B?= , Albert Ou , Alexander Gordeev , Alexandre Ghiti , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Christian Borntraeger , Dave Hansen , David Hildenbrand , Gerald Schaefer , Heiko Carstens , Huacai Chen , Ingo Molnar , Len Brown , Palmer Dabbelt , Paul Walmsley , Pavel Machek , Peter Zijlstra , "H. Peter Anvin" , "Rafael J. Wysocki" , Ryan Roberts , Sven Schnelle , Thomas Gleixner , Uladzislau Rezki , Vasily Gorbik , WANG Xuerui , Will Deacon , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, loongarch@lists.linux.dev Subject: Re: [PATCH 1/6] set_memory: add number of pages parameter to set_direct_map APIs Message-ID: References: <20260816-execmem-set-vm-perms-v0-2-v1-0-90944a3ad43f@kernel.org> <20260816-execmem-set-vm-perms-v0-2-v1-1-90944a3ad43f@kernel.org> Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, Aug 17, 2026 at 02:10:39PM +0200, Brendan Jackman wrote: > On Sun Aug 16, 2026 at 12:59 PM CEST, Mike Rapoport (Microsoft) wrote: > > When set_direct_map APIs were introduced by the commit d253ca0c3865 > > ("x86/mm/cpa: Add set_direct_map_*() functions") the single page > > parameter made sense because the initial callers (vmalloc and > > hibernation) had sets of unsorted struct pages that required changes of > > their mappings in the direct map. > > > > Since there is an increasing demand for direct map manipulation and it > > is also desirable to be able to update larger physically contiguous > > mappings, for example an entire large folio, extend set_direct_map APIs > > to receive number of pages parameter. > > > > As there is still only a handful of callers, change the existing > > functions directly and update all the call sites rather than adding > > wrappers for single page case. > > > > Signed-off-by: Mike Rapoport (Microsoft) > > I think if we add this arg we also need to specify how the > implementations are supposed to behave when they fail midway? This is the same as set_memory, I don't think it deserves a special care right now. > IIUC the incumbent answer for stuff like this is: > > - The implementation might leave partial modifications behind when it > fails. The caller needs to deal with that. > > - ... But, that's gonna be due to allocation failure. So the caller can > just do the inverse operation in the failure path as a cleanup, and > assume that inverse operation succeeds since the pagetables are > already allocated up to the failure point. > > I guess it's worth making that a sort of explicit contract since it > makes certain implementation details load-bearing, e.g. I think... > > - It forces the pagetable update algorithm to work in a fixed order. > > - it forbids us to e.g. merge PTEs into a PMD if the region might be > pending such a cleanup, since it would force that cleanup to > reallocate a PTE table. I'd leave the load-bearing parts for now ;-) I'm going to resend the patches that generalise CPA and I'll add some docs to that set. [1] https://lore.kernel.org/linux-mm/20260721-generic-set-memory-v0-1-v1-0-2c1fc62306b3@kernel.org/ -- Sincerely yours, Mike. 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCF92C5B572 for ; Wed, 19 Aug 2026 06:52:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8Rzf5y2tCPyoSJLMvZBXJE6XMgWkp8902RjAU96QVgU=; b=Hj8UqNciZAqgti H4pu9g0bsrQFJWqobQ8l8C+8AvRCn5sBE3336TSjkQM7RKLglyIvDJKAWuG4J2aQT2gciZU2kAOWn 3BfkGmzwewnFx8HcJi32zWmgl3//oZPF5GtAkEr1RHTpfDQS2EsJ0KV3Siyhou6eiTyn5Rdi3Kv00 LeeaRh5VPVNNR0DLAdZ1ZVjVQkLWi01nWaiyZ4y5lEdbizpdYzcTP9LfkBFLQI22nv+mQe9xDfDZu mHQsT3cyHPSWpw2ixvLNrLZO5otXM/G66RX86apOsj/HgCVzdMP4dNpJ/eDQY9y8bVFevrMe1TMKy IFH2JrS101z02w+g22VQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wwaAC-000000097yI-15S7; Wed, 19 Aug 2026 06:52:40 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wwaAA-000000097xc-0qst; Wed, 19 Aug 2026 06:52:38 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id ACAF0436FF; Wed, 19 Aug 2026 06:52:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D7811F000E9; Wed, 19 Aug 2026 06:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787122357; bh=7d351kwETeBhwKUAevfFIdhiS/3pPYk4RDmKm2u9Xu0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=WkLTMf+qpN/io805Y+2gkeOkMbkpIKzf/6QzY2J/6Bl2FWOx3hYwxZqHUNh5M4dgw NmuyAHXcBRvh2GxscHJW61nXGUBR8lNKbUmLxqWPpQcQgLHWUAVlSWz6LVoosdqCUL ZEmosEMGQfwSgXLsUlMUGHaMqKfk3Jvw8lbWY34WrNbJ3DRB7qmc/YZZa7OShj2kZU 9F9gzCeo4nBVxNMDWaMYPftvg52ti3BnqeVARRjJq5cVbN2pVAHAoYGhFw0l1dFtDu nWSAaMBzSD2S1DqUVmDAMWvEN7eDywpx8rVr2/eMxUkxs3qh6vnl3GoJDWDRt0ReB8 kGYH6E45e0M5Q== Date: Wed, 19 Aug 2026 09:52:22 +0300 From: Mike Rapoport To: Brendan Jackman Cc: Andrew Morton , Adrian =?utf-8?Q?Barna=C5=9B?= , Albert Ou , Alexander Gordeev , Alexandre Ghiti , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Christian Borntraeger , Dave Hansen , David Hildenbrand , Gerald Schaefer , Heiko Carstens , Huacai Chen , Ingo Molnar , Len Brown , Palmer Dabbelt , Paul Walmsley , Pavel Machek , Peter Zijlstra , "H. Peter Anvin" , "Rafael J. Wysocki" , Ryan Roberts , Sven Schnelle , Thomas Gleixner , Uladzislau Rezki , Vasily Gorbik , WANG Xuerui , Will Deacon , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, loongarch@lists.linux.dev Subject: Re: [PATCH 1/6] set_memory: add number of pages parameter to set_direct_map APIs Message-ID: References: <20260816-execmem-set-vm-perms-v0-2-v1-0-90944a3ad43f@kernel.org> <20260816-execmem-set-vm-perms-v0-2-v1-1-90944a3ad43f@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Mon, Aug 17, 2026 at 02:10:39PM +0200, Brendan Jackman wrote: > On Sun Aug 16, 2026 at 12:59 PM CEST, Mike Rapoport (Microsoft) wrote: > > When set_direct_map APIs were introduced by the commit d253ca0c3865 > > ("x86/mm/cpa: Add set_direct_map_*() functions") the single page > > parameter made sense because the initial callers (vmalloc and > > hibernation) had sets of unsorted struct pages that required changes of > > their mappings in the direct map. > > > > Since there is an increasing demand for direct map manipulation and it > > is also desirable to be able to update larger physically contiguous > > mappings, for example an entire large folio, extend set_direct_map APIs > > to receive number of pages parameter. > > > > As there is still only a handful of callers, change the existing > > functions directly and update all the call sites rather than adding > > wrappers for single page case. > > > > Signed-off-by: Mike Rapoport (Microsoft) > > I think if we add this arg we also need to specify how the > implementations are supposed to behave when they fail midway? This is the same as set_memory, I don't think it deserves a special care right now. > IIUC the incumbent answer for stuff like this is: > > - The implementation might leave partial modifications behind when it > fails. The caller needs to deal with that. > > - ... But, that's gonna be due to allocation failure. So the caller can > just do the inverse operation in the failure path as a cleanup, and > assume that inverse operation succeeds since the pagetables are > already allocated up to the failure point. > > I guess it's worth making that a sort of explicit contract since it > makes certain implementation details load-bearing, e.g. I think... > > - It forces the pagetable update algorithm to work in a fixed order. > > - it forbids us to e.g. merge PTEs into a PMD if the region might be > pending such a cleanup, since it would force that cleanup to > reallocate a PTE table. I'd leave the load-bearing parts for now ;-) I'm going to resend the patches that generalise CPA and I'll add some docs to that set. [1] https://lore.kernel.org/linux-mm/20260721-generic-set-memory-v0-1-v1-0-2c1fc62306b3@kernel.org/ -- Sincerely yours, Mike. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv