Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1808857rdb; Tue, 20 Feb 2024 07:39:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVjB7sAi/4ErieT0gMUN3csJL8sT9OeS7G6hzC5yEIEAa8EaIjO4eQDsyVvMQftKX+w8SrzQhjdTKnxah2MR2CuXHv/8pSUMaly3LKhkw== X-Google-Smtp-Source: AGHT+IFdKOyXvlqUZ8E6hSInKnEEv1QFby78U/2nyTv33kNq9CrS9Xds4WLD5+Z1Ia5gvDSmQXha X-Received: by 2002:aa7:8506:0:b0:6e3:53f4:3ab3 with SMTP id v6-20020aa78506000000b006e353f43ab3mr8955024pfn.2.1708443546168; Tue, 20 Feb 2024 07:39:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708443546; cv=pass; d=google.com; s=arc-20160816; b=Zz1LIz6KKd6ZSohtvS3GhDiz66+wOULnciPH2S5cLqPyEB6CGNfTqz1fB4CXY9qoSW 5BCGs1lAO5CmXSEwyggDpmME0a29AO8cHwWCnvQKpcx2BJyoKOBtVDu6ZpeGueqbV6cY RJY3WIH1W2CCYjxklCplEzruj+Y2OEtHieXgMJFTonzhqbQic5c0a9F1hdbLRpcQ2LGd oZMQdxYmc/RMapgzhcMck+q1EPzOYsrg1C5T8Oii2p32c6AQnlZKiQz8isICAvjNp1eN rxySgl5KxjlYKZyrAZRLhSI5GEgVWX7noKOIYdh+4l4vplUqRrubEaHZBkflQBOhDKji 38qw== 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=FZS1rEZtBbRlLpWiglgY0aNBkncGKHDBsi/OHcemO1M=; fh=DXqSFHFMGWs8NWhSKawAW+CcN1HWregSaTKgaWTRpeY=; b=f1GfswhWSQo/GcWBAmDNfG8Ebw6ZVEcTTTyHlpAdZUcllSMsL0jZf2+vOJcdA1WpWK JxZYB22oMYSdYCGBiXXLgXWjvxM53L4Gf/jNMR9jZiU0bXU87j5MYSrGr+O6pbwEhON0 VEpkLNCtYy87js1uySa4WC1r4M1a0bYgwNJvIehFbHJ6/fLplWRdXssS5Gjkfnqv463G dyOPV6ERdv2n4b0UQXRihxQ3vPVMGBVjVzywuwDuB08rLLKnwzhC6pT0InulNdk5MhBi GofAfuEFPAOpujXqS9DmJN7A25zIw3v3ti6o9kEZahF2z+kRsjQntgbwvQLbBw7Zy7Pq Sn+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-73260-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73260-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id u4-20020a056a00098400b006e2f06f6efasi5916058pfg.33.2024.02.20.07.39.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 07:39:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73260-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-73260-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73260-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 D8AAE2850A7 for ; Tue, 20 Feb 2024 15:39:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 291B2762C5; Tue, 20 Feb 2024 15:38:40 +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 A557076031; Tue, 20 Feb 2024 15:38:39 +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=1708443519; cv=none; b=HZnXLmdt580U3ZJTEO62hv1xmT5zGNQtHYjeJ5LoaZKpaR6QkSem1sGyMI1wK8zHiGd0nE3Vtr3HNcZaoHdmov3F7QKFeoGnOkS4GkjG/g1g7LP4pGCs2Rx/ESnzPXgbNPvvRARUD/4Ian1d1DaNLLt0klOgaPJtjVQzBzCDfZ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708443519; c=relaxed/simple; bh=+GWUaKj8l/UOXz/ZncL8CGObQZYYkF42lOpmXt3dqRA=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W2eVVX2V0bA+igMvwz2SpoqV8zi1sipwBuDKT35fgTWhLslLNl7PZSgY1j33ZYvsf70o/nPgZ8EwpPxCRGQEfaTYrM1QxOYvjjgLMORiOzIj0jqCPlZx8yA+VuAt3qCGiAaO1k/4stlMO+06oZFF02tyFYO+uiPjfE4wn9FDCYM= 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 795D7C433F1; Tue, 20 Feb 2024 15:38:38 +0000 (UTC) Date: Tue, 20 Feb 2024 10:40:23 -0500 From: Steven Rostedt To: Mathieu Desnoyers Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Mark Rutland Subject: Re: [PATCH v3] ring-buffer: Simplify reservation with try_cmpxchg() loop Message-ID: <20240220104023.2182b5c3@gandalf.local.home> In-Reply-To: <168765ff-98ea-42a1-82f7-56178bfcf7ec@efficios.com> References: <20240219182032.2605d0a3@gandalf.local.home> <20240220091922.45848d9a@gandalf.local.home> <168765ff-98ea-42a1-82f7-56178bfcf7ec@efficios.com> 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 Tue, 20 Feb 2024 09:50:13 -0500 Mathieu Desnoyers wrote: > On 2024-02-20 09:19, Steven Rostedt wrote: > > On Mon, 19 Feb 2024 18:20:32 -0500 > > Steven Rostedt wrote: > > > >> Instead of using local_add_return() to reserve the ring buffer data, > >> Mathieu Desnoyers suggested using local_cmpxchg(). This would simplify the > >> reservation with the time keeping code. > >> > >> Although, it does not get rid of the double time stamps (before_stamp and > >> write_stamp), using cmpxchg() does get rid of the more complex case when > >> an interrupting event occurs between getting the timestamps and reserving > >> the data, as when that happens, it just tries again instead of dealing > >> with it. > >> > >> Before we had: > >> > >> w = local_read(&tail_page->write); > >> /* get time stamps */ > >> write = local_add_return(length, &tail_page->write); > >> if (write - length == w) { > >> /* do simple case */ > >> } else { > >> /* do complex case */ > >> } > >> > >> By switching the local_add_return() to a local_try_cmpxchg() it can now be: > >> > >> w = local_read(&tail_page->write); > >> again: > >> /* get time stamps */ > >> if (!local_try_cmpxchg(&tail_page->write, &w, w + length)) > >> goto again; > >> > >> /* do simple case */ > > > > Something about this logic is causing __rb_next_reserve() to sometimes > > always return -EAGAIN and triggering the: > > > > RB_WARN_ON(cpu_buffer, ++nr_loops > 1000) > > > > Which disables the ring buffer. > > > > I'm not sure what it is, but until I do, I'm removing the patch from my > > queue. > > Try resetting the info->add_timestamp flags to add_ts_default on goto again > within __rb_reserve_next(). > I was looking at that too, but I don't know how it will make a difference. Note, the test that fails is in my test suite, and takes about a half hour to get there. Running that suite takes up resources (it's my main test suite for all changes). I'm currently testing other patches so I either need to figure it out through inspection, or this will need to wait a while. -- Steve