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 8339CC79FA1 for ; Tue, 8 Sep 2026 09:59:48 +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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GYLtdV6p5mT+hr9US3uDBcYvFiiBVFeGRc9CQOheriQ=; b=pWqR0sYmDprNtd QPae4Zj6jrzQswRYbO3ZplMkrV4UGk630tR7xVTthhf/CEeDJMUT/NpIe6i/Y0/IQbXSXLpaHQLmy yOS0Z8mKt52oytMhshmBGNsfPbjG+DT435AylH23DlKrvziLhmOapb2whB3Vv8BjkYOV/70yV8MLT r9WlBLUrRYypM6MjDHXGXMM6Wa5A4aM3mnKI4oou42lB3Gv5p7gB/sIgObh4U4d65djN0iecWT/6v RhrYJLtTirid7WZBIgKPm38TLBWgVcEG5cn2FQXPCkUrb4clmYP79a2qhN4K+6Nkk+a4bndtx/WfH IlrNtsxa3yzFdInDOu+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x3sc5-00000008hoF-3gBn; Tue, 08 Sep 2026 09:59:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x3sc4-00000008hmk-3QwP; Tue, 08 Sep 2026 09:59:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: Sender:Reply-To:Content-ID:Content-Description; bh=CHEe090zxcvX/G2IQLHQp9iXm/EoC7Qx7nHJQJ/rGtQ=; b=qFuxPgngxSvw4b1gE783OIdOGk aCh1xVz1gdphR/zSDmEp+UMtkdcgkLL1UOBSFR6FX1jemqAeZisR8IfqVYhAsU+GSGw1kkbgFYw8P EY+0gLRpFUIeGTzNyhod0sjhANN9NXkDIMr4rNiQg4zaNS4W3DDwiTs1Xl3ev8FmPnl62ywBWwNDG XbGCrxo9yJYAtQTs8tp1DaUd7NR0q3LbODp4TBV+sD7HesMDfcKOZWiam5Dy3v1eVBCXbHF2iqI24 NazPb/PZ+cuNtqHSKMku/eWj3Q91L7QIRKd+8gdBCK6l6pjwwNMwiexbjmgG1g6AcXdYuTw8c1UIp 0+sJJvxA==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.99.2 #2 (Red Hat Linux)) id 1x3sc0-0000000HF1j-0aKd; Tue, 08 Sep 2026 09:59:34 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7E6391476; Tue, 8 Sep 2026 02:59:25 -0700 (PDT) Received: from [10.164.19.55] (unknown [10.164.19.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8CBC43F7B4; Tue, 8 Sep 2026 02:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1788861569; bh=a/a9VuH1Pbu7fuqb4EF439JhWu4OMvquSWkjlVGi4tM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=YR0UOmZKFbfAJ3SQSDswiFS+rXAWEo6USejgl07yJMtcUVzwUvoX92dfUQwwVpdX5 EaS2HlcY5AR9bV7tQg2bFaeizuNwDp69wiztfvHe7QfBZ8M2HAbZx4+U2VfjisKvus ye1W5JquN+zfg/oiJuWT9J+cxec8MSXZ7ZVkbbDw= Message-ID: <88b48587-1f3e-479b-ae9b-67aa643e2acb@arm.com> Date: Tue, 8 Sep 2026 15:29:16 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 4/6] mm/vmalloc: make set_area_direct_map HUGE_VMAP friendly To: "Mike Rapoport (Microsoft)" , Andrew Morton Cc: =?UTF-8?Q?Adrian_Barna=C5=9B?= , Albert Ou , Alexander Gordeev , Alexandre Ghiti , Andy Lutomirski , Borislav Petkov , Brendan Jackman , 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 References: <20260903-execmem-set-vm-perms-v0-2-v3-0-949b64a9f755@kernel.org> <20260903-execmem-set-vm-perms-v0-2-v3-4-949b64a9f755@kernel.org> Content-Language: en-US From: Dev Jain In-Reply-To: <20260903-execmem-set-vm-perms-v0-2-v3-4-949b64a9f755@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260908_105932_574658_B0F36C69 X-CRM114-Status: GOOD ( 21.83 ) 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 03/09/26 2:58 pm, Mike Rapoport (Microsoft) wrote: > set_area_direct_map() always updates direct map alias permissions in > single page increments. > > For HUGE_VMAP areas it's suboptimal. Not only the loop in > set_area_direct_map() needlessly has more iterations (e.g times 512 on > x86), but it also causes fragmentation of the direct map that could be > avoided for the HUGE_VMAP areas populated with large pages. Correct, this would also help us on arm64 once we have ROX caches. > > All pages in an area are always of the same order: either same-order > large pages when VM_ALLOW_HUGE_VMAP is set and all huge pages were > successfully allocated, or order-0 page when VM_ALLOW_HUGE_VMAP is > cleared or when huge pages allocation fails and fallback path is taken. > > Instead of updating the direct map permissions for every order-0 page in > an area, use the area's page_order as the loop increment and update the > large pages in one call to set_direct_map_{invalid,default}_noflush(). > > Signed-off-by: Mike Rapoport (Microsoft) > --- LGTM: Reviewed-by: Dev Jain > mm/vmalloc.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index 5506b180f5c27..6ed6c160abed7 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -3367,12 +3367,15 @@ static inline void set_area_direct_map(const struct vm_struct *area, > int (*set_direct_map)(struct page *page, > unsigned int nr)) > { > - unsigned long i; > + unsigned int nr = (1U << vm_area_page_order(area)); > + > + for (unsigned long i = 0; i < area->nr_pages; i += nr) { > + if (page_address(area->pages[i])) { > + int err = set_direct_map(area->pages[i], nr); > > - /* HUGE_VMALLOC passes small pages to set_direct_map */ > - for (i = 0; i < area->nr_pages; i++) > - if (page_address(area->pages[i])) > - set_direct_map(area->pages[i], 1); > + WARN_ON_ONCE(err); > + } > + } > } > > /* > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv