Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2707695rdb; Mon, 12 Feb 2024 13:57:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXqq8x81+hI4xO8+MPIjefDy3rCRRmnLI+7H/Zv5tQEioqq0yn3YNpyd57QqXQilo3ABowwf213iidGAkUga3zQaPDFIaxT6tV0VThYKQ== X-Google-Smtp-Source: AGHT+IFcmNtSAs3+6Z/sDP+rYRKcwlqi26t7SL5MOMjOFn7vaUsEwGGayJemduF6CXlK9gnR6GfK X-Received: by 2002:a92:c52e:0:b0:363:e8f4:eb4f with SMTP id m14-20020a92c52e000000b00363e8f4eb4fmr9039048ili.3.1707775044829; Mon, 12 Feb 2024 13:57:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707775044; cv=pass; d=google.com; s=arc-20160816; b=sRc+MiVeihRHEaudzZZOGXZGcJyGDUBXDv4UTmv6wM1DCeTEBlomhqgeiUnQ0aYZM/ 6CwmHk5zT7ThytgQ3WC2bhi5cbJctm3NzRd1+myd90YsxgBcsZya/1koGCfjMbIdkFCf /+9p9PQrTfTc2bej0Xbte41KtjsdLmiqDK7GVTVQJXFqZ0JBOcSmy6gjoRogdIHnr7/7 4GyB+iDosMnxMzq9x8d9SFjOMCp9ihZG3eNCL67Q7zpKbPExvqOSV6pt2apL5GDIw18o dfYJbt2dUSSDpYNEfvSiozx/LQh+kZfBfYP+cEmxO64qVpkgE3WLXZahdMhsfQfbMlVV F5zw== 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=1VrrlnrrTXfQBzWHIpabT1VjgYsZ/dOXI3dAoYe/SKE=; fh=ldMnAtW4j838KV1tAQMpdJfFvuTwf55x/VVd3Gmm5tk=; b=X8Ziv0DA2YzuxsBN2dDKgJY93BOrfIz6Dmic6twssqUW/qhhAVnA1fUUA2ZN3a73xv sFLhVaYWHUWCNbAHsDDJXK8p2tEZq+1U87ipoHmB8bO3Qd+bOCqWdQhLPV8yPa44EJXx 0hFHegte17FtL2JnJ2RLYbQkUxRv+Iy7IFaNM4I0rzLx7I1mgOYCFoQVE+8kmNiOeMoX jkIvMerXUXanhPx/P/ZCZsphiXpZDjyRMUnRQR7LB/wIWvnzW8gWCBNvo4yczcfMXi7P ie2ucDWTp5WZcwTq2HcYanV8k/H67E0HTBY3p7TCXMj4bc2qhl1lhGfl5iss4Ntts2VO /L+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-62443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62443-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWnRqqmMg830ykZu3y4uNBvXhpjH5BEp3RYEI63leZBbj/4wStWup1N6lG4k69llo42+2ymPTlwoQ2ZqItl+evES9LweZPXZzSeEryUaQ== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z21-20020a656655000000b005dc81a30772si264224pgv.301.2024.02.12.13.57.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 13:57:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62443-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-62443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62443-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 5421F282AFE for ; Mon, 12 Feb 2024 21:54:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D2184F1F6; Mon, 12 Feb 2024 21:46:42 +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 E85A14F1E0; Mon, 12 Feb 2024 21:46:41 +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=1707774402; cv=none; b=PhHNbKzloj86sQINgdRIfhRxulxg5f66sJhczWVsHsUFsIRez+eYmcH64JDHGYPhuBrSyPhhrR9ZmekskCUpjkgXlvQlgWH6CAI2RDju1XcCgUxW5bV67hBpS6eVHgVW+cxg6axb69u8+sLSwVzPNBQE38aR/8he7eXGssItR6Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707774402; c=relaxed/simple; bh=OWwHJ8PgKLGXLWXwGyPBKHjW/seZqo+nF2xyRUcgZec=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jrlylrxOawI4WQuPRsqDkf81ruH4o5nfH/D3vcaeINC1lF5avEdfSO31ukz3BAw0NPGI6JQAUR/qXujCqS5fIoAh8ihrYDV5mwwXVYBtfA5djyLEVh7BZxmPlr2Ns3CW9PTQscfkfmXFAvuLVqgVui6e0YSbXHEsQ+x/WZfsSTQ= 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 AF1B4C433F1; Mon, 12 Feb 2024 21:46:40 +0000 (UTC) Date: Mon, 12 Feb 2024 16:47:23 -0500 From: Steven Rostedt To: Vincent Donnefort Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, kernel-team@android.com Subject: Re: [PATCH v16 2/6] ring-buffer: Introducing ring-buffer mapping functions Message-ID: <20240212164723.55993db2@gandalf.local.home> In-Reply-To: References: <20240209163448.944970-1-vdonnefort@google.com> <20240209163448.944970-3-vdonnefort@google.com> <20240211171837.6a4ea1a5@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 Mon, 12 Feb 2024 10:44:26 +0000 Vincent Donnefort wrote: > > > static void > > > rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer) > > > { > > > @@ -5204,6 +5227,9 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer) > > > cpu_buffer->lost_events = 0; > > > cpu_buffer->last_overrun = 0; > > > > > > + if (READ_ONCE(cpu_buffer->mapped)) > > > > Isn't the buffer_mutex held when we modify mapped? I believe it's held > > here. I don't think we need a READ_ONCE() here. Is there a reason for it? > > > > Hmm, looking down, it looks like you take the buffer->mutex after > > setting mapped, is that necessary? If we take the buffer->mutex we can > > sync the reset with mapping. > > The idea was to not take any of the buffer mutex, reader lock if the refcount is > simply inc/dec. Locks are only used if the meta-page is > installed/uninstalled. Does it matter? The inc/dec is only done at initial mapping, right? That's a very slow path. > > The WRITE_ONCE/READ_ONCE is there only to make sure no compiler optimisation > could lead a reader to wrongly interpret that refcount while it is inc/dec. That > is probably not necessary and I'm happy to either drop it completely or replace > it by taking buffer mutex and reader lock whenever the refcount is inc/dec. Yeah, probably best to drop it and keep updates within the mutex. -- Steve