From nobody Fri Oct 2 06:58:30 2026 Received: from va-1-113.ptr.blmpb.com (va-1-113.ptr.blmpb.com [209.127.230.113]) (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 F284D32B10D for ; Tue, 4 Aug 2026 07:12:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.113 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785827539; cv=none; b=CnNbLHLsqm9Evyf5jcMxMFjruTicUUhWJV+MPOXkaHVyjQgV8l3jSJ+NQvGR0TolpOzpKmVUw8PCwrSbCttI7MMbNieCxNLAUFwIvxSt1vOugYV1Wi5OJMKkJCUtixnfhGdn+6drBxeT6kitZiawvVKPdvB9qDxjPDjXDdhP8Ig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785827539; c=relaxed/simple; bh=sYv2Yt7hshDOuKP+c1TAcrZZTNZsh9OCGmezpu25zVM=; h=From:Date:Content-Type:Cc:Message-Id:Mime-Version:To:Subject; b=qwDojff87pVFKVhpdzzK3vgZRl7YmbSrfNu07Hmz0ohizwM8sOYrDcLwkM2d4/ehgKrI8j55bp9OzzQW8QBVt672nWA6MIseB3m6Uys7d/1iVU5hP21mPKN8IgZ6yPAPMTQgImZFuiyLiKGsAZy8v1GPNR0NDx4V2cCRHkkV8fI= 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=JxSe5OQt; arc=none smtp.client-ip=209.127.230.113 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="JxSe5OQt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1785827525; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=m5M1Lm+/NdKKpBFcWcOxFS9rDfn8UtHqjcdy9ymxzsA=; b=JxSe5OQt9XYwi7RshxhsAuRjOsfxnlvMWsLvOxxY1v6ixuLldp5pceztssqEBbK8oDUa6m 7On7kWBXabIED2uQvt+a0li8EOzMQJuqKJxX6669aKuJ/TITGu7rysHi6ien7Tl0y8vO4r pLTNaDfKK0JaPOCEIiu1gV5sZS50DQR8LfJrNYvL5I5iKnAIeilSuFMWRNZQV8Pf9djnxI MALW6+ctSwoDLPnqFiULqFw59ltvyihhft4WgTctGgg5kfUNqUwkqABegfus78gHcRWfRi sF/8WVhzXl1pVLdNlYw7ZJg6m/UBB0vCjSWXs6IEnQHHfE4HWA3XuWNd6ycJ0A== From: "Bo Li" Date: Tue, 4 Aug 2026 15:11:28 +0800 X-Mailer: git-send-email 2.39.5 (Apple Git-154) Content-Transfer-Encoding: quoted-printable Cc: , , , , , , , , "Bo Li" , Message-Id: <20260804071128.31022-1-libo.gcs85@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 To: , , , , X-Original-From: Bo Li Subject: [PATCH] x86/tsc: Fix misplaced seqcount_latch_init() in cyc2ns_init_secondary_cpus() X-Lms-Return-Path: Content-Type: text/plain; charset="utf-8" In cyc2ns_init_secondary_cpus(), seqcount_latch_init(&c2n->seq) is called _before_ c2n is advanced to the next CPU via per_cpu_ptr(). As a result: 1. On the first iteration, c2n still points at the BSP's struct, so the BSP's seqcount_latch is re-initialized. cyc2ns_init_boot_cpu() already did this correctly, so it happens to work by accident because no concurrent readers are live at __init time. 2. On subsequent iterations, seqcount_latch_init() initializes the previous CPU's seqcount (because c2n was advanced by the prior per_cpu_ptr()), so all CPUs except the last one in the for_each loop happen to get initialized. The last secondary CPU's seqcount is left uninitialized. Move seqcount_latch_init() _after_ c2n is pointed at the target CPU's struct, so each secondary CPU's seqcount is correctly initialized. Fixes: e2a9ca29b5ed ("x86/tsc: Initialize cyc2ns when tsc frequency is dete= rmined") Cc: stable@vger.kernel.org Signed-off-by: Bo Li --- arch/x86/kernel/tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index ce10ae4b298b..84fb80492b01 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c @@ -223,8 +223,8 @@ static void __init cyc2ns_init_secondary_cpus(void) =20 for_each_possible_cpu(cpu) { if (cpu !=3D this_cpu) { - seqcount_latch_init(&c2n->seq); c2n =3D per_cpu_ptr(&cyc2ns, cpu); + seqcount_latch_init(&c2n->seq); c2n->data[0] =3D data[0]; c2n->data[1] =3D data[1]; } --=20 2.20.1