Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1490597rbb; Mon, 26 Feb 2024 10:52:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCKOw4lMLtJv9Rm7ATvwvQCq5raiENsfe8m7lYm3xhCbgd+EFhDAxiFswLHyw7/zm26pqRXhSfeETvfJOy8HQcs+w0bviTi+npAa4MQQ== X-Google-Smtp-Source: AGHT+IGhbQUqfsOPEOvMTPOPMm502rI0Gmuh14jM3NoBgX4fOCfXfpR+QwM5HW95hsS6PgS3RN/c X-Received: by 2002:a05:6a00:140a:b0:6e4:b4ca:992b with SMTP id l10-20020a056a00140a00b006e4b4ca992bmr8433919pfu.21.1708973537968; Mon, 26 Feb 2024 10:52:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708973537; cv=pass; d=google.com; s=arc-20160816; b=nC6SQynWvh29oXGj84oyTmWWyNlH0VZR7HG53yLn9CVKcnIqWFaVaiNwtQGMZjF9eC wXjq0N0RlrEI6F+EZ0d2JpvhQ0tFnopU3vJ8+yoak3Sr3R4ViReGIkFsvXKME+metMsk 9X2FprysiQDMN5dJxhW1xeNZpfPTU/6mwlcW2ZTlIaKib9Hu0B3GLO5UdwVqbOQg8wFj xanmktw1PwXCqMhTIhqJbGs4MgYhxFOfjJmZiG7qOYI5MbX+xmtrMlzoxLRsjyjNyzbT onOElJNM/rUIncN28DZDKW3creJ7Rh/mUSbdfaaofhVwa7MjGEMAKMAwqGApxX5atV/d 2M6g== 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=qmciacpAK0AiKv+aLVLVyeF5yx8gngv/vpVBAOVTYNk=; fh=932KNpC5P7PBHRpOopR8J8f7uTkrCEBaJ3DhJNqevQk=; b=usYBWHbT9Fa17RUNHPElXt7dTQaifmnybeYpwIviepFloeoyAflZJ9la3H3DtvvK3H f9tiQ9Whne+8ZxWDii/yV3qVQUGYlVeEW0MXZACvG8r5tQJrrLWhLMoxJIk9CnuL81TJ dBriaubJ3v849TDSOULV5w/TffjPAyo+Daw6Uhw0gWed41Vx048RQZZwMXvP7jQ2LuW+ b697x7F//4XpPah1LTo2BCSLsZAWebaD2QSGBrXIznRMbkUnS4SgoKUnmFR7aHG2wiTU 6m/GLu0zEKaww/3OF04M1k/CSExeTDks48Q8au8/g9TfoBOXMwho2HnCXXl+rxngVs37 okzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-82163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82163-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v126-20020a626184000000b006e4f1a45aabsi4140556pfb.366.2024.02.26.10.52.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 10:52:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-82163-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82163-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 AB08B282AA9 for ; Mon, 26 Feb 2024 18:52:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D83512F365; Mon, 26 Feb 2024 18:52:11 +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 235FC12C53D; Mon, 26 Feb 2024 18:52:09 +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=1708973531; cv=none; b=pzngrsuRnKSDtxbAE9DTA/+g/+qCoICNuR25Q+ULNFS8vvKFvqDwRZZWDC9uj1eI/sBF5+joqIdUSLZySpvhPwGunWS7c9PMxM765HrGJCenFoqScAgk1LTF8hbZgmF0dt1JuLT6HBvEHpQcNFPgVURp5hYc+NrPyPrb34e/xrc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708973531; c=relaxed/simple; bh=3Gmla1nD+s6JL0VfGINBYQZbGiFVdJqDEG83H9jQ8uI=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XPAcQImyXdffDIISkk/FGrQfmYZ0n4gZZQ28S30eLvQJFX72Y7gH0NCfKUXX8XtDPhJFdyDb9zGvG+QXHSZQURM/9+V/+gKOZm6RmhuVTG1p16bqLIV1D7N1Te+dK7/sljAEi2lI5wUdCVJrFw972V4R/1KdYYmA/2Z8Ht21VFI= 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 83819C433C7; Mon, 26 Feb 2024 18:52:04 +0000 (UTC) Date: Mon, 26 Feb 2024 13:53:53 -0500 From: Steven Rostedt To: linke li Cc: Masami Hiramatsu , Mathieu Desnoyers , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH] ring-buffer: use READ_ONCE() to read cpu_buffer->commit_page in concurrent environment Message-ID: <20240226135353.3103b360@gandalf.local.home> In-Reply-To: <20240225150302.23c3c3c2@rorschach.local.home> References: <20240225150302.23c3c3c2@rorschach.local.home> 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 Sun, 25 Feb 2024 15:03:02 -0500 Steven Rostedt wrote: > *But* looking at this deeper, the commit_page may need a READ_ONCE() > but not for the reason you suggested. > > commit_page = cpu_buffer->commit_page; > commit_ts = commit_page->page->time_stamp; > > The commit_page above *is* used again, and we want commit_ts to be part > of the commit_page that was originally read and not a second reading. > > So, I think for the commit_page we do need a READ_ONCE() but that's > because it is referenced again just below it and we don't want the > compiler to read the memory location again for the second reference. Care to send a v2 patch that just adds READ_ONCE() for the commit_page, and change the change log stating that it is to fix the possibility that the time_stamp may come from a different page. -- Steve