Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp374520lqg; Fri, 1 Mar 2024 07:47:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVOs4OGG8gBB+z0MS3rNf7eE2FSxTNs87dsS/X0qoRpIbwWu2BhyYo/hp60t4ODmoyssJIgZWm5UvF/CXqlAdEqM2x4ZqS6FRiNgGbD+w== X-Google-Smtp-Source: AGHT+IEEr35iveBbOMv9h+l+/VZ7+Qpih4D/zFGYAdoaMGtn0XCRs7v8Ub7lVY0YGQqSfgRVC/mA X-Received: by 2002:a05:6a20:914d:b0:19e:a9e6:baf with SMTP id x13-20020a056a20914d00b0019ea9e60bafmr1995500pzc.0.1709308064271; Fri, 01 Mar 2024 07:47:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709308064; cv=pass; d=google.com; s=arc-20160816; b=0ma24xCbzaMhAfsI+gOOxoult7pQuX0qgRjHpvsVwFU2VQoA7ORWkYMcHohdAchihb xfHchs5txiyect8m6wAK/sG6sZ1PX2/wiz1oUiMRyZ8Qyx7CUQc3DJibl3HruC3xuPRi ZhSeb9LwZ2iKTN9g67x8jU26OGQ4jQTOlUy6B2HB2ItJeq2WW9TsBYpOmv7FN0dIrK9c 7fut+0XkJ96RRwyaFTr8Vq6tsjd7NAshcARLX8/CXMJBOMo5+bgKr2iZakXRPYC0oT0D DjoV3/Mhniq7I4snNHJMnk66ySxzrrMsvD5EpC6qtgtg5XWZ3vOTnxsQhOP0TWkysOlQ 1G3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=QroqXY6LHFjiSOdKV6AkjU/Bf3z6uTcw71W8Ruani/g=; fh=lGwW5lXhJ3xWkdGi5w6Msrr4cx4mWwhJgi8T+AHOup0=; b=TgpkelrMWtZ3wlvbyhcJeIG3p4YElguR/RbbMoYEtg+bbHtmwj3oorwXepsZSkKmk+ UbswsI2ikQTq3ex+j1puNYYQpEbqk5uytDAnso0AwsCgTVbNmOB5R5NJg7UWerM/W1sd krA4fPWIQzY6KnwYaADZbelRsSet8dPRQwEaq5IBEzQJGfnufR5+qj2zheMMl9bTO22f MvKZozaFQiOmFC95Wi8s49bTtqdrQJiNEa6eaNkVKtOIa0Da1XkAZCx9NmNlpkTCeOaK Z37C9JroK/SHgg4Ri0QLhpVSoFJQwY8Y54xr7Ab4OE+Kzu4ZTJzcf3/o0t8Dzcqxev7M eyzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-88636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88636-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x22-20020a17090a789600b0029953fe5ffdsi5732566pjk.91.2024.03.01.07.47.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 07:47:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-88636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88636-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B3318284DA8 for ; Fri, 1 Mar 2024 15:47:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 007777002F; Fri, 1 Mar 2024 15:47:38 +0000 (UTC) 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 7EA2D39846; Fri, 1 Mar 2024 15:47:37 +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=1709308057; cv=none; b=dTLEZo+yyC6Y4rrV4sqP75dRkBMkqH+oOLl/Ik9swGX/KzUUHQ3Y2k2NqYTB9MwEwYnRHWTlD1DLQxWMrKc1r/8zm5RHo/DrzaCTbLGSjPoRJpP1TlWuLsjsNS2csYMjeN8oh2Rw+5GYj1iE5WnAKFbH8JcMeVO/KXFFhmii+Is= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709308057; c=relaxed/simple; bh=+bBuSmzM80Yud3CUFZjh8lncJb6Dwdf1wkNLv/XbCmw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=I8pbmzmf6oxtABmpGHWown+JXQdYmd0OAmm1Dttr7IUdYLQhC0EZncOEMe4tOtgXXGDqIdyZkC4jYcF7+WHE2TwZJ743u/EJx/aOWM61zewni+2lV3hSQolmXP+0Jj/0cmt3XDwxz6Wg4paqsZpyg5N0KwRLzS4aLGFanC8Jors= 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 7112FC433F1; Fri, 1 Mar 2024 15:47:36 +0000 (UTC) Date: Fri, 1 Mar 2024 10:49:45 -0500 From: Steven Rostedt To: linke Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, mhiramat@kernel.org Subject: Re: [PATCH] ring-buffer: use READ_ONCE() to read cpu_buffer->commit_page in concurrent environment Message-ID: <20240301104945.43119349@gandalf.local.home> In-Reply-To: References: X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 1 Mar 2024 13:37:18 +0800 linke wrote: > > So basically you are worried about read-tearing? > > > > That wasn't mentioned in the change log. > > Yes. Sorry for making this confused, I am not very familiar with this and > still learning. No problem. We all have to learn this anyway. > > > Funny part is, if the above timestamp read did a tear, then this would > > definitely not match, and would return the correct value. That is, the > > buffer is not empty because the only way for this to get corrupted is if > > something is in the process of writing to it. > > I agree with you here. > > commit = rb_page_commit(commit_page); > > But if commit_page above is the result of a torn read, the commit field > read by rb_page_commit() may not represent a valid value. But commit_page is a word length, and I will argue that any compiler that tears "long" words is broken. ;-) > > In this case, READ_ONCE() is only needed for the commit_page. But we can at least keep the READ_ONCE() on the commit_page just because it is used in the next instruction. -- Steve