Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2356311rwo; Thu, 3 Aug 2023 08:16:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHS7ukfJ1P5nIvS5+qrRzH53PMJZSIN0SDtC0C3hx0hyr2gLzolW2vuHoylya/r+qjCn9Gm X-Received: by 2002:a19:5e5e:0:b0:4fe:d0f:1f1e with SMTP id z30-20020a195e5e000000b004fe0d0f1f1emr7306031lfi.25.1691075780178; Thu, 03 Aug 2023 08:16:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691075780; cv=none; d=google.com; s=arc-20160816; b=keMx+NMOqva/0pKLBczTOYWczhU63VYJLie5lVuR6rDA2BVImyI1eJZsZeSU4xiAfK t46oKOrm+j/kh5AthxAEiLfRJ5AW8rM+Xh8qPte/b7dKpSUTeZsARA5OgO6qsrGxL49x I+HNUYdqFR/pVkopUEIwy3jVPc3AAidEkzpAcAsIG9S8GJ5IN5optj4LluxZoF0D0cKi kVsJIg32yIdlpKWbc848mmWfMm/609hVyiVmaeqC2HIzHupEvGryD08Mbhaq+rjb3Pqw GtoIclZ70ZjMmHPk9SGSOBEsUwGx2TTD+PJYdgM/vCmocAMUX0O1BMGeYOcgVvb73bN5 zT6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=dxcXKfPpPhd8jIfnlWSJUphEjRKtzEmNC53XrnHszGc=; fh=y46xphR+PVQU6SaLWlUF61SWDP96QJyybi+mWwHgCbM=; b=a7fqLxHcfTtDqZ3pTfV5oSEaOaMT4frl21FQ9IiP259kB/1m6KnOyqCRsCE0bNef7S MRN0jiI13tUxKX7TDDzsuzfi5srliylvPXSGAx6faaKmna2Zy6DVUl146KugTzNKlB6F uqslTQyRs/y8ysK+yl10beE1G7DPygwP6N6fCCwE0Z+1JhlugToeLac/RhqsZU9cJHxg V0h2CEFJRg1FLqo6mgE9/c8t+jPCASwUYV+MWDky7RMDB6Kf8/W3XhAT3v5NdCpsK5v1 jUgJlAMbq6hqzVf3Vrw+C7ZP+O0iZgaOVZo9z8AuWDqsBZxiseGouN0/xlM45bh1cH9T ZMCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020aa7ce02000000b005230f8c483bsi901494edv.421.2023.08.03.08.15.47; Thu, 03 Aug 2023 08:16:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235614AbjHCOws (ORCPT + 99 others); Thu, 3 Aug 2023 10:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231874AbjHCOwr (ORCPT ); Thu, 3 Aug 2023 10:52:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A20921728; Thu, 3 Aug 2023 07:52:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 359F061DC7; Thu, 3 Aug 2023 14:52:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C95DC433C8; Thu, 3 Aug 2023 14:52:44 +0000 (UTC) Date: Thu, 3 Aug 2023 10:52:42 -0400 From: Steven Rostedt To: Vincent Donnefort Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v5 1/2] ring-buffer: Introducing ring-buffer mapping functions Message-ID: <20230803105242.2df8831d@gandalf.local.home> In-Reply-To: References: <20230728164754.460767-1-vdonnefort@google.com> <20230728164754.460767-2-vdonnefort@google.com> <20230801132603.0b18c0eb@gandalf.local.home> <20230802074526.2fa479ab@gandalf.local.home> <20230802111306.4f52c1c6@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 3 Aug 2023 11:33:39 +0100 Vincent Donnefort wrote: > [...] > > > > And on the kernel side, just a function to update the "writer fields" of the > > > meta-page: > > > > > > static void rb_wake_up_waiters(struct irq_work *work) > > > { > > > struct rb_irq_work *rbwork = container_of(work, struct rb_irq_work, work); > > > + struct ring_buffer_per_cpu *cpu_buffer = > > > + container_of(rbwork, struct ring_buffer_per_cpu, irq_work); > > > + > > > + rb_update_meta_page(cpu_buffer); > > > > > > wake_up_all(&rbwork->waiters); > > > > > > That would rate limit the number of updates to the meta-page without any irq storm? > > > > > > > Is poll an issue? It requires user space to do a system call to see if > > there's more data? But I guess that's not too much of an issue, as it needs > > to do the ioctl to get the reader page. > > I don't think there's any problem with this approach, beside the extra system > call... > > > > > We could also add an option to the ioctl to block, or have the ioctl honor > > the NON_BLOCK flags of the fd? > > ... but indeed, we could block there. The userspace interface would be even simpler. > How about? > > +++ b/kernel/trace/trace.c > @@ -8499,12 +8499,22 @@ static long tracing_buffers_ioctl(struct file *file, unsigned int cmd, unsigned > { > struct ftrace_buffer_info *info = file->private_data; > struct trace_iterator *iter = &info->iter; > + int err; > + > + if (cmd == TRACE_MMAP_IOCTL_GET_READER_PAGE) { > + if (!(file->f_flags & O_NONBLOCK)) { > + err = ring_buffer_wait(iter->array_buffer->buffer, > + iter->cpu_file, > + iter->tr->buffer_percent); > + if (err) > + return err; > + } > > - if (cmd == TRACE_MMAP_IOCTL_GET_READER_PAGE) > return ring_buffer_map_get_reader_page(iter->array_buffer->buffer, > iter->cpu_file); > Looks good to me. -- Steve