From nobody Mon Apr 6 21:23:12 2026 Received: from va-1-112.ptr.blmpb.com (va-1-112.ptr.blmpb.com [209.127.230.112]) (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 1B36A2FE04E for ; Wed, 18 Mar 2026 04:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.112 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773810001; cv=none; b=pB9bJBIdYUtNCUeDia8t9OCTQgF9lZPnCamKYgsJMTUKl9eUoqOJA4VOiHjUbgCOf+TpylHO53oJ2TvpyXp4gHW2cwNjZLiEMy2iJA/jm/4iBGX+k3y9vjfpFd8BaT5laJZmzfpkEmWWfA29twCDEDd6cfPqHamAdBoEFnWeZTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773810001; c=relaxed/simple; bh=X+CqvbFR/GYiLv0G6d4WSZR05Firg3cSQjz8ceINs08=; h=To:In-Reply-To:Cc:From:Subject:References:Date:Message-Id: Mime-Version:Content-Type; b=ssYrnVlb/R11X+PTD0oFDD+lon43KLo1Isjr10hPfsfW/456xSrRnfg8HzACbA7uS7a0VvJWAUF0ZpZ7FFUbywzaSVy2mkAXQ1mpEoc4FKVeQ2lLmCCkrABTb62hnYPeRPStZfWhsXm60sL8hIQEloNF8ATs/4ZaW2q7HJA1F+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=PKSOjaQh; arc=none smtp.client-ip=209.127.230.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="PKSOjaQh" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1773809995; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=dP80iEfLiCUMTATceYOb/cHCPDqACbsVJSQ5RitjUJU=; b=PKSOjaQh1Vw3ufDXvzZyNO8xXeqAQDBk/pH4TpuWUr7BWJsu+QYqqovWDsacsWduANKdFy 8+u3yZ/4+2tjKsBhg8ErCmroBAzvqAP+9kNDSQ/No5aHA3pYfEe+h2KFIqmghJld1XORfZ w+lF69LX8EwUSbjmPVGKGyFb5hnst5rV0viWpybqolr3iDlGf5iJXxtfPrQdlz/3cHLCBL d4z5zbWQQNyZt00Ou6m3qzqJ4sflgSZVlvZUtGSfr7rXPjubpgEaTuusAWfZgBak28GSsU Ur6B5FTBqNnfWLNvoU7nPk1O+NbCHFEFTbgncD4rBDwa4ftPsnvZX3Fhz6GPZw== To: , , , , , , , , , , , X-Lms-Return-Path: In-Reply-To: <20260318045638.1572777-1-zhouchuyi@bytedance.com> Cc: , "Chuyi Zhou" From: "Chuyi Zhou" Subject: [PATCH v3 12/12] x86/mm: Enable preemption during flush_tlb_kernel_range References: <20260318045638.1572777-1-zhouchuyi@bytedance.com> X-Mailer: git-send-email 2.20.1 Date: Wed, 18 Mar 2026 12:56:38 +0800 Message-Id: <20260318045638.1572777-13-zhouchuyi@bytedance.com> 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-Original-From: Chuyi Zhou Content-Type: text/plain; charset="utf-8" flush_tlb_kernel_range() is invoked when kernel memory mapping changes. On x86 platforms without the INVLPGB feature enabled, we need to send IPIs to every online CPU and synchronously wait for them to complete do_kernel_range_flush(). This process can be time-consuming due to factors such as a large number of CPUs or other issues (like interrupts being disabled). flush_tlb_kernel_range() always disables preemption, this may affect the scheduling latency of other tasks on the current CPU. Previous patch converted flush_tlb_info from per-cpu variable to on-stack variable. Additionally, it's no longer necessary to explicitly disable preemption before calling smp_call*() since they internally handles the preemption logic. Now is's safe to enable preemption during flush_tlb_kernel_range(). Signed-off-by: Chuyi Zhou --- arch/x86/mm/tlb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 73500376d185..b89949d4fb31 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1446,6 +1446,8 @@ static void invlpgb_kernel_range_flush(struct flush_t= lb_info *info) { unsigned long addr, nr; =20 + guard(preempt)(); + for (addr =3D info->start; addr < info->end; addr +=3D nr << PAGE_SHIFT) { nr =3D (info->end - addr) >> PAGE_SHIFT; =20 @@ -1496,14 +1498,12 @@ void flush_tlb_kernel_range(unsigned long start, un= signed long end) .new_tlb_gen =3D TLB_GENERATION_INVALID }; =20 - guard(preempt)(); - if ((end - start) >> PAGE_SHIFT > tlb_single_page_flush_ceiling) { start =3D 0; end =3D TLB_FLUSH_ALL; } =20 - info.initiating_cpu =3D smp_processor_id(), + info.initiating_cpu =3D raw_smp_processor_id(), info.start =3D start; info.end =3D end; =20 --=20 2.20.1