From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from va-1-111.ptr.blmpb.com (va-1-111.ptr.blmpb.com [209.127.230.111]) (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 9989C3F210B for ; Tue, 9 Jun 2026 09:20:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780996820; cv=none; b=exiPtLW6vTsgyxPv/LaUH6chfufeVsTK87rIOBPnShn7rpn+/IqXRbgaRGkLxUvkga+609AEFRoDef8gGoczrUypVuZJBxTFHWLJ7RBh4+qiLTf4JGQsvaAiLTjfn3FbegQXS59SJCDUpALSkxBztg7k6sbBSOFxAZS9ZjWHKHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780996820; c=relaxed/simple; bh=aQEn2iHu8uWayUekGTF8NcS+dbUVABWhsg8gTFgTJ6A=; h=Content-Type:To:Subject:Message-Id:From:Date:References:Cc: Mime-Version:In-Reply-To; b=LXYE2B+tLC8T/rOq6+yaJryRe1FMseIVaDrobGlaNPFJBW/FoNxzkSznyQWfQftd68raWZGpqvK2okbGwMWdsJ5NnJ9ZVvbrMVIZAyoe4ycG1jbAqkoUglDJtCJyLS8CXNxcuCNFS8o1a2KLetfukLL0/kNflYpfNsRkkI0ZDGg= 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=lcWT75NO; arc=none smtp.client-ip=209.127.230.111 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="lcWT75NO" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1780996812; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=0oRoK9tryy0kwmhMlEOPbcFOGHYaFPNq3wPUzdycWW0=; b=lcWT75NOLxvl7LSa3SL+Ry2PJeReXUmwYsUmbsGQ0IHskCSrPdW/3Z6ALfC4kEX37Ie6S0 8Eev2fW4kpXFhIU57SCa6MBOE8KvLESQB4WVRgrJ5mjwcZSKjC5GELThUH1Ke5Q2p5umXY sOdHPj9il6uX9POx/lyiD5NtX5hQoSNOeRQ2XJSq6Cm5yIRoJZVMFeSBig7jh8/+9Dqg5T /0qoeBElPdsVN11BoxeYk8SHV6ykRnrUvxauAPcNyvQ3o8V85kumRXbtp+xPgegmiOgLFQ NiGXGykXy9eKnY8YlUstqwILKyoK5SumhdkrpzaOSrcJBKcsSAmFpwnfeFp08A== X-Lms-Return-Path: Content-Type: text/plain; charset=UTF-8 To: , , , , , , , , , , , , , Subject: [PATCH v7 10/14] x86/mm: Factor out flush_tlb_info initialization Message-Id: <20260609091710.404083-11-zhouchuyi@bytedance.com> Content-Transfer-Encoding: 7bit X-Mailer: git-send-email 2.20.1 From: "Chuyi Zhou" Date: Tue, 9 Jun 2026 17:17:06 +0800 X-Original-From: Chuyi Zhou References: <20260609091710.404083-1-zhouchuyi@bytedance.com> Cc: , "Chuyi Zhou" Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 In-Reply-To: <20260609091710.404083-1-zhouchuyi@bytedance.com> get_flush_tlb_info() currently does two things: it reserves the per-CPU flush_tlb_info storage and initializes the fields that describe the flush. Split the field setup into init_flush_tlb_info(). The per-CPU storage, DEBUG_VM reentrancy check and put_flush_tlb_info() lifetime rules are unchanged. This is a preparatory cleanup for allowing callers to provide their own flush_tlb_info storage. Signed-off-by: Chuyi Zhou --- arch/x86/mm/tlb.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index af43d177087e..c999d5cd3ea8 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1379,22 +1379,12 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct flush_tlb_info, flush_tlb_info); static DEFINE_PER_CPU(unsigned int, flush_tlb_info_idx); #endif -static struct flush_tlb_info *get_flush_tlb_info(struct mm_struct *mm, - unsigned long start, unsigned long end, - unsigned int stride_shift, bool freed_tables, - u64 new_tlb_gen) +static void init_flush_tlb_info(struct flush_tlb_info *info, + struct mm_struct *mm, + unsigned long start, unsigned long end, + unsigned int stride_shift, bool freed_tables, + u64 new_tlb_gen) { - struct flush_tlb_info *info = this_cpu_ptr(&flush_tlb_info); - -#ifdef CONFIG_DEBUG_VM - /* - * Ensure that the following code is non-reentrant and flush_tlb_info - * is not overwritten. This means no TLB flushing is initiated by - * interrupt handlers and machine-check exception handlers. - */ - BUG_ON(this_cpu_inc_return(flush_tlb_info_idx) != 1); -#endif - /* * If the number of flushes is so large that a full flush * would be faster, do a full flush. @@ -1412,6 +1402,26 @@ static struct flush_tlb_info *get_flush_tlb_info(struct mm_struct *mm, info->new_tlb_gen = new_tlb_gen; info->initiating_cpu = smp_processor_id(); info->trim_cpumask = 0; +} + +static struct flush_tlb_info *get_flush_tlb_info(struct mm_struct *mm, + unsigned long start, unsigned long end, + unsigned int stride_shift, bool freed_tables, + u64 new_tlb_gen) +{ + struct flush_tlb_info *info = this_cpu_ptr(&flush_tlb_info); + +#ifdef CONFIG_DEBUG_VM + /* + * Ensure that the following code is non-reentrant and flush_tlb_info + * is not overwritten. This means no TLB flushing is initiated by + * interrupt handlers and machine-check exception handlers. + */ + BUG_ON(this_cpu_inc_return(flush_tlb_info_idx) != 1); +#endif + + init_flush_tlb_info(info, mm, start, end, stride_shift, freed_tables, + new_tlb_gen); return info; } -- 2.20.1