Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1758865rdb; Tue, 20 Feb 2024 06:17:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV3nTuOWENJqrSAFmYvcQZ/iyRC6z09Rk6DXKJyVEgxkhZIKt+H04a+wcATAFbyxwKF613jKdYEDFC6cQMO6QRHhTeKddfxAG91aDFNEw== X-Google-Smtp-Source: AGHT+IGaEuos+lLTgL8EwTUImoNKsf+weq9ehpsSxKElB5rHGOH2+CJ9P6X5L1gIe1i3/TKTRzNk X-Received: by 2002:aa7:d051:0:b0:563:e047:cb9f with SMTP id n17-20020aa7d051000000b00563e047cb9fmr8125909edo.19.1708438663528; Tue, 20 Feb 2024 06:17:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708438663; cv=pass; d=google.com; s=arc-20160816; b=ibmv+laVmmxxMI+WFhiNqy0eCNPOt+V+P8Wmp50w7nDX3iBQ1wZE55QO2EKB0MJEjV Y3c3hpUPaP9qovQ+U7ZOcVGD4n2SKPD5XlyNNFfE44K/L1XJOWmQboe6XN37cnyEJsTq kAazGueaITO9hAhoz44RrK1260H+ag9nqjmV1QL9hwjHksxlXDQLgicRo0R/n8Ya0XC6 z105/diKuqwGzds3+Tcl5a+pCg5pmQ8E9FgkcZq5SmpwDhAuaq7g/PPxSiQ3L2WBTeZo U85XU9x8JB69ZxnVNYC89Ln9Dyns9MGpaxJyKPllQzr0SssGHqjv0e7tmRurv4ufZVTx KWnQ== 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=8IADRXKqBcPZLmWiTmH/VddHTZusdUqBrJWPJRSao58=; fh=R8JZsVKDlS7lXIAvTNV55bsjlDBI0i4sqiOYXO4tZQA=; b=nPn7JGpDsPsrPN2QOmyoaWvgQ36+KU4T94bwA6/9oqOPaFHKENzJCBfDSNZuGpLxDw I3HlTCghlB5VtjhdNPGGRBNTHrNprCmOBDIfaaOn/owUALylOnkknYQxmDu244S/A3w7 3/cN9ksLN/NDOQtuxmyenb77LezqAromoBIgIK7PFWEtAQv/eTGK+zVbyvLMkGicSJEC w2gq1N6cQnz1gklmxcWR4AixdqZ77YyXwzbiudaf00IcG0MDXdlfT104VV9T4kvcPfSF GNmt7d67zlY0mPCw9Q/Y3v1JjnyFNoBiyfryShXGIUajVlLyIhm5ZQvqfPyyXWIdBcdi 2Izg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-73168-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73168-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a25-20020a50c319000000b00564dd136cddsi182590edb.208.2024.02.20.06.17.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 06:17:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73168-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-73168-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73168-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 49D641F21793 for ; Tue, 20 Feb 2024 14:17:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1656C6A8D4; Tue, 20 Feb 2024 14:17:39 +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 8FCB66A352; Tue, 20 Feb 2024 14:17:38 +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=1708438658; cv=none; b=lskySCh9hvbNx9R0VgXt3KKl8++5ORviJjmomUcSDvkFwdGohdaIWfPVqKgQaECU8xBunKRMuQJtz7EyFc91F9nJoIslkwXp22dPZ/SczdTs5SNdKjEAufm96i48B/yvAmEr7IJs/ewcpIiX/xvdzYj+0AGhe9+8pV4dN+NF19g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708438658; c=relaxed/simple; bh=qHlJwqessxV9XUwxNx0X6io3N2Cccxou6H8VwK7z4/4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LKdA15Nlf0xuyEkLxbe4P142Im3gOUg/x+Qsos8FSVyoRozxL6M/c9ccfeuTa2pde83RNX36ELN7SbJJ5TYjTfn9aaC+N+Ioeb1i2bPIxSNlVJRhN7KnzIh9KC15WzdXXUZ+hthgRMjlNiuHPdL3okHnMXYOglNGKGJo5PXghY4= 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 55523C433C7; Tue, 20 Feb 2024 14:17:37 +0000 (UTC) Date: Tue, 20 Feb 2024 09:19:22 -0500 From: Steven Rostedt To: LKML , Linux Trace Kernel Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers Subject: Re: [PATCH v3] ring-buffer: Simplify reservation with try_cmpxchg() loop Message-ID: <20240220091922.45848d9a@gandalf.local.home> In-Reply-To: <20240219182032.2605d0a3@gandalf.local.home> References: <20240219182032.2605d0a3@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 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. -- Steve