From nobody Fri Jul 24 21:53:02 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFF373F58CA; Thu, 23 Jul 2026 10:32:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784802754; cv=none; b=a4jYSEn+gvQwM3m5ZNqlzxc1OwXAQooOx+XEaLMtoERfnLL2lJP0HBoO8rJQfDpVwvelagE88i57xefxxnqHA/jb5ltalIVJklbpRIMoxj0hUI+u8MbRJTdsHydx7iBvEk5sXbYBuiABSlqrHP+8IdKPHGlYSezi6HwqJNQTO68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784802754; c=relaxed/simple; bh=H5p4m5trm47NiPMr16PKM6UwnE/9jMHj7Le0do3y/N0=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=WyYmmlLGPXCrUZgOOUuXGsq4CPQu1bY/n55tmzmYujCNJfcL/LhfGTrertN6VVjJYP+gXjjyUB8oZj/Kqhs7Wxljlow3dWkjQ6zFwiPSkBGCP6DY1XssleW/yVRS46758yd8NB2CNyq/LQVbhbAkUvNsudd1PTvndr8g7EvgmEY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=D49fCfxk; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EGf0LCrO; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="D49fCfxk"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EGf0LCrO" Date: Thu, 23 Jul 2026 10:32:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1784802749; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nn6F8k2Pse4St53OzDkYvFzefsxpnNT1syHkxQEdgKk=; b=D49fCfxkNmtDDD16Sn1VSs5H5sdRuBV5HLqrBVuUIGTtI8DwP82hs6CdZ9jWIA+ACpn5AQ 4YngDRzSeSowHpkiXH5rro08yEzbe51CHne+9scyUKR2kZVhYUUEejW0mFuUe0ZU1y9ef2 VoYeQCz6x5mm2dJmHrUMxtzvlI9B74tcAcGF7if1nyPKXlvckaYFSUsRkFCLZnIY33lTcV p61Ecr35TfCIxjTtqIxTQISWMPwCjPLFesdQcJ/5ZlYnwlibWqFSY3hPcSZpr2phjkKi4Z asxPiADlRFJaOSamMsjBvhawuXQeEzlxjH0MfRmxkPB+3T+25sugwsprid/xQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1784802749; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nn6F8k2Pse4St53OzDkYvFzefsxpnNT1syHkxQEdgKk=; b=EGf0LCrOXboGdiwQZZUVMa5tKtW6qpgwYLb5fdw9n0Iv/toJdyCI9S980ModTPBJrlCaRk KSC42nq9N2ByWZBQ== From: "tip-bot2 for Chuyi Zhou" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] x86/mm: Factor out flush_tlb_info initialization Cc: Chuyi Zhou , Thomas Gleixner , Sebastian Andrzej Siewior , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260709122933.4021501-11-zhouchuyi@bytedance.com> References: <20260709122933.4021501-11-zhouchuyi@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178480274772.2943223.11532611470907647901.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/mm branch of tip: Commit-ID: 33c179b5020554722bcb4c5a3ff565192ac53f54 Gitweb: https://git.kernel.org/tip/33c179b5020554722bcb4c5a3ff565192= ac53f54 Author: Chuyi Zhou AuthorDate: Thu, 09 Jul 2026 20:29:29 +08:00 Committer: Thomas Gleixner CommitterDate: Thu, 23 Jul 2026 12:30:31 +02:00 x86/mm: Factor out flush_tlb_info initialization get_flush_tlb_info() has two responsibilities: it reserves the per-CPU flush_tlb_info storage and it initializes the fields that describe the flush operation. The per-CPU storage also carries the DEBUG_VM reentrancy check and the matching put_flush_tlb_info() lifetime rules. Moving flush_tlb_info back to caller-provided storage requires the same field initialization without tying the caller to the per-CPU object. Leaving the field setup embedded in get_flush_tlb_info() would either keep those callers tied to the per-CPU object or duplicate the initialization logic. Split the field setup into init_flush_tlb_info(). Keep the per-CPU storage selection, DEBUG_VM reentrancy check and put_flush_tlb_info() lifetime rules in get_flush_tlb_info(). No functional change intended. Signed-off-by: Chuyi Zhou Signed-off-by: Thomas Gleixner Reviewed-by: Sebastian Andrzej Siewior Link: https://patch.msgid.link/20260709122933.4021501-11-zhouchuyi@bytedanc= e.com --- arch/x86/mm/tlb.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 1023aca..7f48342 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -1379,29 +1379,18 @@ static DEFINE_PER_CPU_SHARED_ALIGNED(struct flush_t= lb_info, flush_tlb_info); static DEFINE_PER_CPU(unsigned int, flush_tlb_info_idx); #endif =20 -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_str= uct *mm, + unsigned long start, unsigned long end, + unsigned int stride_shift, bool freed_tables, + u64 new_tlb_gen) { - struct flush_tlb_info *info =3D 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) !=3D 1); -#endif - /* * If the number of flushes is so large that a full flush * would be faster, do a full flush. */ if ((end - start) >> stride_shift > tlb_single_page_flush_ceiling) { - start =3D 0; - end =3D TLB_FLUSH_ALL; + start =3D 0; + end =3D TLB_FLUSH_ALL; } =20 info->start =3D start; @@ -1412,7 +1401,24 @@ static struct flush_tlb_info *get_flush_tlb_info(str= uct mm_struct *mm, info->new_tlb_gen =3D new_tlb_gen; info->initiating_cpu =3D smp_processor_id(); info->trim_cpumask =3D 0; +} + +static struct flush_tlb_info *get_flush_tlb_info(struct mm_struct *mm, uns= igned long start, + unsigned long end, unsigned int stride_shift, + bool freed_tables, u64 new_tlb_gen) +{ + struct flush_tlb_info *info =3D 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) !=3D 1); +#endif =20 + init_flush_tlb_info(info, mm, start, end, stride_shift, freed_tables, new= _tlb_gen); return info; } =20