From patchwork Wed Mar 15 13:39:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pengdonglin X-Patchwork-Id: 13175889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9C5EC7618B for ; Wed, 15 Mar 2023 13:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nSSLOkK5JShj8BL2h8v/bqiVK0LFo9SO++IPo7ZLmVA=; b=3Y7krYekcJa+i9 T3kSbOLT6P4xnGDm4LOiLpJgVHaV2YmFogu/TOXa1mgSg9XI9AMBQWu4zP4v/6Pqrnl+pK9plvria OgzeF6Oqt5mn5t9OjubYZ4Eur8EXoqAvntJUPWUnO1N15inRdZrRgo9JwFDw21n/+Y4MlifsR46Yl ParxFToWUwEYAc/JGTGeKSGJyWQmcXmv9Xe9mHHRp4wawIG1BHWQmxZDmOXF5AocC54US4AkNWz3d iff3N5st+CEuMURv1BHUk1B5XMg+FdeOf6R3WQlXvEZVTq/TJp9pn9zfZwpwGRQJ4wkToW0u8jUXa AuYp0ntH45nZCinFMrQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcRLu-00DTW2-1c; Wed, 15 Mar 2023 13:39:38 +0000 Received: from mail-m118111.qiye.163.com ([115.236.118.111]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pcRLp-00DTSB-2Z; Wed, 15 Mar 2023 13:39:36 +0000 Received: from ubuntu.localdomain (unknown [121.32.254.146]) by mail-m118111.qiye.163.com (Hmail) with ESMTPA id 8DAFC58022F; Wed, 15 Mar 2023 21:39:18 +0800 (CST) From: Donglin Peng To: mhiramat@kernel.org, rostedt@goodmis.org, linux@armlinux.org.uk, mark.rutland@arm.com, will@kernel.org, catalin.marinas@arm.com, palmer@dabbelt.com, paul.walmsley@sifive.com, tglx@linutronix.de, dave.hansen@linux.intel.com, x86@kernel.org, mingo@redhat.com, xiehuan09@gmail.com, dinghui@sangfor.com.cn, huangcun@sangfor.com.cn, dolinux.peng@gmail.com Cc: linux-trace-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Donglin Peng Subject: [PATCH v4 2/2] tracing: Add documentation for funcgraph-retval and graph_retval_hex Date: Wed, 15 Mar 2023 06:39:11 -0700 Message-Id: <20230315133911.958741-3-pengdonglin@sangfor.com.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230315133911.958741-1-pengdonglin@sangfor.com.cn> References: <20230315133911.958741-1-pengdonglin@sangfor.com.cn> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVkaTkxMVkxDGRhKThpPHkkfSVUTARMWGhIXJBQOD1 lXWRgSC1lBWUpJSlVISVVJTk9VSk9NWVdZFhoPEhUdFFlBWU9LSFVKSEpCSE9VSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NSI6MTo*FT0TNRpNEy0aTT8Q Kh9PCi1VSlVKTUxDQ0NMTk5CTENNVTMWGhIXVQseFRwfFBUcFxIVOwgaFRwdFAlVGBQWVRgVRVlX WRILWUFZSklKVUhJVUlOT1VKT01ZV1kIAVlBTUtKSTcG X-HM-Tid: 0a86e57f20912eb7kusn8dafc58022f X-HM-MType: 1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_063934_495710_94D6E4F9 X-CRM114-Status: GOOD ( 13.33 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add documentation for the two newly introduced options for the function_graph tracer. The new option funcgraph-retval is used to control whether or not to display the return value. The new option graph_retval_hex is used to control the display format of the return value. Signed-off-by: Donglin Peng --- Documentation/trace/ftrace.rst | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst index b927fb2b94dc..8ebe8d0b8838 100644 --- a/Documentation/trace/ftrace.rst +++ b/Documentation/trace/ftrace.rst @@ -1328,6 +1328,19 @@ Options for function_graph tracer: only a closing curly bracket "}" is displayed for the return of a function. + funcgraph-retval + When set, the return event will include the function and + its return value. Note that even if the function return + type is void, a return value will also be printed, you + should ignore it. This option is off by default. + + graph_retval_hex + Depend on function-retval. When set, the function return + value will be printed in hexadecimal format. If this is not + set and the return value looks like an error code, it will + be printed in signed decimal format, else in hexadecimal + format. This option is off by default. + sleep-time When running function graph tracer, to include the time a task schedules out in its function. @@ -2673,6 +2686,48 @@ It is default disabled. 0) 1.757 us | } /* kmem_cache_free() */ 0) 2.861 us | } /* putname() */ +The kernel function return value can be displayed. Note that even if the +function return type is void, the return value is will still be printed. +However you should ignore it. You can use this feature to locate kernel +functions those return errors. + + - hide: echo nofuncgraph-retval > trace_options + - show: echo funcgraph-retval > trace_options + + Example with funcgraph-retval:: + + 1) | cgroup_migrate() { + 1) 0.651 us | cgroup_migrate_add_task(); /* = 0xffff93fcfd346c00 */ + 1) | cgroup_migrate_execute() { + 1) | cpu_cgroup_can_attach() { + 1) | cgroup_taskset_first() { + 1) 0.732 us | cgroup_taskset_next(); /* = 0xffff93fc8fb20000 */ + 1) 1.232 us | } /* cgroup_taskset_first = 0xffff93fc8fb20000 */ + 1) 0.380 us | sched_rt_can_attach(); /* = 0x0 */ + 1) 2.335 us | } /* cpu_cgroup_can_attach = -22 */ + 1) 4.369 us | } /* cgroup_migrate_execute = -22 */ + 1) 7.143 us | } /* cgroup_migrate = -22 */ + +By default, if the return value looks like an error code, it will be printed in +signed decimal format. In other cases, it will be printed in hexadecimal format. + + - hexadecimal or signed decimal (default): echo nograph_retval_hex > trace_options + - hexadecimal: echo graph_retval_hex > trace_options + + Example with graph_retval_hex:: + + 1) | cgroup_migrate() { + 1) 0.651 us | cgroup_migrate_add_task(); /* = 0xffff93fcfd346c00 */ + 1) | cgroup_migrate_execute() { + 1) | cpu_cgroup_can_attach() { + 1) | cgroup_taskset_first() { + 1) 0.732 us | cgroup_taskset_next(); /* = 0xffff93fc8fb20000 */ + 1) 1.232 us | } /* cgroup_taskset_first = 0xffff93fc8fb20000 */ + 1) 0.380 us | sched_rt_can_attach(); /* = 0x0 */ + 1) 2.335 us | } /* cpu_cgroup_can_attach = 0xffffffea */ + 1) 4.369 us | } /* cgroup_migrate_execute = 0xffffffea */ + 1) 7.143 us | } /* cgroup_migrate = 0xffffffea */ + You can put some comments on specific functions by using trace_printk() For example, if you want to put a comment inside the __might_sleep() function, you just have to include