Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2230963ybc; Wed, 13 Nov 2019 11:01:54 -0800 (PST) X-Google-Smtp-Source: APXvYqy98QY8d/5S/RLdFzfZGXmXsIT/4nqz9oHNhwSvQ+LeVnkWxRCQjw6MErwvqHK/xszr4tSA X-Received: by 2002:a17:907:4300:: with SMTP id oa24mr4380052ejb.8.1573671714771; Wed, 13 Nov 2019 11:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573671714; cv=none; d=google.com; s=arc-20160816; b=GMjCxv47v8UPvWekWN4wd4b4+zlIKjOANfrF98iyUyiHKW61GyD0hejMYZhePkUdyS wOv+SX1sRwsE6jw6ju6PBGANpTq0m4wOeUEQx9Xp13FoIwd9qVBuVpmXyAdDgro2zPGg 1LNs5hgtO+7HSJafxlSxJPTIA3WpyvO8A6+e2BzsBrskCbrqN7KskkHN1Icrd09MlcWI ZnisptdTtERSqNsbkY+X759qC0AJZAIqvHEBw40lvJJzzuR4Qu3if9lvPiSwWwztHgmR GgMWSrrUVuP02ZBCNbN5jWrSlPOeC2PiVdITO5/NDDIrIcR3RQkt3atfb8DOldCewn6E vJYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=pDKKsEnNSRaRtnTtkPfEq2dSlMtAaoLWzVsslXGiAh0=; b=XdRcyvoZgiZ/iF4D/qXCtkH6K+9wo2cCAXenV3hWWA6OlVKXGNLWW03eAAEFOUP96j JPL7CigiJeraShnR1kMUos0MyLjOZ0fJiYvrm14WXWlu1lSgnvwWjfWxM5TZArb1P48I JJoMd/tvqsX0q0HgRK9KynuOcK9pDXsL+bOxvLplw+EekL6Fl1eUxP15XcgDI13c5WPs 5KkWGsGSS2M3GpHKbRf27JevJUPdlX/sF0aZubUCHeKAlvJ1U/XLZFOwmG9i12zFXbo7 s6eSxKMfHVKlG/inrdUFD+OVrKvAsc4nerQ3/s7Enan7kfpY4drXZ+soJj9UoEIjPa4E ypxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@generalsoftwareinc-com.20150623.gappssmtp.com header.s=20150623 header.b=18309h9P; 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 s21si1794374eju.82.2019.11.13.11.01.29; Wed, 13 Nov 2019 11:01:54 -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; dkim=pass header.i=@generalsoftwareinc-com.20150623.gappssmtp.com header.s=20150623 header.b=18309h9P; 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 S1728363AbfKMQcl (ORCPT + 99 others); Wed, 13 Nov 2019 11:32:41 -0500 Received: from mail-ua1-f46.google.com ([209.85.222.46]:33106 "EHLO mail-ua1-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726521AbfKMQcl (ORCPT ); Wed, 13 Nov 2019 11:32:41 -0500 Received: by mail-ua1-f46.google.com with SMTP id a13so867060uaq.0 for ; Wed, 13 Nov 2019 08:32:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=generalsoftwareinc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pDKKsEnNSRaRtnTtkPfEq2dSlMtAaoLWzVsslXGiAh0=; b=18309h9PFFwMrlS/XYWNpakfrkLyFf5WzDSkRkznyRjceSIwnZc1mNodE+ZWZjDd46 XWqzYpymjBA7c11tSENL50ARuSWF8gsMk8nwGV2UHCn8Di5UFWpQKoq7Yq4HMsd/TJOT rtmfa2/1EKe7LrY8HjjxXWgSdRsQXlY49MIcfDyeV5fu/CprhZKmQuCPvazseo7f+DDp mbzQoBB/iYc1WEXsQLM7mfzHRYgsvPW5TrxNxbTbhuTL/J4EyOCh3t4+G9oYpQ8fW+kW g9VghxVQ6sELRogY0wGDB67jZlWDfPnzdBjcGmRj8Hi505v+Qzjqyu3JFuJUsfXGwA7H GF/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pDKKsEnNSRaRtnTtkPfEq2dSlMtAaoLWzVsslXGiAh0=; b=ho01cOrr3/mxR2Wpj7VJwih9/I401xtjIv/Equ9iv6vsWIDfjfll+hDXbXNojkiicc wSDcqx1bKnO6W2+ZsVhLZHNWMV23zuQ9b+xpmfko2Sc94/L55iRftGZQSl2J3ezAeSMr TVimU/KN2n/rInaMRYR0+w4F1WkzLFR0YaGnvag0AiwEYxIbLw93QKUbRzkGAAjCT86P FZQh0U1qDqGNYhroP1rqXnLrN8GOWNo9Gwfgz8oeUZKThamDVUa/LVBKu/RLyY8w6wRt RL4P6NWQfqcE5G1MwN5rB1LNHGPcnKPIJdO6tQop9Oupozxq84VJMh1QbwfrC39XX0yL n12w== X-Gm-Message-State: APjAAAXWGDgIPAk3RrwDaNs3SlPnNV2Jv8EdoWtEg0X7ZvV6DLQy5YHZ BjbHGrAU8hiD8CdAc3s5hDAZVrvTCtLHdg== X-Received: by 2002:a9f:3c13:: with SMTP id u19mr2369395uah.27.1573662758781; Wed, 13 Nov 2019 08:32:38 -0800 (PST) Received: from ubuntu1804-desktop ([172.97.41.74]) by smtp.gmail.com with ESMTPSA id r15sm587351uap.19.2019.11.13.08.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2019 08:32:37 -0800 (PST) Date: Wed, 13 Nov 2019 11:32:36 -0500 From: "Frank A. Cancio Bello" To: Steven Rostedt , Ingo Molnar , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: joel@joelfernandes.org, saiprakash.ranjan@codeaurora.org Subject: [RFC 1/2] docs: ftrace: Clarify the RAM impact of buffer_size_kb Message-ID: <0e4a803c3e24140172855748b4a275c31920e208.1573661658.git.frank@generalsoftwareinc.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171215 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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). Buffer sizes for individual CPUs may vary (see "per_cpu/cpu0/buffer_size_kb" below), and if they do -- 2.17.1