From nobody Fri Dec 19 09:52:48 2025 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E0FB314A65 for ; Mon, 8 Dec 2025 13:19:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765199968; cv=none; b=up2EK6S5nz+HqKO1OALYTZve3n5AnltQDVczSJz/tNshpPj8oyREDjuMcoH5TzKjpn9rr5UUrIASEBcqhG5W3fETL+SD/CGTlskwhTf62Rl3LwhNJSdW8IfGm6zwrAoTIZS4j1tbeRT2GY/uQBQYd/SQuP0kHFwqVog8sZhSStk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765199968; c=relaxed/simple; bh=30o7EXsT+3UE9XemGnLUmRBLG1W6L02/uoH/F43nEZc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BWotCkaGP/FndHaqp4mXeFGkZYgDFpQkEAElsY/IRy15elXWLKOyA5M/j4mHMd6IuENCC9waDvAtwVV7viZtCZEeUOkeAJuW70+6R0SizFiWPGbDb5AAPHWyTHTwuReciIymXOidNzBth2eomq6RSHPIVAxvv7d/RxzrUPvc9Zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=G4wS5yNZ; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G4wS5yNZ" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2984dfae043so45137785ad.0 for ; Mon, 08 Dec 2025 05:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765199966; x=1765804766; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lZnyUry+1w8xao5+MHyxhYILKDa1nn4nE9blPajp6gw=; b=G4wS5yNZjiOURtICLLVcSskh/lLVrSopH7L0y09BhaUHXCbopeaO7y19/ARIb54mOy 5pjOVnlAw0Ls5TPxpbi1EMUwhVDewjED8SXjo/gmwDRc1kWsznKlLyDtD2/1VPwhoCo9 Vm5uKtYY1ebm6kW9n9A/i+MdHV6HfFEla2UOlX7hGCYOLOPj6mfnQ7MKqtgPBr6Lgq1S 5x52l63sypJnqESxjS2HeNdiIdzt/mHqiKOrNe0+bcd4e/wfv6C6EYfnpJJwMx4TQiO4 SHKzPQnP7CRksNl5av+31SPKbgRX15V/exz1KWp6N0m5ZoREG8UsdpT2ISN/Bpbt4e4b vvXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765199966; x=1765804766; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lZnyUry+1w8xao5+MHyxhYILKDa1nn4nE9blPajp6gw=; b=sjRgWrD/BSFkE+/QLDBS+10qKNO0Cg7as2CMB5OGWICqPEuKRZjZEFKMm+rlJC60nt +gSCnz9+Oany2e3TeXmWoMMkuOAbowJ1JmBxYJAvsnWXpNRKJoxwTOyXXYKq8SU+iril 5Jt7Of09zgWFo+ZHd8FVKw9tFOLYblPSdcSS+288M4h+DH4cQyENX4r+m6ipiYwuu8e+ OlhXKjhPNPHH/xWiqTLHJwfHo9TirNpGg5Dmajh8dGoVO+6XOyfieO3PgWG5pSxfxcj6 fPy2MfLtjR9AJU33JDLrskdyIpP2rJr0+iiOMEcFoXGTj2ZtWxl0UlPjT7C9bIIUlvbh rI3w== X-Forwarded-Encrypted: i=1; AJvYcCXPkyC16R6JDKhRm/fyhRVLd/2vn0D4BzzZDu+SHMurIM1dABBwzsZJs9d0IPmvFkTuNJIAimGyfzMB568=@vger.kernel.org X-Gm-Message-State: AOJu0YzJSMnNV1jR0zkyZJLlsV2OxIO4l8yGepqO5++OWijgMKJunjp6 01YMrV0eelFqYg0LpWDTSlrsKOdFjBfINcg7wIzild4Xe4BVdPqLT2+7 X-Gm-Gg: ASbGncuOtDmD5Un602JhuuJLLwdzmV5Kjz5FWBVkOZCh9rO7vlb6mHpzbBTLjUJpr4k ScTnR7kbfM6P9VPAavlwemclBPsxqBUCfv19TFVHhtDSqJyIOyu4NMul7Yzu7zJB36c12/lgGMh Gb6KBsuDPG9G43h34FBkzT0L5tUKqgdxnVMjZT6wVuGamchLlZhTEkCkwkdTYMnZVNimXMZKaOq EOAVyfazmoxWUacY3i1dq03MBgMiMw0nsbQzuCobRRm4+QKSRycWJYDMRaZVJYcs1rGAunoJCNU xnCWQUzAe4SKlgtxdZAlVjFCDtYbMll5EIktfqsltNASpHvct0Th/v1VIMV/2y8pAyRgHoKq2Im RC0PQT17ZK8CT933S9ppljdrvRjUEmwiRWx4hcJCz3qn3ulT4rNmT132ZO+w9w+USVZt7koo79X l/r/xB3FqC8hHrrfDVclw+6Rj0fHY= X-Google-Smtp-Source: AGHT+IFWXGjhBj6hkqmebRecDz2AWq0HxXcKoCZvpg7M+b+Y6TIyVk5TEkPd/s/kMEV1LLpgSWp5lw== X-Received: by 2002:a17:903:2f84:b0:295:57cc:cfb5 with SMTP id d9443c01a7336-29df880d030mr64767545ad.37.1765199965715; Mon, 08 Dec 2025 05:19:25 -0800 (PST) Received: from pengdl-pc.mioffice.cn ([43.224.245.249]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29daeaaba21sm126848595ad.70.2025.12.08.05.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Dec 2025 05:19:24 -0800 (PST) From: Donglin Peng To: rostedt@goodmis.org Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, pengdonglin , Masami Hiramatsu , Xiaoqin Zhang Subject: [PATCH v2 1/2] fgraph: Use BTF to trim and filter return values Date: Mon, 8 Dec 2025 21:19:16 +0800 Message-Id: <20251208131917.2444620-2-dolinux.peng@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251208131917.2444620-1-dolinux.peng@gmail.com> References: <20251208131917.2444620-1-dolinux.peng@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: pengdonglin The current funcgraph-retval implementation has two limitations: 1. It prints a return value even when the traced function returns void. 2. When the return type is narrower than a register, the printed value may be incorrect because high bits can contain undefined data. Both issues are addressed by using BTF to obtain the precise return type of each traced function: - Return values are now printed only for functions whose return type is not void. - The value is truncated to the actual width of the return type, ensuring correct representation. These changes make the funcgraph-retval output more accurate and remove noise from void functions. Cc: Steven Rostedt (Google) Cc: Masami Hiramatsu Cc: Xiaoqin Zhang Signed-off-by: pengdonglin --- kernel/trace/trace_functions_graph.c | 64 +++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 10 deletions(-) diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_func= tions_graph.c index 17c75cf2348e..9e63665c81e2 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c @@ -15,6 +15,7 @@ =20 #include "trace.h" #include "trace_output.h" +#include "trace_btf.h" =20 /* When set, irq functions might be ignored */ static int ftrace_graph_skip_irqs; @@ -865,6 +866,46 @@ static void print_graph_retaddr(struct trace_seq *s, s= truct fgraph_retaddr_ent_e =20 #if defined(CONFIG_FUNCTION_GRAPH_RETVAL) || defined(CONFIG_FUNCTION_GRAPH= _RETADDR) =20 +static void trim_retval(unsigned long func, unsigned long *retval, bool *p= rint_retval) +{ + const struct btf_type *t; + char name[KSYM_NAME_LEN]; + struct btf *btf; + u32 v, msb; + + if (!IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) + return; + + if (lookup_symbol_name(func, name)) + return; + + t =3D btf_find_func_proto(name, &btf); + if (IS_ERR_OR_NULL(t)) + return; + + t =3D btf_type_skip_modifiers(btf, t->type, NULL); + switch (t ? BTF_INFO_KIND(t->info) : BTF_KIND_UNKN) { + case BTF_KIND_UNKN: + *print_retval =3D false; + break; + case BTF_KIND_ENUM: + case BTF_KIND_ENUM64: + msb =3D BITS_PER_BYTE * t->size - 1; + *retval &=3D GENMASK(msb, 0); + break; + case BTF_KIND_INT: + v =3D *(u32 *)(t + 1); + if (BTF_INT_ENCODING(v) =3D=3D BTF_INT_BOOL) + msb =3D 0; + else + msb =3D BTF_INT_BITS(v) - 1; + *retval &=3D GENMASK(msb, 0); + break; + default: + break; + } +} + static void print_graph_retval(struct trace_seq *s, struct ftrace_graph_en= t_entry *entry, struct ftrace_graph_ret *graph_ret, void *func, u32 opt_flags, u32 trace_flags, int args_size) @@ -884,17 +925,20 @@ static void print_graph_retval(struct trace_seq *s, s= truct ftrace_graph_ent_entr print_retaddr =3D !!(opt_flags & TRACE_GRAPH_PRINT_RETADDR); #endif =20 - if (print_retval && retval && !hex_format) { - /* Check if the return value matches the negative format */ - if (IS_ENABLED(CONFIG_64BIT) && (retval & BIT(31)) && - (((u64)retval) >> 32) =3D=3D 0) { - err_code =3D sign_extend64(retval, 31); - } else { - err_code =3D retval; + if (print_retval) { + trim_retval((unsigned long)func, &retval, &print_retval); + if (print_retval && retval && !hex_format) { + /* Check if the return value matches the negative format */ + if (IS_ENABLED(CONFIG_64BIT) && (retval & BIT(31)) && + (((u64)retval) >> 32) =3D=3D 0) { + err_code =3D sign_extend64(retval, 31); + } else { + err_code =3D retval; + } + + if (!IS_ERR_VALUE(err_code)) + err_code =3D 0; } - - if (!IS_ERR_VALUE(err_code)) - err_code =3D 0; } =20 if (entry) { --=20 2.34.1 From nobody Fri Dec 19 09:52:48 2025 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51B933148B6 for ; Mon, 8 Dec 2025 13:19:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765199971; cv=none; b=TwHxkLRjDlVVcu2dhZjI00tN/VmZUygit65DcOVmc+yJx4vhuNxDhXkSyfSIZEsR9liRKTXBbGmx2OE6a9aVu0tuGZQ5tsQTcDkI/Qsu2pvMNte3WGbVODdBmyPHPmNQoG5uhtCx6T+700phDgIhh5E8uOCFff8wEwsG282hyPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765199971; c=relaxed/simple; bh=3bCdGD5FkpIAdYyYC22nZLqB1yqO0XZeOaSMwBTAUTA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jSGt5i3P8Ii07rQEKzCsDAuFusTmqbbWyHHuwgXQ18bpEAsycRRRkM0MghX49ZzA14oF08b4PJYQIjHntWXRDga4M4CFULY4reuwIErZpeUCzq4OdZFDp2QVSDnGOPmmMKLAjblJ3Z6QvwFUuWfSHforH57/yerqyApGFsUmLlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ed4Vt3J6; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ed4Vt3J6" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-29853ec5b8cso56904685ad.3 for ; Mon, 08 Dec 2025 05:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765199968; x=1765804768; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SkmupKimgD1Rk9p/ZFjo6RNMN1QYMXsx5o4Me/NgHuo=; b=ed4Vt3J6gMmWIpkukeIMfwadsJMMf7/dwo02V2JCc2PYRdqDTibqxYprd1cKPFayOx 9Ud1EM30xR9irRugDd6t6EPvz2el5sLlek22kd8xfmFS/VbN4NGzUbdvVrR0rMKgYRQp btc9jCOrIzrDQhlclBa4in4qi98yyqOd9N5+1CfUdge7eYhKrNC0aQR45hmSDNJWY0n9 4pNyD5ZbLlEn3M3euoQezlAM3sM3cm6jjp4P9yjdofszfDhGpr45prlXCDBc7u1azY7h elK/aBEnG8YcqSGaiUrFmzIJ9HnVFGdzk26VRlwiSUa29NdobMF/2b6yof84vtHXOqHF R6VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765199968; x=1765804768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SkmupKimgD1Rk9p/ZFjo6RNMN1QYMXsx5o4Me/NgHuo=; b=ogAZLmD8rhX3klJyGeiVir7sb/hTbGype3o1mkiVa7JegIp86NCnbLr5Zez0me5MyF LIxsL6tm2rtCVf2Jx3zPs0cNrOOYEUDPvtt9EbI3WrF1ieg8utKiN7Oegjgmwa8iFF+k bT+TZqX78vz4VNRtXTrz8+wa+cAl7mTTaTMAOlnk/pG+6ouyy1CaRv5ypXkIKAfmjG4P JmIW9ypliq45ECbSjUYhQXfH/NNWd0oMZmFU99QhsNtWS7J60AvQOpCCp89neqHsyL3z ZYzcxIhc67i0uowe3KO/McMOJZzT330O3SX6AW0Jm/6pXQCKZCw3HsLtjR/awEYtbTdB K3YA== X-Forwarded-Encrypted: i=1; AJvYcCXwVbOxpAZDYTJNVKdjxJfwgX6R67/VEDzpviMs66knYydKj+T+21J0m/+6gkG9pXIJ8CrddmzAZtMbLS4=@vger.kernel.org X-Gm-Message-State: AOJu0YxyDRp8WBl0aaAvFl8lwgTq1m0CHIwD9/b8QQel97VcgLHuw4jj LsRJjqPEFGCAIk8MJbXlRao/N7NdkOhdczONu+FHb6AS/T4/U0fpI1nr X-Gm-Gg: ASbGncsHdXz7ILrQEc304N++QwXAYfsjhrMVM6FeSM4hdkAlg4vzPtCdg5eTGvT34Yf N086swpvHZumCsSof+mBTA5UsaKK59fb9hM4RW2s6H/+00TxGZDhm7HWR43ZayGMJ0xg0SMOpcI zn8cHePZrUU6gHAhhMjdM54GrRKHkh3Wiqpv/X4fjJf+KOWfbmBOUsI1TPe49eKtNbcL83m7pZ9 rcI89LZ8cjHp3ytIN+wy4Ibuwp4iUyOwNSKUQ+cSfCIUZZt1d7dq8Oer09RjgJ/v30lIs2MaSl4 RxlBqLkmQekAnftzdZ5zyeVWA0VrEFbKxYYbcib5THVbkKWWCYuNB+QCoUfQ2Cww3Q6tNWCcA1m Jcc0s1WPpLo+rXXvhhCxFIdLtdkMfvyODCwUJlfeo29XOQTZeqCJBEDs4ojN7rsMzJ5HL1qVQhp 7d7/9DTN/Y6Y3evgMHpVN60L1B3mo14Xq18p0/pA== X-Google-Smtp-Source: AGHT+IGvWbkfyWsvDaD8zDVwbf1HrBIDdnuUuIME9a6jI1GzdIehLaH75wd1F0bqZJ8oibOKcUA1vQ== X-Received: by 2002:a17:902:d509:b0:295:2276:6704 with SMTP id d9443c01a7336-29df5deb71amr53107855ad.51.1765199968563; Mon, 08 Dec 2025 05:19:28 -0800 (PST) Received: from pengdl-pc.mioffice.cn ([43.224.245.249]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29daeaaba21sm126848595ad.70.2025.12.08.05.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Dec 2025 05:19:27 -0800 (PST) From: Donglin Peng To: rostedt@goodmis.org Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, pengdonglin , Masami Hiramatsu , Xiaoqin Zhang Subject: [PATCH v2 2/2] tracing: Update funcgraph-retval documentation Date: Mon, 8 Dec 2025 21:19:17 +0800 Message-Id: <20251208131917.2444620-3-dolinux.peng@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251208131917.2444620-1-dolinux.peng@gmail.com> References: <20251208131917.2444620-1-dolinux.peng@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: pengdonglin The existing documentation for funcgraph-retval is outdated and partially incorrect, as it describes limitations that have now been resolved. Recent changes (e.g., using BTF to obtain function return types) have addressed key issues: 1. Return values are now printed only for non-void functions. 2. Values are trimmed to the correct width of the return type, avoiding garbage data from high bits. Cc: Steven Rostedt (Google) Cc: Masami Hiramatsu Cc: Xiaoqin Zhang Signed-off-by: pengdonglin --- Documentation/trace/ftrace.rst | 76 +++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/Documentation/trace/ftrace.rst b/Documentation/trace/ftrace.rst index d1f313a5f4ad..d2edd58f04c3 100644 --- a/Documentation/trace/ftrace.rst +++ b/Documentation/trace/ftrace.rst @@ -1454,6 +1454,10 @@ Options for function_graph tracer: printed in hexadecimal format. By default, this option is off. =20 + funcgraph-retaddr + When set, the return address will always be printed. + By default, this option is off. + sleep-time When running function graph tracer, to include the time a task schedules out in its function. @@ -2800,7 +2804,7 @@ It is default disabled. 0) 2.861 us | } /* putname() */ =20 The return value of each traced function can be displayed after -an equal sign "=3D". When encountering system call failures, it +an equal sign "ret =3D". When encountering system call failures, it can be very helpful to quickly locate the function that first returns an error code. =20 @@ -2810,16 +2814,16 @@ returns an error code. Example with funcgraph-retval:: =20 1) | cgroup_migrate() { - 1) 0.651 us | cgroup_migrate_add_task(); /* =3D 0xffff93fcfd= 346c00 */ + 1) 0.651 us | cgroup_migrate_add_task(); /* ret=3D0xffff93fc= fd346c00 */ 1) | cgroup_migrate_execute() { 1) | cpu_cgroup_can_attach() { 1) | cgroup_taskset_first() { - 1) 0.732 us | cgroup_taskset_next(); /* =3D 0xffff93fc= 8fb20000 */ - 1) 1.232 us | } /* cgroup_taskset_first =3D 0xffff93fc8f= b20000 */ - 1) 0.380 us | sched_rt_can_attach(); /* =3D 0x0 */ - 1) 2.335 us | } /* cpu_cgroup_can_attach =3D -22 */ - 1) 4.369 us | } /* cgroup_migrate_execute =3D -22 */ - 1) 7.143 us | } /* cgroup_migrate =3D -22 */ + 1) 0.732 us | cgroup_taskset_next(); /* ret=3D0xffff93= fc8fb20000 */ + 1) 1.232 us | } /* cgroup_taskset_first ret=3D0xffff93fc= 8fb20000 */ + 1) 0.380 us | sched_rt_can_attach(); /* ret=3D0x0 */ + 1) 2.335 us | } /* cpu_cgroup_can_attach ret=3D-22 */ + 1) 4.369 us | } /* cgroup_migrate_execute ret=3D-22 */ + 1) 7.143 us | } /* cgroup_migrate ret=3D-22 */ =20 The above example shows that the function cpu_cgroup_can_attach returned the error code -22 firstly, then we can read the code @@ -2836,37 +2840,39 @@ printed in hexadecimal format. Example with funcgraph-retval-hex:: =20 1) | cgroup_migrate() { - 1) 0.651 us | cgroup_migrate_add_task(); /* =3D 0xffff93fc= fd346c00 */ + 1) 0.651 us | cgroup_migrate_add_task(); /* ret=3D0xffff93= fcfd346c00 */ 1) | cgroup_migrate_execute() { 1) | cpu_cgroup_can_attach() { 1) | cgroup_taskset_first() { - 1) 0.732 us | cgroup_taskset_next(); /* =3D 0xffff93= fc8fb20000 */ - 1) 1.232 us | } /* cgroup_taskset_first =3D 0xffff93fc= 8fb20000 */ - 1) 0.380 us | sched_rt_can_attach(); /* =3D 0x0 */ - 1) 2.335 us | } /* cpu_cgroup_can_attach =3D 0xffffffea = */ - 1) 4.369 us | } /* cgroup_migrate_execute =3D 0xffffffea */ + 1) 0.732 us | cgroup_taskset_next(); /* ret=3D0xffff= 93fc8fb20000 */ + 1) 1.232 us | } /* cgroup_taskset_first ret=3D0xffff93= fc8fb20000 */ + 1) 0.380 us | sched_rt_can_attach(); /* ret=3D0x0 */ + 1) 2.335 us | } /* cpu_cgroup_can_attach ret=3D0xffffffe= a */ + 1) 4.369 us | } /* cgroup_migrate_execute ret=3D0xffffffea= */ 1) 7.143 us | } /* cgroup_migrate =3D 0xffffffea */ =20 -At present, there are some limitations when using the funcgraph-retval -option, and these limitations will be eliminated in the future: +Note that there are some limitations when using the funcgraph-retval +option: + +- If CONFIG_DEBUG_INFO_BTF is disabled (n), a return value is printed even= for + functions with a void return type. When CONFIG_DEBUG_INFO_BTF is enabled= (y), + the return value is printed only for non-void functions. =20 -- Even if the function return type is void, a return value will still - be printed, and you can just ignore it. +- If a return value occupies multiple registers, only the value in the fir= st + register is recorded and printed. For example, on the x86 architecture, a + 64-bit return value is stored across eax (lower 32 bits) and edx (upper = 32 bits), + but only the contents of eax are captured. =20 -- Even if return values are stored in multiple registers, only the - value contained in the first register will be recorded and printed. - To illustrate, in the x86 architecture, eax and edx are used to store - a 64-bit return value, with the lower 32 bits saved in eax and the - upper 32 bits saved in edx. However, only the value stored in eax - will be recorded and printed. +- Under certain procedure-call standards (e.g., arm64's AAPCS64), when the= return + type is smaller than a general-purpose register (GPR), the caller is res= ponsible + for narrowing the value; the upper bits of the register may contain unde= fined data. + For instance, when a u8 is returned in 64-bit GPR, bits [63:8] can hold = arbitrary + values, especially when larger types are truncated (explicitly or implic= itly). It + is therefore advisable to inspect the code in such cases. If CONFIG_DEBU= G_INFO_BTF + is enabled (y), the return value is automatically trimmed to the width o= f the return + type. =20 -- In certain procedure call standards, such as arm64's AAPCS64, when a - type is smaller than a GPR, it is the responsibility of the consumer - to perform the narrowing, and the upper bits may contain UNKNOWN values. - Therefore, it is advisable to check the code for such cases. For instanc= e, - when using a u8 in a 64-bit GPR, bits [63:8] may contain arbitrary value= s, - especially when larger types are truncated, whether explicitly or implic= itly. - Here are some specific cases to illustrate this point: + The following examples illustrate the behavior: =20 **Case One**: =20 @@ -2885,7 +2891,9 @@ option, and these limitations will be eliminated in t= he future: RET =20 If you pass 0x123456789abcdef to this function and want to narrow it, - it may be recorded as 0x123456789abcdef instead of 0xef. + it may be recorded as 0x123456789abcdef instead of 0xef. When + CONFIG_DEBUG_INFO_BTF is enabled, the value will be correctly truncated + to 0xef based on the size constraints of the u8 type. =20 **Case Two**: =20 @@ -2910,7 +2918,9 @@ option, and these limitations will be eliminated in t= he future: RET =20 When passing 0x2_0000_0000 to it, the return value may be recorded as - 0x2_0000_0000 instead of 0. + 0x2_0000_0000 instead of 0. When CONFIG_DEBUG_INFO_BTF is enabled, the + value will be correctly truncated to 0 based on the size constraints of + the int type. =20 You can put some comments on specific functions by using trace_printk() For example, if you want to put a comment inside --=20 2.34.1