From nobody Mon Apr 6 10:45:07 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 613E22DCF45 for ; Thu, 19 Mar 2026 18:31:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773945092; cv=none; b=GLAjbJcAJ3k2efCcsLjrhIAw4wGrtdNh+7czp8+YDtbuMl9pUa03/bpmUDJQX8XcXx2G3TPVmPrSu9PSCzNfmeEHvc4d7HeT2jzkJPuK74NgBvpLHnT4muLHfgJ7vGb1nMpiC6eTrd2D7Awo5n94e6t9fwjBa/9loymQsGjgiYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773945092; c=relaxed/simple; bh=nOEE3JK1QoYh5GpiYGfLUtii2Wjnk1v54Kbm6zzMFVU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lMxx1o9WJ8FQShL7xO//D2jK2dNg3wG+2i6LQdEPVSvhXnIvMpYc5gdMhBFGJ+LFRO5zrcrZ1TTBmtNQb9qRjUp7Q5o4cL/XxVBFlm43wpYwXTqkXhM69Q/F5QRpHaOBw8tb5lYzz4QT9Y8DliJRcxWvptxp90oA5CS6+VVw/WA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A0B535BD82; Thu, 19 Mar 2026 18:31:24 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id C63284273B; Thu, 19 Mar 2026 18:31:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 2PTnLPtAvGmbdgAAD6G6ig (envelope-from ); Thu, 19 Mar 2026 18:31:23 +0000 From: Pedro Falcato To: Andrew Morton , "Liam R. Howlett" , Lorenzo Stoakes Cc: Pedro Falcato , Vlastimil Babka , Jann Horn , David Hildenbrand , Dev Jain , Luke Yang , jhladky@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] mm/mprotect: un-inline folio_pte_batch_flags() Date: Thu, 19 Mar 2026 18:31:07 +0000 Message-ID: <20260319183108.1105090-4-pfalcato@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260319183108.1105090-1-pfalcato@suse.de> References: <20260319183108.1105090-1-pfalcato@suse.de> 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 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: A0B535BD82 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: Content-Type: text/plain; charset="utf-8" Hoist some previous, important to be inlined checks to the main loop and noinline the entirety of folio_pte_batch_flags(). The loop itself is quite large and whether it is inlined or not should not matter, as we are ideally dealing with larger orders. Signed-off-by: Pedro Falcato --- mm/mprotect.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mm/mprotect.c b/mm/mprotect.c index 8d4fa38a8a26..aa845f5bf14d 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -103,16 +103,9 @@ bool can_change_pte_writable(struct vm_area_struct *vm= a, unsigned long addr, return can_change_shared_pte_writable(vma, pte); } =20 -static __always_inline int mprotect_folio_pte_batch(struct folio *folio, p= te_t *ptep, +static noinline int mprotect_folio_pte_batch(struct folio *folio, pte_t *p= tep, pte_t pte, int max_nr_ptes, fpb_t flags) { - /* No underlying folio, so cannot batch */ - if (!folio) - return 1; - - if (!folio_test_large(folio)) - return 1; - return folio_pte_batch_flags(folio, NULL, ptep, &pte, max_nr_ptes, flags); } =20 @@ -333,7 +326,12 @@ static long change_pte_range(struct mmu_gather *tlb, continue; } =20 - nr_ptes =3D mprotect_folio_pte_batch(folio, pte, oldpte, max_nr_ptes, f= lags); + /* No underlying folio (or not large), so cannot batch */ + if (likely(!folio || !folio_test_large(folio))) + nr_ptes =3D 1; + else + nr_ptes =3D mprotect_folio_pte_batch(folio, pte, oldpte, + max_nr_ptes, flags); =20 oldpte =3D modify_prot_start_ptes(vma, addr, pte, nr_ptes); ptent =3D pte_modify(oldpte, newprot); --=20 2.53.0