Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1100385rwo; Wed, 2 Aug 2023 08:43:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFp6U6qEge7+3coDRGek3wMVpXbArUJdxsa87O3ZAjUv5OvE90j3C1PV4mSDcSVcA5McfM X-Received: by 2002:a05:6402:134c:b0:522:abaf:1b0b with SMTP id y12-20020a056402134c00b00522abaf1b0bmr7944537edw.18.1690990992661; Wed, 02 Aug 2023 08:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690990992; cv=none; d=google.com; s=arc-20160816; b=V0fN9XdTxZerkB9cL4NAdTBXgyApCUVdfpIBpOsg0J4Vhzem9k/WzCYi4W6X20Smpg 8BkWk0GWA/A3EeDSZiBvo09SCubrnIlhufWLZgP3/bTrFl/oUwQw5MHPTeX6zA7jO/EQ 7GDPrftnH4nkJ4hIf0xHaRkx2CwmQaO276dSBHMgJRqHcvdNdU1GviXl43pK4SqbakQn 66s3EVfEGpPUlhY9TaDKNRJ+p9LB8RKMJHPrHJELW4OKeuC1j7TbEBAauwSxLM+k6rVY Cn+aY9YtHqVAVSALVhXy1sM3oxgwPFilCVfL5ZE9JT/1tUn1qipVR2vh0HTBDIsh8UlX f1aw== 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=0NWSN/BijPx/R+tl8QNSO1iPuUuXE+N8il3cAaM2VVQ=; fh=y46xphR+PVQU6SaLWlUF61SWDP96QJyybi+mWwHgCbM=; b=xBeX9/hai8ajYMa5c28Bx+liEXy3g3anqSzUX8/msiTT0KEldni3Ee7iu6gY0xcNl/ vJ6dmv6U/VRGQ/7pcnr6WNAvlTXkDiCHvfzpjvjDrh7R+tu4aX2ZM+OkpGvsRk2hz4+m syZvh86vclIoaKkotGrq2JPkuhqlFt2RT4t2UYI8YVZuouJjFgEeXZyqGnX3vwn+vSFW 1F//Aqgbtxx2LIC7uvbeOU9c2WqErc64HwdNX0JfzUCDckmpWT0pa8/4qBjLFHOzL5yv cnd89KZRw+cV70CHAc6o4WkimB9x6SJYykGYh6lTyaA6KkqYp1wlTh3VTo12rzrl0B2U MDrA== 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 b15-20020aa7cd0f000000b005227e4f12fdsi7315891edw.237.2023.08.02.08.42.47; Wed, 02 Aug 2023 08:43:12 -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 S233840AbjHBPNT (ORCPT + 99 others); Wed, 2 Aug 2023 11:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235022AbjHBPNM (ORCPT ); Wed, 2 Aug 2023 11:13:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B0DC11F; Wed, 2 Aug 2023 08:13:09 -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 208D16186B; Wed, 2 Aug 2023 15:13:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0BEBC433C8; Wed, 2 Aug 2023 15:13:07 +0000 (UTC) Date: Wed, 2 Aug 2023 11:13:06 -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: <20230802111306.4f52c1c6@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> 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=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 Wed, 2 Aug 2023 13:30:56 +0100 Vincent Donnefort wrote: > On Wed, Aug 02, 2023 at 07:45:26AM -0400, Steven Rostedt wrote: > > On Tue, 1 Aug 2023 13:26:03 -0400 > > Steven Rostedt wrote: > > > > > > + > > > > + if (READ_ONCE(cpu_buffer->mapped)) { > > > > + /* Ensure the meta_page is ready */ > > > > + smp_rmb(); > > > > + WRITE_ONCE(cpu_buffer->meta_page->pages_touched, > > > > + local_read(&cpu_buffer->pages_touched)); > > > > + } > > > > > > I was thinking instead of doing this in the semi fast path, put this logic > > > into the rb_wakeup_waiters() code. That is, if a task is mapped, we call > > > the irq_work() to do this for us. It could even do more, like handle > > > blocked mapped waiters. > > > > I was thinking how to implement this, and I worry that it may cause an irq > > storm. Let's keep this (and the other locations) as is, where we do the > > updates in place. Then we can look at seeing if it is possible to do it in > > a delayed fashion another time. > > I actually looking at this. How about: > > On the userspace side, a simple poll: > > static void wait_entries(int fd) > { > struct pollfd pollfd = { > .fd = fd, > .events = POLLIN, > }; > > if (poll(&pollfd, 1, -1) == -1) > pdie("poll"); > } > > 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. We could also add an option to the ioctl to block, or have the ioctl honor the NON_BLOCK flags of the fd? -- Steve