Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp626988rdb; Mon, 15 Jan 2024 08:16:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEunzui5ZAIX2lttIFSmCINaucfJ9uVOS8gdeFBGXgBFiRCNvBh1HyprIdDCVjWqvKqGYav X-Received: by 2002:a05:6402:6d7:b0:554:4c3a:f7db with SMTP id n23-20020a05640206d700b005544c3af7dbmr2728245edy.28.1705335376177; Mon, 15 Jan 2024 08:16:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705335376; cv=none; d=google.com; s=arc-20160816; b=K9JStFdMdTorxl9xCAZiXpMeOtqiSe48Vb8T+ENfcncuAlj9qOmq7AyMpCXhVVJXBz jYE32LDj38XTjZnZ0qcZnkHvYWRkRdyscoPRN54vrYMUj4xOkGu9x3NRkKkgAe8fYpF7 wUrG/6iCSfgY7+GCGdWvKQwxDE1qtvm1XOhu4Hq1RzgpCmSb5bAwaThPEFSuiRjzUEj9 W+nzK213mUJndY3euwoSDCBk44LskrT34S6ffufQ/QuNySIRiLuDT309U/f+bQ6ncSsw Vn++oEqQIVcyrs0w/8AsdITWmqNEnEUZpWFQ3AboVFLFwbh2eE7g89xW3jIRgUoRLNEg nOJA== ARC-Message-Signature: i=1; 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=LztoTZ0iNZ3D0PufCAlT4PZQbOgI+MrmAo+an88X+f0=; fh=9NsraGzYoFYIdTb+acwdk5gD6m8pHsK28rjiAl8maec=; b=iQNYOLBOvv+A2lrebba77cBtmRBYOzEk8OWGxMH4NkpdB8ntvV+BzhQg7l9x+GExYb PeGS3wtoiFZyiRP+zj+Npraqj7F6IT6WWSHqUXhzOpp4kEqOnJrmFMyfLSIXt9MrJgD6 ZP3KjqpSJf6V7VjBVxkSjlHhgfmnMZVmWf0qwfLWsGLXlAWHG5G4AGngSFRz1NJ+nKBg /RQ/E7UG4PusTU8mxsnKspHKO1Xv+DTB05RcS3mnGwC/94Pup/LbhtGHvnav9+RzqjzJ nwikwCT5LYrkjHnkgHsQzJUrRcOoN5CVrVv/K9VztQBfD9+XWMzNXe/LXqjxFsCJXZ+v gDXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26227-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26227-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h9-20020a0564020e0900b00557f4fdb58bsi4158271edh.110.2024.01.15.08.16.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 08:16:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26227-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26227-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26227-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B8AA71F23AFD for ; Mon, 15 Jan 2024 16:10:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24A0617BA1; Mon, 15 Jan 2024 16:09: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 A7B0E1799A; Mon, 15 Jan 2024 16:09:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F60BC433C7; Mon, 15 Jan 2024 16:09:40 +0000 (UTC) Date: Mon, 15 Jan 2024 11:09:38 -0500 From: Steven Rostedt To: Vincent Donnefort Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, kernel-team@android.com Subject: Re: [PATCH v11 2/5] ring-buffer: Introducing ring-buffer mapping functions Message-ID: <20240115110938.613380ca@rorschach.local.home> In-Reply-To: References: <20240111161712.1480333-1-vdonnefort@google.com> <20240111161712.1480333-3-vdonnefort@google.com> <20240115134303.1a673e37b8e7d35a33d8df52@kernel.org> X-Mailer: Claws Mail 3.17.8 (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, 15 Jan 2024 15:37:31 +0000 Vincent Donnefort wrote: > > > @@ -5418,6 +5446,11 @@ int ring_buffer_swap_cpu(struct trace_buffer *buffer_a, > > > cpu_buffer_a = buffer_a->buffers[cpu]; > > > cpu_buffer_b = buffer_b->buffers[cpu]; > > > > > > + if (READ_ONCE(cpu_buffer_a->mapped) || READ_ONCE(cpu_buffer_b->mapped)) { > > > + ret = -EBUSY; > > > + goto out; > > > + } > > > > Ah, this is not enough to stop snapshot. update_max_tr()@kernel/trace/trace.c > > is used for swapping all CPU buffer and it does not use this function. > > (but that should use this instead of accessing buffer directly...) > > > > Maybe we need ring_buffer_swap() and it checks all cpu_buffer does not set > > mapping bits. > > > > Thank you, > > How about instead of having ring_buffer_swap_cpu() returning -EBUSY when mapped > we have two functions to block any mapping that trace.c could call? > No. The ring buffer logic should not care if the user of it is swapping the entire ring buffer or not. It only cares if parts of the ring buffer is being swapped or not. That's not the level of scope it should care about. If we do not want a swap to happen in update_max_tr() that's not ring_buffer.c's problem. The code to prevent that from happening should be 100% in trace.c. The trace.c code knows what's being mapped or not. The accounting to keep a mapped buffer from being swapped should stay in trace.c, and not add unnecessary implementation coupling between that and ring_buffer.c. -- Steve