Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp317577rdb; Thu, 21 Dec 2023 09:57:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFly0EQj6otOJ1kK0228hZitHlnj4KPwtjd64cItcAZxGG24fDaGmWT/mIttI3KqiLwTz5 X-Received: by 2002:a05:6a00:26e5:b0:6d2:9595:b52b with SMTP id p37-20020a056a0026e500b006d29595b52bmr39388pfw.32.1703181449892; Thu, 21 Dec 2023 09:57:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703181449; cv=none; d=google.com; s=arc-20160816; b=kndSMEi0Pw4xNr46+roPMeJv8YRHbOjgdtDFBdG6yH26FNNskqhF+CAq/eeQ6ijre2 3oeDkHrjcTO58C6zOKKxam1Guu8WI4F44vS+2rsByKtse7n+Lei+wx1nKlvfCc03rUrs 4Px9TQbBDadnh7XKGriHwxunYgdRH84Z4SeyqwUaCq6JuVH9yAwZM0NUjBYdZdkcSvIe aIFrTGEvMwxPVmAe0lMMV1bnil/jh+ynJwnG1D3+co4OG+Y0LdyaOq1ynxTxW7NYCwIc 7+wiFZ8HPzFH94ZWeKZGfvSL34dNFVN77gJi+kjCVtciDcZSqRx2KB6pL1tRQSZ/j+UL L7JA== 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=IFZ9gPsaIpdmM8dnlo4Q8QdICXKvF7fxkBrFtQb5SGw=; fh=H7rhZUnZ+NlyyU7vxDXWwpu6VPK6D0cjPor36M8Xy6o=; b=yduQf7bD9BGLMcpiKk01U6wMvCWVNvYHZK5AZq84+IwUaSa4M9U5eA81ANO8T4eXjo K/2tnY1/FbwpA4DHqq7N8gQlcS8BFiPfZA+x1KQtZ570dY3EzydpKf7EqNmobn2P0r3y F+0a+1q1D+0tOYFehO3a7F6R1onlevlhF5bJ92CVZh6yTFmfFhlbzlE/3AWZRduhY4Ea +6u2m/PwdRZNFyVbdLUjJH6ThE6eNrw+/+0jfgeGr8KuhZFBipoIynsdwyBX7s8ewkEz TvVAy1iFRwMNuNg67XYwNS1LV766seNOK8AhMawBcr3lO8tqzrDYtwHnX6dPVOriZ10R wAsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8883-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8883-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z24-20020a056a001d9800b006d8ba635b86si1910842pfw.170.2023.12.21.09.57.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 09:57:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8883-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-8883-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8883-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 E3957B23EEB for ; Thu, 21 Dec 2023 17:57:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CBB9634EE; Thu, 21 Dec 2023 17:57:12 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org 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 A2DE864A83; Thu, 21 Dec 2023 17:57:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA2CDC433C7; Thu, 21 Dec 2023 17:57:09 +0000 (UTC) Date: Thu, 21 Dec 2023 12:58:13 -0500 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 v9 1/2] ring-buffer: Introducing ring-buffer mapping functions Message-ID: <20231221125813.673293a2@gandalf.local.home> In-Reply-To: <20231221173523.3015715-2-vdonnefort@google.com> References: <20231221173523.3015715-1-vdonnefort@google.com> <20231221173523.3015715-2-vdonnefort@google.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 Thu, 21 Dec 2023 17:35:22 +0000 Vincent Donnefort wrote: > @@ -5999,6 +6078,307 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order) > } > EXPORT_SYMBOL_GPL(ring_buffer_subbuf_order_set); > The kernel developers have agreed to allow loop variables to be declared in loops. This will simplify these macros: > +#define subbuf_page(off, start) \ > + virt_to_page((void *)(start + (off << PAGE_SHIFT))) > + > +#define foreach_subbuf_page(off, sub_order, start, page) \ > + for (off = 0, page = subbuf_page(0, start); \ > + off < (1 << sub_order); \ > + off++, page = subbuf_page(off, start)) #define foreach_subbuf_page(sub_order, start, page) \ for (int __off = 0, page = subbuf_page(0, (start)); \ __off < (1 << (sub_order)); \ __off++, page = subbuf_page(__off, (start))) And parameters as r-values should always be wrapped in parenthesis. > + > +static inline void subbuf_map_prepare(unsigned long subbuf_start, int order) > +{ > + struct page *page; > + int subbuf_off; Then you can remove the "subbuf_off". > + > + /* > + * When allocating order > 0 pages, only the first struct page has a > + * refcount > 1. Increasing the refcount here ensures none of the struct > + * page composing the sub-buffer is freeed when the mapping is closed. Nice catch by the way ;-) -- Steve > + */ > + foreach_subbuf_page(subbuf_off, order, subbuf_start, page) > + page_ref_inc(page); > +} > + > +static inline void subbuf_unmap(unsigned long subbuf_start, int order) > +{ > + struct page *page; > + int subbuf_off; > + > + foreach_subbuf_page(subbuf_off, order, subbuf_start, page) { > + page_ref_dec(page); > + page->mapping = NULL; > + } > +} > +