Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2120628ybc; Wed, 13 Nov 2019 09:16:23 -0800 (PST) X-Google-Smtp-Source: APXvYqw5wv9SPuVNG3Az2T0e+vfpz5SqE5xmCBCse/SRJ61m+9ud6U4Z1Pt/V9BZPlH7lCMpYhOz X-Received: by 2002:a50:9fa4:: with SMTP id c33mr4833070edf.176.1573665383586; Wed, 13 Nov 2019 09:16:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573665383; cv=none; d=google.com; s=arc-20160816; b=X0ROlbuWfgxhHMJKIKlk5T1TuVQ1CM0LeQux+Iw/7651kJMLQetazkUbSfqrdwvs55 WRV4OlKEk3SqeHqtAegK5+gHG6TzA4UPmpZ+mKR9eyBKrans7kKLwkM9aGEItn9m+oN4 gZscK9ZcssYa4YaJvQUdF3DuL/Vqe0zM/WfnxFiE4xPrGGkHewFS0FljYv/w2Ot3O99x Tc8GvVK7S5uyuu9DgOzQ9z5uvFNNmcM1dw248woawfMj3LSOPdXFIP2HdfRbqfK73bEW 4gUgX/k41Z+CzjPCKzZRC4O9Z/TWwPsCcn1pHF6lSbXaFy8hht0jbOgEQhBBxv9C7hmu 4BRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Hg2yvctGYhdS0nI5FbkkD0XPxDRhNLnBdiCVGidBFPs=; b=GLR4xM4Pvj0N+clKeY8p7Nx9SPeFSrsUlza1zo+FjzsZid0qQCGlK2QCRbv1y9xmh2 He2sO0sRmvM1Wm58BGGqOr7GOcq6g4gdQXhhsa++8mvQmCHgJigeVBzZfX7iCvSUfw2Z iAsejjPG+STTCaE725s7O1mmkIzPsHAvZNxcmf9tm/kxCrZzPehPFFM5oFs1LCAWXiCv FVY3Hr7lQtYU+SwW2V8pDkNkCwsdmTgftni0K7BeBTSDMPuwAbgfTaeAGBmug1Hc9e5n 5y55SSZTHN0lG8sU1EGzQZGh9iut0/Vkki5/sUpjcG9CPP/UGFY2PKEe4pza3lhn0erk QCxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si1885927ede.61.2019.11.13.09.15.59; Wed, 13 Nov 2019 09:16:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728485AbfKMQhd (ORCPT + 99 others); Wed, 13 Nov 2019 11:37:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:55322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbfKMQhd (ORCPT ); Wed, 13 Nov 2019 11:37:33 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 27FEA2051A; Wed, 13 Nov 2019 16:37:30 +0000 (UTC) Date: Wed, 13 Nov 2019 11:37:30 -0500 From: Steven Rostedt To: "Frank A. Cancio Bello" Cc: Ingo Molnar , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, joel@joelfernandes.org, saiprakash.ranjan@codeaurora.org Subject: Re: [RFC 1/2] docs: ftrace: Clarify the RAM impact of buffer_size_kb Message-ID: <20191113113730.213ddd72@gandalf.local.home> In-Reply-To: <0e4a803c3e24140172855748b4a275c31920e208.1573661658.git.frank@generalsoftwareinc.com> References: <0e4a803c3e24140172855748b4a275c31920e208.1573661658.git.frank@generalsoftwareinc.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Nov 2019 11:32:36 -0500 "Frank A. Cancio Bello" wrote: > The current text could mislead the user into believing that the number > of pages allocated by each CPU ring buffer is calculated by the round > up of the division: buffer_size_kb / PAGE_SIZE. > > Clarify that the number of pages allocated is the round up of the > division: buffer_size_kb / (PAGE_SIZE - BUF_PAGE_HDR_SIZE). Add an > example that shows how the number of pages allocated could be off by > 5 pages more compared with how the current text suggests it should be. > > Suggested-by: Joel Fernandes (Google) > Signed-off-by: Frank A. Cancio Bello > --- > Documentation/trace/ftrace.rst | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst > index e3060eedb22d..ec2c4eff95a6 100644 > --- a/Documentation/trace/ftrace.rst > +++ b/Documentation/trace/ftrace.rst > @@ -188,8 +188,17 @@ of ftrace. Here is a list of some of the key files: > If the last page allocated has room for more bytes > than requested, the rest of the page will be used, > making the actual allocation bigger than requested or shown. > - ( Note, the size may not be a multiple of the page size > - due to buffer management meta-data. ) The above is not untrue ;-) > + > + The number of pages allocated for each CPU buffer may not > + be the same than the round up of the division: > + buffer_size_kb / PAGE_SIZE. This is because part of each page is > + used to store a page header with metadata. E.g. with > + buffer_size_kb=4096 (kilobytes), a PAGE_SIZE=4096 bytes and a > + BUF_PAGE_HDR_SIZE=16 bytes (BUF_PAGE_HDR_SIZE is the size of the > + page header with metadata) the number of pages allocated for each > + CPU buffer is 1029, not 1024. The formula for calculating the > + number of pages allocated for each CPU buffer is the round up of: > + buffer_size_kb / (PAGE_SIZE - BUF_PAGE_HDR_SIZE). I have no problem with this patch, but the concern of documenting the implementation here, which will most likely not be updated if the implementation is ever changed, which is why I was vague to begin with. But it may never be changed as that code has been like that for a decade now. -- Steve > > Buffer sizes for individual CPUs may vary > (see "per_cpu/cpu0/buffer_size_kb" below), and if they do