From nobody Mon Apr 6 10:45:12 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 76E2F1D6193 for ; Thu, 19 Mar 2026 18:31:25 +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=1773945086; cv=none; b=X0i1fULnd9u/KS5O79+fZDpgeezhOsNNI+Ph8cUHU7X9t5WOIBNY9q8gU7lZJG1Vi6hFQflm9yJYQKKwPHUR1XiRXFFmgGKpkBfGFwethz54a5AuN7fHQQoEFfLINw7BFPWdP5ohz7IzIge1QFtNQHhKqnVd6X0ohSXELNulizU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773945086; c=relaxed/simple; bh=Oci7+eOyv2DvIYHwHcWPk6ScUUGwXF56RP6YDE1pfQ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hfAcVtutWCH4j9b1c/15FP/M1UUDuE1ohd/72pJMaWN655/tDCJnOC+aDR0LMIG284w7AhWZSQlNBYQbO4LXT6bfrXUASwOrve0lyVS+I05S8gxZHV+x59ltYlwL/durRRGSw1wUre58zE52nfigI6DwlUUCEih4TAnCOpgPl0Y= 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; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=DVxcO0GG; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=0v07ZlIi; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=DVxcO0GG; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=0v07ZlIi; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="DVxcO0GG"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0v07ZlIi"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="DVxcO0GG"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="0v07ZlIi" Received: from imap1.dmz-prg2.suse.org (unknown [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 95B3D5BD97; Thu, 19 Mar 2026 18:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1773945080; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=anyfiV6rgUNLqvdloJydtyxRF1ee9QavRldGPaFXcPE=; b=DVxcO0GGwaWmy/iEVsxUuH0tYC8PxAyd7+ebKCMjH1hkrxKNaZZ1c/OpwzZCNtJfWVRum3 PNgjxzs+J4qYe7G+rpGzOyIC3BjujeBW9wOkwS4PvcObGlYmFp3OlRBpUaF9XbWix90SEa kIqV+/xduLezQ3Lql0Pa4O69pfwBB8I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1773945080; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=anyfiV6rgUNLqvdloJydtyxRF1ee9QavRldGPaFXcPE=; b=0v07ZlIi0C8yO71HGvvpk3vQzMbgZvMWWi8S1VhNwwmjASPjgMtxJGzQafZPd4l2akquoB bi3ovs60pdo4tbDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1773945080; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=anyfiV6rgUNLqvdloJydtyxRF1ee9QavRldGPaFXcPE=; b=DVxcO0GGwaWmy/iEVsxUuH0tYC8PxAyd7+ebKCMjH1hkrxKNaZZ1c/OpwzZCNtJfWVRum3 PNgjxzs+J4qYe7G+rpGzOyIC3BjujeBW9wOkwS4PvcObGlYmFp3OlRBpUaF9XbWix90SEa kIqV+/xduLezQ3Lql0Pa4O69pfwBB8I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1773945080; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=anyfiV6rgUNLqvdloJydtyxRF1ee9QavRldGPaFXcPE=; b=0v07ZlIi0C8yO71HGvvpk3vQzMbgZvMWWi8S1VhNwwmjASPjgMtxJGzQafZPd4l2akquoB bi3ovs60pdo4tbDA== 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 BAB8F4273B; Thu, 19 Mar 2026 18:31:19 +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 4PcbKvdAvGmbdgAAD6G6ig (envelope-from ); Thu, 19 Mar 2026 18:31:19 +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 1/4] mm/mprotect: encourage inlining with __always_inline Date: Thu, 19 Mar 2026 18:31:05 +0000 Message-ID: <20260319183108.1105090-2-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-Spam-Score: -6.80 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.997]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWELVE(0.00)[12]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email] X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" Encourage the compiler to inline batch PTE logic and resolve constant branches by adding __always_inline strategically. Signed-off-by: Pedro Falcato --- mm/mprotect.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/mprotect.c b/mm/mprotect.c index 9681f055b9fc..1bd0d4aa07c2 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -103,7 +103,7 @@ bool can_change_pte_writable(struct vm_area_struct *vma= , unsigned long addr, return can_change_shared_pte_writable(vma, pte); } =20 -static int mprotect_folio_pte_batch(struct folio *folio, pte_t *ptep, +static __always_inline int mprotect_folio_pte_batch(struct folio *folio, p= te_t *ptep, pte_t pte, int max_nr_ptes, fpb_t flags) { /* No underlying folio, so cannot batch */ @@ -117,9 +117,9 @@ static int mprotect_folio_pte_batch(struct folio *folio= , pte_t *ptep, } =20 /* Set nr_ptes number of ptes, starting from idx */ -static void prot_commit_flush_ptes(struct vm_area_struct *vma, unsigned lo= ng addr, - pte_t *ptep, pte_t oldpte, pte_t ptent, int nr_ptes, - int idx, bool set_write, struct mmu_gather *tlb) +static __always_inline void prot_commit_flush_ptes(struct vm_area_struct *= vma, + unsigned long addr, pte_t *ptep, pte_t oldpte, pte_t ptent, + int nr_ptes, int idx, bool set_write, struct mmu_gather *tlb) { /* * Advance the position in the batch by idx; note that if idx > 0, @@ -169,7 +169,7 @@ static int page_anon_exclusive_sub_batch(int start_idx,= int max_len, * pte of the batch. Therefore, we must individually check all pages and * retrieve sub-batches. */ -static void commit_anon_folio_batch(struct vm_area_struct *vma, +static __always_inline void commit_anon_folio_batch(struct vm_area_struct = *vma, struct folio *folio, struct page *first_page, unsigned long addr, pte_t = *ptep, pte_t oldpte, pte_t ptent, int nr_ptes, struct mmu_gather *tlb) { --=20 2.53.0