Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2385315rdd; Fri, 12 Jan 2024 07:58:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFK88T0fzn5Nswom+M3oqZBtYPbTprurlJZDxj2CFUJSf+yrYoaa1NSmFlY1y6q84ilaIIB X-Received: by 2002:a05:6a00:460b:b0:6db:624e:93cd with SMTP id ko11-20020a056a00460b00b006db624e93cdmr333444pfb.23.1705075085661; Fri, 12 Jan 2024 07:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705075085; cv=none; d=google.com; s=arc-20160816; b=FtdYlteLHOF5Su0bRmmL8+8nUGhTJWhLVt0C3I3ilNhJjEtC0ygh57ZMwgLq0WvN0p WvsuO734A+jmeNzlU7i6qVjDn6ls3ZaYBYtzM39LTke1yRiBj7A411xCg9aiMDgKnwWS j9jD4L7c8MJfxZH17OooeTQF2zRwfHuCKfFtwytTMuG8g9LesMH3K5q7xzwfwaabUFo7 AYBiJrKWBaF0qF2wzsNCys9xBb1tOdFdLsa2oRry87atfum+h8AKgHhslZM5qFE/+AYQ Jej3S9T1X/+XoFsezn5vrj+W5s7/ceuSSV5FwUr2jlJNrlwvVvfF6m3i5m9CUOdah1pa BrLA== 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=0hEn4p6wSrZBSN7qTO9sqyIOqUZFGBz0ZprO7F/M+Uw=; fh=HpUCWQe5boeOyneRMQS5+eD/FKQ8/MkuFwPGMS/ifHs=; b=T2iRC8fMuBjRQm+1za7QR+xdpiBs+w/H+p7PbyPRY/gn6LUrPNNsKKAmPbR5jPQHkj vaxqBY81N5h0QCfaZ2d3EccfsddoM4wqY32N/iIUJvhmg1pXaSmxB7ZbEczJcm+GtM7g pIhiGZCqvOOqCQXLQuoLWJKpxz3cDzhAPwXbXDYz8RmYX8HoqCUNKGUWsbsc5I/OYLvo /8K0F2A59UXIL0U7X/E8lwp4t8eFOGtB3UZ6sKrsquO9PG394Lsp2IF69Yg+5mBl+pEj 53Dzk54dp9LGc/e6kCR3iFUQ+yWnl1v7b8y+h7cXxat0V2y1Cm8XZT4SBjoBxSMx+BvH n6TQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24831-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w11-20020aa7858b000000b006da9f53a872si3345681pfn.124.2024.01.12.07.58.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 07:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-24831-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24831-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1A3FFB22A5F for ; Fri, 12 Jan 2024 15:58:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A1766EB7C; Fri, 12 Jan 2024 15:57:52 +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 AFF106EB6E; Fri, 12 Jan 2024 15:57:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61562C433C7; Fri, 12 Jan 2024 15:57:50 +0000 (UTC) Date: Fri, 12 Jan 2024 10:58:55 -0500 From: Steven Rostedt To: Vincent Donnefort Cc: Mathieu Desnoyers , mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v11 2/5] ring-buffer: Introducing ring-buffer mapping functions Message-ID: <20240112105855.7f4c290d@gandalf.local.home> In-Reply-To: <20240112100641.3675edad@gandalf.local.home> References: <20240111161712.1480333-1-vdonnefort@google.com> <20240111161712.1480333-3-vdonnefort@google.com> <20240111181814.362c42cf@gandalf.local.home> <20240112100641.3675edad@gandalf.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 Fri, 12 Jan 2024 10:06:41 -0500 Steven Rostedt wrote: > I'm thinking both may be good, as the number of dropped events are not > added if there's no room to put it at the end of the ring buffer. When > there's no room, it just sets a flag that there was missed events but > doesn't give how many events were missed. > > If anything, it should be in both locations. In the sub-buffer header, to > be consistent with the read/splice version, and in the meta page were if > there's no room to add the count, it can be accessed in the meta page. I think the meta data page should look like this: struct trace_buffer_meta { __u32 meta_page_size; __u32 meta_struct_len; __u32 subbuf_size; __u32 nr_subbufs; struct { __u64 lost_events; __u32 id; __u32 read; } reader; __u64 entries; __u64 overrun; __u64 read; }; 1) meta_page_size The size of this meta page. It's the first thing the application needs to know how much to mmap. 2) meta_struct_len The actual length of the structure. It's the second thing the application will look at to know what version it is dealing with. 3) subbuf_size 4) nr_subbufs The next two is the next thing the application should do. That is to memory map in all the sub-buffers. With 1) and this, it knows how to do that. The first four are needed for setup, and never changes once mapped. The rest gets updated during the trace. 5) reader 5a) lost_events 5b) id 5c) read This is actively needed during tracing. It is what is used to know where and how to read the reader sub-buffer. 6) entries 7) overrun 8) read These are useful statistics, but probably seldom really looked at. They should be at the end. Also notice that I converted all "unsigned long" to __u64. This is because it is possible to have a 32 bit userspace running this on top of a 64 bit kernel. If we were to use "long" it would be inconsistent and buggy. Now if you need subbufs_touched and subbufs_lost. When that gets opened, it would update the meta_struct_len accordingly, and the structure would look like: struct trace_buffer_meta { __u32 meta_page_size; __u32 meta_struct_len; __u32 subbuf_size; __u32 nr_subbufs; struct { __u64 lost_events; __u32 id; __u32 read; } reader; __u64 entries; __u64 overrun; __u64 read; __u64 subbufs_touched; __u64 subbufs_lost; }; Make sense? -- Steve