From nobody Mon Feb 9 10:24:36 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8086C70CB0 for ; Thu, 14 Mar 2024 14:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710426084; cv=none; b=N6o0bZRqkXsjSRRo8oElWpZ9fST5Z3h9tcdKVmKxFQg4K414r9bAIv244QoCba62H4fZEKp/byendrCOPlSlpHiP77Ad1JSGVDljfcu0Dk0Xi/OWvonhpf/kCiMB2fjBqXrdGoJIaBUZ0baXzQH+k7cAdu9+4HlRPgnCSRK4OA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710426084; c=relaxed/simple; bh=gtQrW/f+7C+gaOAoZH/KhR7pyutOL5DABu1wR3iLb6A=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=CWs4LFV1B0KOwxeD8ZsPhFQFgSnMR/6sKiqfG6X+L5KdhmojKnN9d21wMY/BpuSWn+2DUQ8coK2wFe49TbLlyzBTjf1697oePHZYM8UFlPPacnZedp+BNLXRo9bfsNe0anSOVyPXK/KeDDAJw7auOqydgpanp8AGun6PaeQInts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AAD6C433F1; Thu, 14 Mar 2024 14:21:24 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1rklzb-00000002dew-20cT; Thu, 14 Mar 2024 10:23:35 -0400 Message-ID: <20240314142335.342287656@goodmis.org> User-Agent: quilt/0.67 Date: Thu, 14 Mar 2024 10:23:06 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , linke li Subject: [for-next][PATCH 5/8] ring-buffer: use READ_ONCE() to read cpu_buffer->commit_page in concurrent environment References: <20240314142301.170713485@goodmis.org> 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 Content-Type: text/plain; charset="utf-8" From: linke li In function ring_buffer_iter_empty(), cpu_buffer->commit_page is read while other threads may change it. It may cause the time_stamp that read in the next line come from a different page. Use READ_ONCE() to avoid having to reason about compiler optimizations now and in future. Link: https://lore.kernel.org/linux-trace-kernel/tencent_DFF7D3561A0686B5E8= FC079150A02505180A@qq.com Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Signed-off-by: linke li Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ring_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 1d7d7a701867..13250856a3a8 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -4346,7 +4346,7 @@ int ring_buffer_iter_empty(struct ring_buffer_iter *i= ter) cpu_buffer =3D iter->cpu_buffer; reader =3D cpu_buffer->reader_page; head_page =3D cpu_buffer->head_page; - commit_page =3D cpu_buffer->commit_page; + commit_page =3D READ_ONCE(cpu_buffer->commit_page); commit_ts =3D commit_page->page->time_stamp; =20 /* --=20 2.43.0