From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) (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 9D48D3815F4 for ; Mon, 9 Feb 2026 18:08:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770660492; cv=none; b=K6nM6oulQPm3JwT/tiBVUifx+WKJMK8c5I8LTpgc7K4DF39nPFIdftA4lQ5URZV5MqoA+8FTk/HpNbdoc3rMAaV6ocvtsz6twPninUAvbXKDUyTcm+H/V5/2IbJhMvQ9DdGaeR+rPjVtsEsJdlphd/Tb5UMz1tI7m+9MsFOA5Dc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770660492; c=relaxed/simple; bh=1rK1iyIJNdkErygH2CvBR8fck8gRvkX1Y1yapCTG6gk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eLaBiSGzBWb4gVyxKOfjfTLsilEfSBTWulpz16WPHEyH+09os/IurhlOBe56BMXzHPpPvpV0jB3feZKSM5lty+/YcNy9AAmkebr9E+dW05euYLNY5kFP4ZchzZPjU1i1P+fLuLB2rK5sAsUIMM4uDzo5XdD+AMrQrKbjKYPWLOs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NEjGfxI/; arc=none smtp.client-ip=209.85.222.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NEjGfxI/" Received: by mail-ua1-f45.google.com with SMTP id a1e0cc1a2514c-94aaa5d3bfcso1446447241.3 for ; Mon, 09 Feb 2026 10:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770660491; x=1771265291; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6etbSktugcyTa/hE9/FXn2l+e6oOxB8uxoNamCNtG+g=; b=NEjGfxI/k84aOodsrH3c5L8AVVr2UyzxqnukqdGKHaV77XpqAKxRyIJOezF/xFsnyz IfBxlgOnVAG/MWMZcCeHHFtHncSgB0Gb4H79TZ55BnCvbKY7B2pQmNtU4BYqNaF8gzNu m0G9FTyvNVviPA0U7Aev4mRh+NenP1vWDnR3j9KfVq01it/viJsiUj6RNPxHIedWmUWD ttO2qBNIIGibCmIhC0NC4+lZg4qgS0AbsGZ007oKgn4gD6aegg4LJWS8hOsGMS2pkKh5 GWM2AGGKZbxIGJstmGJLC6o1rn6aVPJRKnbshxicIJGAyRGe1262TTlzbCJvGdZhgDbZ cEpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770660491; x=1771265291; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6etbSktugcyTa/hE9/FXn2l+e6oOxB8uxoNamCNtG+g=; b=eHd62UE2WBI7ACmbYlCWzUTBL1UvM2Vhj3N6LAuEOd7FI0gmwAwlIP5rHFofZEHNyE /O4eo+N9AoifEIIMS5kTKphVSQ/Kqjy8KF2ZugK/2YfMVLyfLTFNBG+kw6Q+z1ApYUk8 HKe0ciMHCOiwx6QNPucTqkh5ZE2ZACSAtn1KgwK4kF8Fu3ZetmjeFxSN0fATMxjTO7ud kgpf5jSKxYlRVL/6+2yL3LNy4q2a/9KP8WMdBJMx6J0AMbYNS+4i4JtbeVkB5kJHumRj 0x2rat4qgkfCrY+yo1TF7WOI6hjqyUIY5RD4eegqJ25kjG9Cxc/fVRGVvQ2q9+jG6lzu 4aRg== X-Gm-Message-State: AOJu0YzhK9pgPKCDVZAgJee4Z8o7GIe2MzpjHcNkT3EC3Iwko7HqAEm/ AGTV06IIYIi/g8mbd+7ptm7w81oGd+eicn406WoMcrZdOdtPhTXd8WrfdiPClg== X-Gm-Gg: AZuq6aKBE/HqKqZEKXsUhk9/U37fUuABB55dk++jKBqfvKld2oF59s/Z1JXKUYSMUGC fkUmnoZehUXmzPZon3TK5MSUxb84okrIGpyZJueTx760NsvkLAZE5upBVPE/Rv1bqatl+Wj+mBZ 3I+2YnQOlE6Ny960K6hzU7kzGdsh1ybXTxKXu/YO9kw076u2Kod7At64jv8xeZfnnwj6+WqXGsG EgickqBpb1ltH9vZRI5VgxTQH9szwBHRBuThTNhdD/sSnbbj0oVPiWE659vCnO/btxyT4U4MNu+ qVgii81+8a5g3XpzMHYlb+NkhLcyLodGxgpMgPMX25uQxfvmiX2A6l2Yl3Jr2pcPGE4ia71c7Ot Vpc9j/fhwwGqRf4qAWUMOXri+nBzlUlJV1eq5Jfal2CMbSLPlUQjAL/D6gO2d0GBDMFXuzx+3qV Onxljm0waGnUAjlWeXBZmeIRXIrDuG+C8= X-Received: by 2002:a05:6a00:10c4:b0:81f:9bdc:9ef1 with SMTP id d2e1a72fcca58-824417db0c5mr9795617b3a.69.1770654240253; Mon, 09 Feb 2026 08:24:00 -0800 (PST) Received: from DESKTOP-3LEPQG8.localdomain ([119.28.20.50]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-824418812d2sm12764675b3a.43.2026.02.09.08.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Feb 2026 08:23:59 -0800 (PST) From: Xie Yuanbin To: peterz@infradead.org, tglx@kernel.org, riel@surriel.com, segher@kernel.crashing.org, david@kernel.org, hpa@zytor.com, arnd@arndb.de, anna-maria@linutronix.de, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, luto@kernel.org, houwenlong.hwl@antgroup.com, frederic@kernel.org, akpm@linux-foundation.org, lorenzo.stoakes@oracle.com, bhe@redhat.com, ryan.roberts@arm.com, urezki@gmail.com, nysal@linux.ibm.com, max.kellermann@ionos.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Xie Yuanbin Subject: [PATCH v6 RESEND 1/3] x86/mm/tlb: Make enter_lazy_tlb() always inline on x86 Date: Tue, 10 Feb 2026 00:23:39 +0800 Message-ID: <20260209162341.2922-1-qq570070308@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit enter_lazy_tlb() on x86 is short enough, and is called in context switching, which is the hot code path. Make enter_lazy_tlb() always inline on x86 to optimize performance. Cc: Thomas Gleixner Cc: David Hildenbrand (Red Hat) Reviewed-by: Rik van Riel Signed-off-by: Xie Yuanbin --- arch/x86/include/asm/mmu_context.h | 23 ++++++++++++++++++++++- arch/x86/mm/tlb.c | 21 --------------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 1acafb1c6a93..ec3f9bebcf7b 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -136,8 +136,29 @@ static inline void mm_reset_untag_mask(struct mm_struct *mm) } #endif +/* + * Please ignore the name of this function. It should be called + * switch_to_kernel_thread(). + * + * enter_lazy_tlb() is a hint from the scheduler that we are entering a + * kernel thread or other context without an mm. Acceptable implementations + * include doing nothing whatsoever, switching to init_mm, or various clever + * lazy tricks to try to minimize TLB flushes. + * + * The scheduler reserves the right to call enter_lazy_tlb() several times + * in a row. It will notify us that we're going back to a real mm by + * calling switch_mm_irqs_off(). + */ +#ifndef MODULE +static __always_inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) +{ + if (this_cpu_read(cpu_tlbstate.loaded_mm) == &init_mm) + return; + + this_cpu_write(cpu_tlbstate_shared.is_lazy, true); +} +#endif #define enter_lazy_tlb enter_lazy_tlb -extern void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk); extern void mm_init_global_asid(struct mm_struct *mm); extern void mm_free_global_asid(struct mm_struct *mm); diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 621e09d049cb..af43d177087e 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -971,27 +971,6 @@ void switch_mm_irqs_off(struct mm_struct *unused, struct mm_struct *next, } } -/* - * Please ignore the name of this function. It should be called - * switch_to_kernel_thread(). - * - * enter_lazy_tlb() is a hint from the scheduler that we are entering a - * kernel thread or other context without an mm. Acceptable implementations - * include doing nothing whatsoever, switching to init_mm, or various clever - * lazy tricks to try to minimize TLB flushes. - * - * The scheduler reserves the right to call enter_lazy_tlb() several times - * in a row. It will notify us that we're going back to a real mm by - * calling switch_mm_irqs_off(). - */ -void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk) -{ - if (this_cpu_read(cpu_tlbstate.loaded_mm) == &init_mm) - return; - - this_cpu_write(cpu_tlbstate_shared.is_lazy, true); -} - /* * Using a temporary mm allows to set temporary mappings that are not accessible * by other CPUs. Such mappings are needed to perform sensitive memory writes -- 2.51.0