From patchwork Wed Sep 4 06:58:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13789842 X-Patchwork-Delegate: mhiramat@kernel.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 EB1C6145FE8; Wed, 4 Sep 2024 07:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433260; cv=none; b=GX2lZWW9YPi/kGBQn/zEeMWblsFlD03XsgNv9xnHGiB+BNhh4JdtR0sc8eUwOCGmFrki43PD8E6+NzpNq2CgFMFoJYMWH5rmKD1UyM3yZZOkVb+Ky9hW1SkAV1kuyyoqLgcZiaGw1IQgrVQe29QiPsWJ/W12TBnal3ZPMAHGD7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433260; c=relaxed/simple; bh=XhRyrIUnx0vcUn1794mXXJ04+1nZfUPFAUbgPQOeGlc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=otyW1gyE2cLZPn2BuBYAA1nhZdNRbzS/3utEdPzXelqhaGhWiiyVXEOafWTlqQQMBV7BDzhi3uFFMnCX96e1I8XexX7iADcwgiV6Ic5nUFUaUIqwCFcvz4ad7p3MsYMWw4JqcwjH0SvJ7YjIxKc34F5pTjBNS/zdOouL+fS10FY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=lE0LMpjq; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="lE0LMpjq" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4846HBfX016570; Wed, 4 Sep 2024 06:59:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=folkEIJqstNzu 7lwREFA/To2vbOIgoI9Y7HXfVt2L+U=; b=lE0LMpjqff+1mmFkHrSz4fklZ5X+5 iBqjQRbetoP8n+C+7ngNmnp+awphLL0vlg84xB25xHnDJ2f66lwui/k2DAtlNNg/ P91ynPjf8WHxkt5Z7IRFm+5IAkLz7u+ADKaknng+M/flQ6Dr+T+2PLif7E3UNOv1 IfzQ+CrYh88BCVLi1OL88XCywOiH6Cs2Vnt2XZ+scTsDa7YYPYmQ1psJ7KcN0tmY o5EpEgn16MpCatVoZWMrwUl1CCpujfbpbX839/a05o5v3dleyO2mQ9yJZBh38WaL FXFHPty7ghqYDiPxbGrYtFxyhRW8hF451vjRrMOsjpOuKux3F5cSMfYHw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41btp9hn91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:24 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4846xNXk004735; Wed, 4 Sep 2024 06:59:23 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41btp9hn8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:23 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48430pfD000413; Wed, 4 Sep 2024 06:59:21 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 41cdgupq5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:21 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4846xHm534931168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Sep 2024 06:59:18 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC49C20043; Wed, 4 Sep 2024 06:59:17 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A500320040; Wed, 4 Sep 2024 06:59:17 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 4 Sep 2024 06:59:17 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 7AC54E0297; Wed, 4 Sep 2024 08:59:17 +0200 (CEST) From: Sven Schnelle To: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Russell King , Catalin Marinas , Will Deacon , Guo Ren , Huacai Chen , WANG Xuerui , Michal Simek , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Yoshinori Sato , Rich Felker , John Paul Adrian Glaubitz , "David S. Miller" , Andreas Larsson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org Subject: [PATCH 1/7] tracing: add ftrace_regs to function_graph_enter() Date: Wed, 4 Sep 2024 08:58:55 +0200 Message-ID: <20240904065908.1009086-2-svens@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240904065908.1009086-1-svens@linux.ibm.com> References: <20240904065908.1009086-1-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4SIE32AwU4OcPAwAEJmTo-vtL9wXompT X-Proofpoint-ORIG-GUID: 562DU-xMxw4EVrNelRokSilhcXaDg0Dm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_04,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 spamscore=0 malwarescore=0 mlxlogscore=861 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409040049 Will be used later for showing function arguments in the function graph tracer. Signed-off-by: Sven Schnelle --- arch/arm/kernel/ftrace.c | 2 +- arch/arm64/kernel/ftrace.c | 2 +- arch/csky/kernel/ftrace.c | 2 +- arch/loongarch/kernel/ftrace.c | 2 +- arch/loongarch/kernel/ftrace_dyn.c | 2 +- arch/microblaze/kernel/ftrace.c | 2 +- arch/mips/kernel/ftrace.c | 2 +- arch/parisc/kernel/ftrace.c | 2 +- arch/powerpc/kernel/trace/ftrace.c | 2 +- arch/riscv/kernel/ftrace.c | 2 +- arch/s390/kernel/ftrace.c | 2 +- arch/sh/kernel/ftrace.c | 2 +- arch/sparc/kernel/ftrace.c | 2 +- arch/x86/kernel/ftrace.c | 2 +- include/linux/ftrace.h | 3 ++- kernel/trace/fgraph.c | 3 ++- 16 files changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index e61591f33a6c..1f8802439e34 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -267,7 +267,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, old = *parent; *parent = return_hooker; - if (function_graph_enter(old, self_addr, frame_pointer, NULL)) + if (function_graph_enter(old, self_addr, frame_pointer, NULL, NULL)) *parent = old; } diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index a650f5e11fc5..686fbebb0432 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -472,7 +472,7 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent, old = *parent; if (!function_graph_enter(old, self_addr, frame_pointer, - (void *)frame_pointer)) { + (void *)frame_pointer, NULL)) { *parent = return_hooker; } } diff --git a/arch/csky/kernel/ftrace.c b/arch/csky/kernel/ftrace.c index 50bfcf129078..c12af268c1cb 100644 --- a/arch/csky/kernel/ftrace.c +++ b/arch/csky/kernel/ftrace.c @@ -156,7 +156,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, old = *parent; if (!function_graph_enter(old, self_addr, - *(unsigned long *)frame_pointer, parent)) { + *(unsigned long *)frame_pointer, parent, NULL)) { /* * For csky-gcc function has sub-call: * subi sp, sp, 8 diff --git a/arch/loongarch/kernel/ftrace.c b/arch/loongarch/kernel/ftrace.c index 8c3ec1bc7aad..43d908b01718 100644 --- a/arch/loongarch/kernel/ftrace.c +++ b/arch/loongarch/kernel/ftrace.c @@ -61,7 +61,7 @@ void prepare_ftrace_return(unsigned long self_addr, if (ftrace_get_parent_ra_addr(self_addr, &ra_off)) goto out; - if (!function_graph_enter(old, self_addr, 0, NULL)) + if (!function_graph_enter(old, self_addr, 0, NULL, NULL)) *(unsigned long *)(callsite_sp + ra_off) = return_hooker; return; diff --git a/arch/loongarch/kernel/ftrace_dyn.c b/arch/loongarch/kernel/ftrace_dyn.c index bff058317062..eab16231d09d 100644 --- a/arch/loongarch/kernel/ftrace_dyn.c +++ b/arch/loongarch/kernel/ftrace_dyn.c @@ -233,7 +233,7 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent) old = *parent; - if (!function_graph_enter(old, self_addr, 0, parent)) + if (!function_graph_enter(old, self_addr, 0, parent, NULL)) *parent = return_hooker; } diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c index 188749d62709..009800d7e54f 100644 --- a/arch/microblaze/kernel/ftrace.c +++ b/arch/microblaze/kernel/ftrace.c @@ -62,7 +62,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) return; } - if (function_graph_enter(old, self_addr, 0, NULL)) + if (function_graph_enter(old, self_addr, 0, NULL, NULL)) *parent = old; } #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ diff --git a/arch/mips/kernel/ftrace.c b/arch/mips/kernel/ftrace.c index 8c401e42301c..65f29de35a59 100644 --- a/arch/mips/kernel/ftrace.c +++ b/arch/mips/kernel/ftrace.c @@ -362,7 +362,7 @@ void prepare_ftrace_return(unsigned long *parent_ra_addr, unsigned long self_ra, insns = core_kernel_text(self_ra) ? 2 : MCOUNT_OFFSET_INSNS + 1; self_ra -= (MCOUNT_INSN_SIZE * insns); - if (function_graph_enter(old_parent_ra, self_ra, fp, NULL)) + if (function_graph_enter(old_parent_ra, self_ra, fp, NULL, NULL)) *parent_ra_addr = old_parent_ra; return; out: diff --git a/arch/parisc/kernel/ftrace.c b/arch/parisc/kernel/ftrace.c index c91f9c2e61ed..c8d926f057a6 100644 --- a/arch/parisc/kernel/ftrace.c +++ b/arch/parisc/kernel/ftrace.c @@ -45,7 +45,7 @@ static void __hot prepare_ftrace_return(unsigned long *parent, old = *parent; - if (!function_graph_enter(old, self_addr, 0, NULL)) + if (!function_graph_enter(old, self_addr, 0, NULL, NULL)) /* activate parisc_return_to_handler() as return point */ *parent = (unsigned long) &parisc_return_to_handler; } diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index d8d6b4fd9a14..8a24d6eabb64 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -434,7 +434,7 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, if (bit < 0) goto out; - if (!function_graph_enter(parent_ip, ip, 0, (unsigned long *)sp)) + if (!function_graph_enter(parent_ip, ip, 0, (unsigned long *)sp, NULL)) parent_ip = ppc_function_entry(return_to_handler); ftrace_test_recursion_unlock(bit); diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c index 4b95c574fd04..b45985265b29 100644 --- a/arch/riscv/kernel/ftrace.c +++ b/arch/riscv/kernel/ftrace.c @@ -205,7 +205,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, */ old = *parent; - if (!function_graph_enter(old, self_addr, frame_pointer, parent)) + if (!function_graph_enter(old, self_addr, frame_pointer, parent, NULL)) *parent = return_hooker; } diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c index 0b6e62d1d8b8..cf9ee90ae216 100644 --- a/arch/s390/kernel/ftrace.c +++ b/arch/s390/kernel/ftrace.c @@ -273,7 +273,7 @@ unsigned long prepare_ftrace_return(unsigned long ra, unsigned long sp, if (unlikely(atomic_read(¤t->tracing_graph_pause))) goto out; ip -= MCOUNT_INSN_SIZE; - if (!function_graph_enter(ra, ip, 0, (void *) sp)) + if (!function_graph_enter(ra, ip, 0, (void *) sp, NULL)) ra = (unsigned long) return_to_handler; out: return ra; diff --git a/arch/sh/kernel/ftrace.c b/arch/sh/kernel/ftrace.c index 930001bb8c6a..a9a0a1238214 100644 --- a/arch/sh/kernel/ftrace.c +++ b/arch/sh/kernel/ftrace.c @@ -359,7 +359,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) return; } - if (function_graph_enter(old, self_addr, 0, NULL)) + if (function_graph_enter(old, self_addr, 0, NULL, NULL)) __raw_writel(old, parent); } #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c index eaead3da8e03..9ad77a2d9bc4 100644 --- a/arch/sparc/kernel/ftrace.c +++ b/arch/sparc/kernel/ftrace.c @@ -125,7 +125,7 @@ unsigned long prepare_ftrace_return(unsigned long parent, if (unlikely(atomic_read(¤t->tracing_graph_pause))) return parent + 8UL; - if (function_graph_enter(parent, self_addr, frame_pointer, NULL)) + if (function_graph_enter(parent, self_addr, frame_pointer, NULL, NULL)) return parent + 8UL; return return_hooker; diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 8da0e66ca22d..b325f7e7e39a 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -637,7 +637,7 @@ void prepare_ftrace_return(unsigned long ip, unsigned long *parent, if (bit < 0) return; - if (!function_graph_enter(*parent, ip, frame_pointer, parent)) + if (!function_graph_enter(*parent, ip, frame_pointer, parent, NULL)) *parent = return_hooker; ftrace_test_recursion_unlock(bit); diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index fd5e84d0ec47..56d91041ecd2 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -1083,7 +1083,8 @@ extern void return_to_handler(void); extern int function_graph_enter(unsigned long ret, unsigned long func, - unsigned long frame_pointer, unsigned long *retp); + unsigned long frame_pointer, unsigned long *retp, + struct ftrace_regs *fregs); struct ftrace_ret_stack * ftrace_graph_get_ret_stack(struct task_struct *task, int skip); diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index d1d5ea2d0a1b..fa62ebfa0711 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -613,7 +613,8 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, /* If the caller does not use ftrace, call this function. */ int function_graph_enter(unsigned long ret, unsigned long func, - unsigned long frame_pointer, unsigned long *retp) + unsigned long frame_pointer, unsigned long *retp, + struct ftrace_regs *fregs) { struct ftrace_graph_ent trace; unsigned long bitmap = 0; From patchwork Wed Sep 4 06:58:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13789837 X-Patchwork-Delegate: mhiramat@kernel.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 1CFD647F4D; Wed, 4 Sep 2024 06:59:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433187; cv=none; b=G7EGG/NdGsvsmz8S8F/s+E+Pp9HsSlokqBmGpp3oqTH8O3fh+NHt0fXGZa0ZqDS6gkUnrcaUV4aoIwTRySe5Qbz1QQvHxUZ1+/YPztDQmZGGWStqPoCVnEffdMqNboRpNRWlbDvqdZpshcuvkRHH3nYLlGrRrC1V8truO1SsV1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433187; c=relaxed/simple; bh=e58CG+AcikgqXnrXSqI6oEBC59bbF39mHDrZelCdUO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FDOjNlykVAmAU8Wksu0LFFUva1zYRG048l1MYRYLUV3he5aKCfUkLcygWN3D/OTHdPqq1ndZjBMoqRDbKEQQPmaeA9Ux9PBCBQr0KCzwDDKM5ZE6yAZJv1Mb/T2uGA36ZhsWk+6FOON6nPriTMmY9ZxSJzpGTXbo8o9MCpsR7HU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=oG06pXe2; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="oG06pXe2" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4846mw6F007038; Wed, 4 Sep 2024 06:59:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=LsyxFV6hi1/6W RqskN/bUYJbWT5DOE92Idx8C1CSDTQ=; b=oG06pXe21fijaB47NWaeMeC4Q5oUv 1PsVHWFv96Ryqmyt4EcU82bMNMNPrXMm7Hhn9WvNhnXkRvqfDDSPt3NdLydFT5pq z4GXoqsU51gPkAr8IWL+4DcyFPMD0pMgdjSectwEENmFKMnqctkNiHHvd1iOPgyC 2ColRu3I3VRe9HLlbN/riGA3MQanwc8qt7onlL7GbwE6zG3AT+clbNrcfvrOOxpP fJxn52cb6jyQtaf9/jIu27wUGS8i29afE8iYEoK+D8BB5aNByMfg/OsX0LPWsuw5 zAdixWfUHPeqHYsRvMmUjcrqEIizjArwgITZRcGBs+vV01b/KfrFLxibg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41bskm1w7t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:21 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 4846xLwZ028361; Wed, 4 Sep 2024 06:59:21 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41bskm1w7n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:21 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4844MPmr018672; Wed, 4 Sep 2024 06:59:20 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41cdw16kpg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:20 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4846xIFk33424054 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Sep 2024 06:59:18 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4185C2004D; Wed, 4 Sep 2024 06:59:18 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30BF82004B; Wed, 4 Sep 2024 06:59:18 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 4 Sep 2024 06:59:18 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 06506E0297; Wed, 4 Sep 2024 08:59:18 +0200 (CEST) From: Sven Schnelle To: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 2/7] x86/tracing: pass ftrace_regs to function_graph_enter() Date: Wed, 4 Sep 2024 08:58:56 +0200 Message-ID: <20240904065908.1009086-3-svens@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240904065908.1009086-1-svens@linux.ibm.com> References: <20240904065908.1009086-1-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: rnkbJHoNSdnGsWppD9zB_2A00H9vu87N X-Proofpoint-ORIG-GUID: th6i1OWPQT5Q1UVV0zsfPK0dS1Tl3KR_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_04,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 mlxlogscore=773 clxscore=1011 phishscore=0 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409040049 Will be used later for printing function argument in the function graph tracer. Signed-off-by: Sven Schnelle --- arch/x86/include/asm/ftrace.h | 2 +- arch/x86/kernel/ftrace.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h index 0152a81d9b4a..9843d0c08e61 100644 --- a/arch/x86/include/asm/ftrace.h +++ b/arch/x86/include/asm/ftrace.h @@ -105,7 +105,7 @@ struct dyn_arch_ftrace { #ifndef __ASSEMBLY__ void prepare_ftrace_return(unsigned long ip, unsigned long *parent, - unsigned long frame_pointer); + unsigned long frame_pointer, struct ftrace_regs *regs); #if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE) extern void set_ftrace_ops_ro(void); diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index b325f7e7e39a..a016b82de5e2 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -610,7 +610,7 @@ int ftrace_disable_ftrace_graph_caller(void) * in current thread info. */ void prepare_ftrace_return(unsigned long ip, unsigned long *parent, - unsigned long frame_pointer) + unsigned long frame_pointer, struct ftrace_regs *fregs) { unsigned long return_hooker = (unsigned long)&return_to_handler; int bit; @@ -637,7 +637,7 @@ void prepare_ftrace_return(unsigned long ip, unsigned long *parent, if (bit < 0) return; - if (!function_graph_enter(*parent, ip, frame_pointer, parent, NULL)) + if (!function_graph_enter(*parent, ip, frame_pointer, parent, fregs)) *parent = return_hooker; ftrace_test_recursion_unlock(bit); @@ -650,7 +650,7 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, struct pt_regs *regs = &fregs->regs; unsigned long *stack = (unsigned long *)kernel_stack_pointer(regs); - prepare_ftrace_return(ip, (unsigned long *)stack, 0); + prepare_ftrace_return(ip, (unsigned long *)stack, 0, fregs); } #endif From patchwork Wed Sep 4 06:58:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13789836 X-Patchwork-Delegate: mhiramat@kernel.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 01DF51474A7; Wed, 4 Sep 2024 06:59:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433177; cv=none; b=I79WECMxT634rDRuFblTW/ODwN5+0HyPb2II3V/LVLVj1n+v5FxOPBPoC/A0346g77/IdMI3EdvALod3cOV8sdlf6A5jO5Iqyxi7lO3kk0Pq7nP8yV83CsLaKFvyTJOVn2DFNUlXfckOPntpLAf43X4yCFsDtZgez+LyCwnDsTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433177; c=relaxed/simple; bh=ctHiHkwE6tuAM+pU9h4uYZ8WWO1ajWuOutSejTQKAfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X9pToQlDOSkGxt7RKdTLJzfMuujsjIsZWhUTz12yAbet7UTZ6bGKCum9e/XHPpa/1fLoZbnB/tqqevhF7V5Wi3B+ltHbXfZLBdNEf+wcqusuvw26HI25AUAotvu0G1eRrgZZu21y8xK+lgmOU5qQ1GbX/6QD5zIneg2GZPzgdF8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=GF3otf1N; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="GF3otf1N" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4843qjJ5023414; Wed, 4 Sep 2024 06:59:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=0S2sSyTqalzFM k1QFvsJIk3XU0AKQNPbYyEFYeBwcas=; b=GF3otf1N2dE7lFoVSqzt7Qzhqmfaj 0ttbc5r5mdGqg5b2IstGXvSoP2n1eM8WrTh2M0RCi1HdgHPcjYnUDa+WstAoSybp gdgYwMkl8eFxujlUomHtvuzM8xLhfqsffvtPXOdeyj+YExc8fQT99w9gnpVD4sBi y2hYkoA9/XJkl11naeAg/p4fhN8FkrFS274GP/v9SfoqHJYXA5tQMQgA2/JIgaAQ iWkT7hQdXWlQJQ4D3bQ4qrjulGadO10QVjbjdyOxFkNbDIsibjZ5mT2cYSOmJjL5 PCOY2qmxzCvbrLuwVnbebBPXqfKP/R4VrhQHJ2Y72Ml9s2cbU4faxadWw== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41btp9hn8u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:23 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4845US8E000926; Wed, 4 Sep 2024 06:59:22 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41cf0mxcm4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:22 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4846xITl11469248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Sep 2024 06:59:19 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBD3020043; Wed, 4 Sep 2024 06:59:18 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C8DFF20040; Wed, 4 Sep 2024 06:59:18 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 4 Sep 2024 06:59:18 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 88E4DE0297; Wed, 4 Sep 2024 08:59:18 +0200 (CEST) From: Sven Schnelle To: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 3/7] s390/tracing: pass ftrace_regs to function_graph_enter() Date: Wed, 4 Sep 2024 08:58:57 +0200 Message-ID: <20240904065908.1009086-4-svens@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240904065908.1009086-1-svens@linux.ibm.com> References: <20240904065908.1009086-1-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 7aIX8uAl-RY4UpNawcSPGqSm3YmATvQS X-Proofpoint-ORIG-GUID: 7aIX8uAl-RY4UpNawcSPGqSm3YmATvQS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_04,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 phishscore=0 impostorscore=0 spamscore=0 malwarescore=0 mlxlogscore=662 adultscore=0 mlxscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409040049 Will be used later to print function arguments in the function graph tracer. Signed-off-by: Sven Schnelle --- arch/s390/kernel/entry.h | 4 +++- arch/s390/kernel/ftrace.c | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/s390/kernel/entry.h b/arch/s390/kernel/entry.h index 21969520f947..d0a5fbaad987 100644 --- a/arch/s390/kernel/entry.h +++ b/arch/s390/kernel/entry.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,8 @@ void do_restart(void *arg); void __init startup_init(void); void die(struct pt_regs *regs, const char *str); int setup_profiling_timer(unsigned int multiplier); -unsigned long prepare_ftrace_return(unsigned long parent, unsigned long sp, unsigned long ip); +unsigned long prepare_ftrace_return(unsigned long parent, unsigned long sp, unsigned long ip, + struct ftrace_regs *regs); struct s390_mmap_arg_struct; struct fadvise64_64_args; diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c index cf9ee90ae216..dd77b656d9b9 100644 --- a/arch/s390/kernel/ftrace.c +++ b/arch/s390/kernel/ftrace.c @@ -266,14 +266,14 @@ void ftrace_arch_code_modify_post_process(void) * in current thread info. */ unsigned long prepare_ftrace_return(unsigned long ra, unsigned long sp, - unsigned long ip) + unsigned long ip, struct ftrace_regs *regs) { if (unlikely(ftrace_graph_is_dead())) goto out; if (unlikely(atomic_read(¤t->tracing_graph_pause))) goto out; ip -= MCOUNT_INSN_SIZE; - if (!function_graph_enter(ra, ip, 0, (void *) sp, NULL)) + if (!function_graph_enter(ra, ip, 0, (void *) sp, regs)) ra = (unsigned long) return_to_handler; out: return ra; From patchwork Wed Sep 4 06:58:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13789831 X-Patchwork-Delegate: mhiramat@kernel.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 DA0CC1DDE9; Wed, 4 Sep 2024 06:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433172; cv=none; b=eI2C6kR2RsOm30GVb/J70T8k3DbCOmOKtIA3g6jbwj85knUIi/Y0IPo4xk7k9HpB+CkNiI1iJhqkvDvZ9iqb/N7mp/DsCWl/j6vd2g6Gw1+aBuKvPMLopQR1cf/czJF/DE2K8UQKRp8RQEeG0L2WKUdedRmstFzV8X7mvoi+h2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433172; c=relaxed/simple; bh=aQyhcc3F3PANNj74AR0gp1Z4T/rwnutME68N8t9B1WY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cDQNPvdte++Fgc7PsThb2Okfx5DTkXXU/18vb8WYc8JzLFV56bvI2f6MnigsFWuFkoawbyEDOCFMWAFgCM2504Tc8f7Cw5l2rWYpknrt6piwmmqcR28sQ+Ychk4TPLXBPP4FxMCQO0+DoZg/UYEHbIod7E8Th5ogFJ1+xeY8XQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=anx+jUJn; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="anx+jUJn" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4843l4Ga026977; Wed, 4 Sep 2024 06:59:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=bpnTrhuT9tk24 mc0lWEQWOy52/vroDUge2MFDgcCyR4=; b=anx+jUJn6idlgKmc8fF4BR02/M52W Pwr0wZpcMu8cQMN/FbWw9BYzTjBpUh9atZo5yA0PZ/+4p01HUlParICB3t9P9tZ5 zMzttQ/mI1EL4Wnk5lxAn4DHGq3gvt+l82M64m38ukYlJSn7zpRIhKuf/xyj3oFy Y2KAboJICyb+5Sh2qe/H91Z658KQdww/6JBMK3YTwMfG51xRVjlgt9LsonbN2gwt v4YUSvUzr3HBTbSdI7LN2pUH3LPWKZTd1Cozbb8KQddzPaNtuXlQejxPyF/W03Gt 0/wb/SjQpHVmpHv1DEc3Bd99pldiOBcva6zovSJ0EfkFv6cklIFVk5nbQ== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41brkqt1tx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:22 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48455ePr011979; Wed, 4 Sep 2024 06:59:21 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41cegpxf9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:21 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4846xJVk53346580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Sep 2024 06:59:19 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7160E20043; Wed, 4 Sep 2024 06:59:19 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F76D20040; Wed, 4 Sep 2024 06:59:19 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 4 Sep 2024 06:59:19 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 203CEE0297; Wed, 4 Sep 2024 08:59:19 +0200 (CEST) From: Sven Schnelle To: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 4/7] Add print_function_args() Date: Wed, 4 Sep 2024 08:58:58 +0200 Message-ID: <20240904065908.1009086-5-svens@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240904065908.1009086-1-svens@linux.ibm.com> References: <20240904065908.1009086-1-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: g7qxufGOAcbGUCKmLgjBagyF508u6CrB X-Proofpoint-ORIG-GUID: g7qxufGOAcbGUCKmLgjBagyF508u6CrB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_04,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1011 mlxscore=0 impostorscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409040049 Add a function to decode argument types with the help of BTF. Will be used to display arguments in the function and function graph tracer. Signed-off-by: Sven Schnelle --- kernel/trace/trace_output.c | 68 +++++++++++++++++++++++++++++++++++++ kernel/trace/trace_output.h | 9 +++++ 2 files changed, 77 insertions(+) diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index d8b302d01083..70405c4cceb6 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -12,8 +12,11 @@ #include #include #include +#include +#include #include "trace_output.h" +#include "trace_btf.h" /* must be a power of 2 */ #define EVENT_HASHSIZE 128 @@ -669,6 +672,71 @@ int trace_print_lat_context(struct trace_iterator *iter) return !trace_seq_has_overflowed(s); } +#ifdef CONFIG_FUNCTION_TRACE_ARGS +void print_function_args(struct trace_seq *s, struct ftrace_regs *fregs, + unsigned long func) +{ + const struct btf_param *param; + const struct btf_type *t; + const char *param_name; + char name[KSYM_NAME_LEN]; + unsigned long arg; + struct btf *btf; + s32 tid, nr = 0; + int i; + + trace_seq_printf(s, "("); + + if (!ftrace_regs_has_args(fregs)) + goto out; + if (lookup_symbol_name(func, name)) + goto out; + + btf = bpf_get_btf_vmlinux(); + if (IS_ERR_OR_NULL(btf)) + goto out; + + t = btf_find_func_proto(name, &btf); + if (IS_ERR_OR_NULL(t)) + goto out; + + param = btf_get_func_param(t, &nr); + if (!param) + goto out_put; + + for (i = 0; i < nr; i++) { + arg = ftrace_regs_get_argument(fregs, i); + + param_name = btf_name_by_offset(btf, param[i].name_off); + if (param_name) + trace_seq_printf(s, "%s = ", param_name); + t = btf_type_skip_modifiers(btf, param[i].type, &tid); + if (!t) + continue; + switch (BTF_INFO_KIND(t->info)) { + case BTF_KIND_PTR: + trace_seq_printf(s, "0x%lx", arg); + break; + case BTF_KIND_INT: + trace_seq_printf(s, "%ld", arg); + break; + case BTF_KIND_ENUM: + trace_seq_printf(s, "%ld", arg); + break; + default: + trace_seq_printf(s, "0x%lx (%d)", arg, BTF_INFO_KIND(param[i].type)); + break; + } + if (i < nr - 1) + trace_seq_printf(s, ", "); + } +out_put: + btf_put(btf); +out: + trace_seq_printf(s, ")"); +} +#endif + /** * ftrace_find_event - find a registered event * @type: the type of event to look for diff --git a/kernel/trace/trace_output.h b/kernel/trace/trace_output.h index dca40f1f1da4..a21d8ce606f7 100644 --- a/kernel/trace/trace_output.h +++ b/kernel/trace/trace_output.h @@ -41,5 +41,14 @@ extern struct rw_semaphore trace_event_sem; #define SEQ_PUT_HEX_FIELD(s, x) \ trace_seq_putmem_hex(s, &(x), sizeof(x)) +#ifdef CONFIG_FUNCTION_TRACE_ARGS +void print_function_args(struct trace_seq *s, struct ftrace_regs *fregs, + unsigned long func); +#else +static inline void print_function_args(struct trace_seq *s, struct ftrace_regs *fregs, + unsigned long func) { + trace_seq_puts(s, "()"); +} +#endif #endif From patchwork Wed Sep 4 06:58:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13789835 X-Patchwork-Delegate: mhiramat@kernel.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 F1D6E14658B; Wed, 4 Sep 2024 06:59:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433175; cv=none; b=SfXS4hD1yvT9FFPvnn9arLB5edC/f9gktbYG06Q8lfsN98bnj0osbrfXtqaPl+vi449Kc3mFQNkHXsbvk4xE8JtuCMtLBVzZG9qPGpCrA15uCOwQlyNJPJ1wNLLgpQICK8ZXKdx3kDQ1j/+DgL46gQpRiAehkKkkuaXdFPIp8gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433175; c=relaxed/simple; bh=AsMuNK/VNzs25P4UhqW/dLed5ignnKTo05pw9tsVZa4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LE4q0+50oPRunZX/7a6MTp6lNDIoP2gDL/cemQ7srnapcpcdhNFAYiICeKX9w2cgCQTAqJV33pmIJC5yXtang3O2IkNbVG8WB3JaddPUCK/uU3TEuiB/dl77Gd3O7cRlD4d4rY8MXEmErhVRtKaNsB3UXsESTDyW66eXOKxQe34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=XRkl+CMF; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="XRkl+CMF" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4843iuH5018346; Wed, 4 Sep 2024 06:59:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=mVK2+Fis+uDCY 4mWrAvexyW+a1YkyaPfuIanqLiNr1Y=; b=XRkl+CMFn/T1A0R3i//RvgwmEGnXI n/R17HQ15BLsnSpf7FKRt2XIWUF2BNBMWx/T7g/PYEIEbab420oCk1T9Q7ovV8+X 0i11y90lV70GMjxCBrT5v48ZBXtcfitTcOZyrb9yDHK+ztXEI6w8Ixp0HrCr9/nT NDzjDRrm4qfIAY2aJmlOeD53wZx3JrCpEWFkXMkiVPUMq5iFciyw4sR1qPC5Ok2S 0MHlCxslgLIJiIhTubFD8OSuVm7tRbV1UmJgQh8CCgaPOZeDbFuJTUF2aWeicaZr DPDNHFYQvHG13xVY6/n3mk/kaX0nsFRVC37ycC68eKLCNwKifHM/e08Kw== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41brkqt1ty-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:22 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4846UagY009148; Wed, 4 Sep 2024 06:59:21 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 41cg73p5be-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:21 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4846xJLI54395384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Sep 2024 06:59:19 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE41220043; Wed, 4 Sep 2024 06:59:19 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B037320040; Wed, 4 Sep 2024 06:59:19 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 4 Sep 2024 06:59:19 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 796EDE0297; Wed, 4 Sep 2024 08:59:19 +0200 (CEST) From: Sven Schnelle To: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 5/7] tracing: add config option for print arguments in ftrace Date: Wed, 4 Sep 2024 08:58:59 +0200 Message-ID: <20240904065908.1009086-6-svens@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240904065908.1009086-1-svens@linux.ibm.com> References: <20240904065908.1009086-1-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 3JImOn-JiFtlDj5augIhilK-2ps0LxBs X-Proofpoint-ORIG-GUID: 3JImOn-JiFtlDj5augIhilK-2ps0LxBs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_04,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 mlxscore=0 impostorscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 adultscore=0 mlxlogscore=999 bulkscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409040049 Add a config option to disable/enable function argument printing support during runtime. Signed-off-by: Sven Schnelle --- kernel/trace/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 721c3b221048..8b9b6cdf39ac 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -242,6 +242,18 @@ config FUNCTION_GRAPH_RETVAL enable it via the trace option funcgraph-retval. See Documentation/trace/ftrace.rst +config FUNCTION_TRACE_ARGS + bool "Kernel Function Tracer Arguments" + depends on HAVE_FUNCTION_ARG_ACCESS_API + depends on DEBUG_INFO_BTF && BPF_SYSCALL + default n + help + Support recording and printing of function arguments when using + the function tracer or function graph tracer. This feature is off + by default, and can be enabled via the trace option func-args (for + the function tracer) and funcgraph-args (for the function graph + tracer). + config DYNAMIC_FTRACE bool "enable/disable function tracing dynamically" depends on FUNCTION_TRACER From patchwork Wed Sep 4 06:59:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13789832 X-Patchwork-Delegate: mhiramat@kernel.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 CF2BD13B2A4; Wed, 4 Sep 2024 06:59:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433174; cv=none; b=OeqsXK1X/RxywbBcEZzJbJVNiB1V98x0WVaWy9bHd8pAxW4u1xGC5m7ncaePhrTuqrQH3ckVT/fBP6WmHhjK8pm6Lc7JBiyH/sNHoar6+wu5H9UHFP4aaKsdl05hNZF7Amv1y+rMlfw1s3DF2i+nn3oGHUzQPbfwpqTifzJT2g8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433174; c=relaxed/simple; bh=hC58jLJTDlCLylqz/wSbPfuzxRAozU8IZy2jXQXM3mc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UhqDQvPp4x4BBdGXN9oC99THdziaFjMIBn8+NuT/75U2b4SmztEbAAMJylT28yEmgy7SPu9bV3kLGtHE/zBh2kJ88dyJNj9cU3BMosjwQp9rLNW9CzeVBTyYPp91KtABb8XAzpUbcTtbqNdGM6h74qqMikHGbfPCXjtXCFG76IE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=I1E/80Sb; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="I1E/80Sb" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483L8dLS006681; Wed, 4 Sep 2024 06:59:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=uMWX5RTeccU/C cqEWQfzKGoIsIuNyNyKITEFnOwaNc0=; b=I1E/80SbtDrptLdKRhoLCmXl9/pnM kjKedt5+FAud60GteKwOEKRxvlrjX+NYrFmb3Q/0loXkGjNiM6vKz+p8yN2PjLkk Q3rW7dgjQZJnlWlZedOcChckyvIc86DiVdP+vfbRYIVk5Ru46qnl3uhl+cb4upZ5 pPEpHHNEvCYSJxoiq93Nmj+R+YH9vrZzuwTcxiIHDOBOktr967iIdCP85KGnRpia Fxs+am5w6u6wusbuoO/iH1WI3pleXnA2zBCjHo/lFQ2Hgi3j4E+OJsC3QX0gwUeN IYhHLrh4TzNJ7lciCMeFJy3mpJAzLya3TCHEf+Cx06ArsmLb6S446QMHA== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41bttyhmcx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:23 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48456qES001535; Wed, 4 Sep 2024 06:59:22 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41cf0mxcm3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:22 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4846xKZS30933448 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Sep 2024 06:59:20 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A36A2004B; Wed, 4 Sep 2024 06:59:20 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FE4420043; Wed, 4 Sep 2024 06:59:20 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 4 Sep 2024 06:59:20 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 37F94E0297; Wed, 4 Sep 2024 08:59:20 +0200 (CEST) From: Sven Schnelle To: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 6/7] tracing: add support for function argument to graph tracer Date: Wed, 4 Sep 2024 08:59:00 +0200 Message-ID: <20240904065908.1009086-7-svens@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240904065908.1009086-1-svens@linux.ibm.com> References: <20240904065908.1009086-1-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _o0R60wvuriQNIEKnoAy1BMXnXC4pMJ1 X-Proofpoint-ORIG-GUID: _o0R60wvuriQNIEKnoAy1BMXnXC4pMJ1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_04,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 spamscore=0 adultscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409040049 Wire up the code to print function arguments in the function graph tracer. This functionality can be enabled/disabled during compile time by setting CONFIG_FUNCTION_TRACE_ARGS and during runtime with options/funcgraph-args. Example usage: 6) | dummy_xmit [dummy](skb = 0x8887c100, dev = 0x872ca000) { 6) | consume_skb(skb = 0x8887c100) { 6) | skb_release_head_state(skb = 0x8887c100) { 6) 0.178 us | sock_wfree(skb = 0x8887c100) 6) 0.627 us | } Signed-off-by: Sven Schnelle --- include/linux/ftrace.h | 1 + kernel/trace/fgraph.c | 6 ++- kernel/trace/trace_functions_graph.c | 74 ++++++++++++++-------------- 3 files changed, 44 insertions(+), 37 deletions(-) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 56d91041ecd2..5d0ff66f8a70 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -1010,6 +1010,7 @@ static inline void ftrace_init(void) { } * to remove extra padding at the end. */ struct ftrace_graph_ent { + struct ftrace_regs regs; unsigned long func; /* Current function */ int depth; } __packed; diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index fa62ebfa0711..f4bb10c0aa52 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -614,7 +614,7 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, /* If the caller does not use ftrace, call this function. */ int function_graph_enter(unsigned long ret, unsigned long func, unsigned long frame_pointer, unsigned long *retp, - struct ftrace_regs *fregs) + struct ftrace_regs *fregs) { struct ftrace_graph_ent trace; unsigned long bitmap = 0; @@ -623,6 +623,10 @@ int function_graph_enter(unsigned long ret, unsigned long func, trace.func = func; trace.depth = ++current->curr_ret_depth; + if (IS_ENABLED(CONFIG_FUNCTION_TRACE_ARGS) && fregs) + trace.regs = *fregs; + else + memset(&trace.regs, 0, sizeof(struct ftrace_regs)); offset = ftrace_push_return_trace(ret, func, frame_pointer, retp, 0); if (offset < 0) diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index 13d0387ac6a6..be0cee52944a 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include "trace.h" #include "trace_output.h" @@ -63,6 +65,9 @@ static struct tracer_opt trace_opts[] = { { TRACER_OPT(funcgraph-retval, TRACE_GRAPH_PRINT_RETVAL) }, /* Display function return value in hexadecimal format ? */ { TRACER_OPT(funcgraph-retval-hex, TRACE_GRAPH_PRINT_RETVAL_HEX) }, +#endif +#ifdef CONFIG_FUNCTION_TRACE_ARGS + { TRACER_OPT(funcgraph-args, TRACE_GRAPH_ARGS) }, #endif /* Include sleep time (scheduled out) between entry and return */ { TRACER_OPT(sleep-time, TRACE_GRAPH_SLEEP_TIME) }, @@ -653,7 +658,7 @@ print_graph_duration(struct trace_array *tr, unsigned long long duration, #define __TRACE_GRAPH_PRINT_RETVAL TRACE_GRAPH_PRINT_RETVAL static void print_graph_retval(struct trace_seq *s, unsigned long retval, - bool leaf, void *func, bool hex_format) + bool hex_format) { unsigned long err_code = 0; @@ -673,28 +678,17 @@ static void print_graph_retval(struct trace_seq *s, unsigned long retval, err_code = 0; done: - if (leaf) { - if (hex_format || (err_code == 0)) - trace_seq_printf(s, "%ps(); /* = 0x%lx */\n", - func, retval); - else - trace_seq_printf(s, "%ps(); /* = %ld */\n", - func, err_code); - } else { - if (hex_format || (err_code == 0)) - trace_seq_printf(s, "} /* %ps = 0x%lx */\n", - func, retval); - else - trace_seq_printf(s, "} /* %ps = %ld */\n", - func, err_code); - } + if (hex_format || (err_code == 0)) + trace_seq_printf(s, " /* = 0x%lx */", retval); + else + trace_seq_printf(s, " /* = %ld */", err_code); } #else #define __TRACE_GRAPH_PRINT_RETVAL 0 -#define print_graph_retval(_seq, _retval, _leaf, _func, _format) do {} while (0) +#define print_graph_retval(_seq, _retval, _format) do {} while (0) #endif @@ -741,16 +735,20 @@ print_graph_entry_leaf(struct trace_iterator *iter, /* Function */ for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) trace_seq_putc(s, ' '); + trace_seq_printf(s, "%ps", (void *)graph_ret->func); + if (flags & TRACE_GRAPH_ARGS) + print_function_args(s, &call->regs, graph_ret->func); + else + trace_seq_puts(s, "();"); /* * Write out the function return value if the option function-retval is * enabled. */ if (flags & __TRACE_GRAPH_PRINT_RETVAL) - print_graph_retval(s, graph_ret->retval, true, (void *)call->func, - !!(flags & TRACE_GRAPH_PRINT_RETVAL_HEX)); - else - trace_seq_printf(s, "%ps();\n", (void *)call->func); + print_graph_retval(s, graph_ret->retval, + !!(flags & TRACE_GRAPH_PRINT_RETVAL_HEX)); + trace_seq_printf(s, "\n"); print_graph_irq(iter, graph_ret->func, TRACE_GRAPH_RET, cpu, iter->ent->pid, flags); @@ -788,7 +786,12 @@ print_graph_entry_nested(struct trace_iterator *iter, for (i = 0; i < call->depth * TRACE_GRAPH_INDENT; i++) trace_seq_putc(s, ' '); - trace_seq_printf(s, "%ps() {\n", (void *)call->func); + trace_seq_printf(s, "%ps", (void *)call->func); + if (flags & TRACE_GRAPH_ARGS) + print_function_args(s, &call->regs, call->func); + else + trace_seq_puts(s, "()"); + trace_seq_printf(s, " {\n"); if (trace_seq_has_overflowed(s)) return TRACE_TYPE_PARTIAL_LINE; @@ -1028,27 +1031,26 @@ print_graph_return(struct ftrace_graph_ret *trace, struct trace_seq *s, for (i = 0; i < trace->depth * TRACE_GRAPH_INDENT; i++) trace_seq_putc(s, ' '); + /* + * If the return function does not have a matching entry, + * then the entry was lost. Instead of just printing + * the '}' and letting the user guess what function this + * belongs to, write out the function name. Always do + * that if the funcgraph-tail option is enabled. + */ + if (func_match && !(flags & TRACE_GRAPH_PRINT_TAIL)) + trace_seq_puts(s, "}"); + else + trace_seq_printf(s, "} /* %ps */", (void *)trace->func); /* * Always write out the function name and its return value if the * function-retval option is enabled. */ if (flags & __TRACE_GRAPH_PRINT_RETVAL) { - print_graph_retval(s, trace->retval, false, (void *)trace->func, + print_graph_retval(s, trace->retval, !!(flags & TRACE_GRAPH_PRINT_RETVAL_HEX)); - } else { - /* - * If the return function does not have a matching entry, - * then the entry was lost. Instead of just printing - * the '}' and letting the user guess what function this - * belongs to, write out the function name. Always do - * that if the funcgraph-tail option is enabled. - */ - if (func_match && !(flags & TRACE_GRAPH_PRINT_TAIL)) - trace_seq_puts(s, "}\n"); - else - trace_seq_printf(s, "} /* %ps */\n", (void *)trace->func); } - + trace_seq_printf(s, "\n"); /* Overrun */ if (flags & TRACE_GRAPH_PRINT_OVERRUN) trace_seq_printf(s, " (Overruns: %u)\n", From patchwork Wed Sep 4 06:59:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 13789834 X-Patchwork-Delegate: mhiramat@kernel.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 18A0414600D; Wed, 4 Sep 2024 06:59:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433175; cv=none; b=pg3A/cEWuVfyV7hd8qNp0uP11mwCNtQ4dj4mSXNXH1YOYcDAE81IOSCWEOX2oXP8mvvQb1YqfY0WTXAU/3Idqv90TZ2akGpMCykVch0n3S8PoAZf+2lg4C/FW1dOp1HX+hpvJP+GJos3K4kTYNlcBghgUSBPWhPh6JrL3J6VWNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725433175; c=relaxed/simple; bh=8KArWYxDYUDJ4scCS2qRzkTqEjcZPhCddUDfLvip7hY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bDjGXoCJQN3FxC+uFq3946naS5An5ps7N9l1N4XIoI848g/Swf4iKn6EdQd8OCZvXNznEiXjXPlO/nzuFK2eARcfRz5ML5LC4VlvS2BSpG5s44rvCeKkKlX+4RnwqqRU+v2WR79SZ7412jeYTTNhbq1za6bS2LV3ZTmNi/gxHug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=HoykKDGX; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="HoykKDGX" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4843La36025328; Wed, 4 Sep 2024 06:59:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=EHXEqHdLSqeJ3 iFQang+Q8/lNpfAThetnfJ7+gLtcks=; b=HoykKDGX+J8Q2s1uTMWJJSqCkie46 ki/v/NhDzytPM+qY83fh/VWgI6fFIuWyPu/srpP57TJ7Lt6HwTkm1F6SCPMiEXQ1 m2G2gOWfb4IXSIY4JN1DXsnMukBu+pGMYgnUyjMbQrKhxBx5a3bFceoK6lf7e1V6 EftS/BpXCVjPwNIil9DpHhAAOXeV+faUuqbXdXUNzBPa3g+vWJWmDhQcXlufnjam vHyMY9rQOYK/bbva5C0dvijhKcs1+aMHrrb62yD+slqdE/uT+QaDKuS3+MWxYDE+ tW1lKQTwrmbt3oIIIbaPw3kc+PCWZIAKBcnv5SMUW35aHZVgfnMNnHLnA== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41bttyhmd1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:24 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4844Klx0018726; Wed, 4 Sep 2024 06:59:24 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 41cdw16kpw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2024 06:59:23 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4846xMui54133180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Sep 2024 06:59:22 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EC0B22004D; Wed, 4 Sep 2024 06:59:21 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBEA92004B; Wed, 4 Sep 2024 06:59:21 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 4 Sep 2024 06:59:21 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 7CA82E0297; Wed, 4 Sep 2024 08:59:21 +0200 (CEST) From: Sven Schnelle To: Steven Rostedt , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCH 7/7] tracing: add arguments to function tracer Date: Wed, 4 Sep 2024 08:59:01 +0200 Message-ID: <20240904065908.1009086-8-svens@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240904065908.1009086-1-svens@linux.ibm.com> References: <20240904065908.1009086-1-svens@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SpzfxvEkpsCFHkUWVBjuRX8ZF1AHDWdq X-Proofpoint-ORIG-GUID: SpzfxvEkpsCFHkUWVBjuRX8ZF1AHDWdq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-04_04,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 suspectscore=0 mlxscore=0 bulkscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 spamscore=0 adultscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409040049 Wire up the code to print function arguments in the function tracer. This functionality can be enabled/disabled during compile time by setting CONFIG_FUNCTION_TRACE_ARGS and during runtime with options/func-args. ping-689 [004] b.... 77.170220: dummy_xmit(skb = 0x82904800, dev = 0x882d0000) <-dev_hard_start_xmit Signed-off-by: Sven Schnelle --- kernel/trace/trace.c | 8 +++++- kernel/trace/trace.h | 4 ++- kernel/trace/trace_entries.h | 7 +++-- kernel/trace/trace_functions.c | 46 +++++++++++++++++++++++++++---- kernel/trace/trace_irqsoff.c | 4 +-- kernel/trace/trace_output.c | 14 ++++++++-- kernel/trace/trace_sched_wakeup.c | 4 +-- 7 files changed, 71 insertions(+), 16 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index ebe7ce2f5f4a..8118e4c8c649 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -2864,7 +2864,7 @@ trace_buffer_unlock_commit_nostack(struct trace_buffer *buffer, void trace_function(struct trace_array *tr, unsigned long ip, unsigned long - parent_ip, unsigned int trace_ctx) + parent_ip, unsigned int trace_ctx, struct ftrace_regs *regs) { struct trace_event_call *call = &event_function; struct trace_buffer *buffer = tr->array_buffer.buffer; @@ -2878,6 +2878,12 @@ trace_function(struct trace_array *tr, unsigned long ip, unsigned long entry = ring_buffer_event_data(event); entry->ip = ip; entry->parent_ip = parent_ip; +#ifdef CONFIG_FUNCTION_TRACE_ARGS + if (regs) + entry->regs = *regs; + else + memset(&entry->regs, 0, sizeof(struct ftrace_regs)); +#endif if (!call_filter_check_discard(call, entry, buffer, event)) { if (static_branch_unlikely(&trace_function_exports_enabled)) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index bd3e3069300e..13cf6f97f7e0 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -673,7 +673,8 @@ unsigned long trace_total_entries(struct trace_array *tr); void trace_function(struct trace_array *tr, unsigned long ip, unsigned long parent_ip, - unsigned int trace_ctx); + unsigned int trace_ctx, + struct ftrace_regs *regs); void trace_graph_function(struct trace_array *tr, unsigned long ip, unsigned long parent_ip, @@ -870,6 +871,7 @@ static __always_inline bool ftrace_hash_empty(struct ftrace_hash *hash) #define TRACE_GRAPH_GRAPH_TIME 0x400 #define TRACE_GRAPH_PRINT_RETVAL 0x800 #define TRACE_GRAPH_PRINT_RETVAL_HEX 0x1000 +#define TRACE_GRAPH_ARGS 0x2000 #define TRACE_GRAPH_PRINT_FILL_SHIFT 28 #define TRACE_GRAPH_PRINT_FILL_MASK (0x3 << TRACE_GRAPH_PRINT_FILL_SHIFT) diff --git a/kernel/trace/trace_entries.h b/kernel/trace/trace_entries.h index c47422b20908..f2021ab52da2 100644 --- a/kernel/trace/trace_entries.h +++ b/kernel/trace/trace_entries.h @@ -61,8 +61,11 @@ FTRACE_ENTRY_REG(function, ftrace_entry, TRACE_FN, F_STRUCT( - __field_fn( unsigned long, ip ) - __field_fn( unsigned long, parent_ip ) + __field_fn( unsigned long, ip ) + __field_fn( unsigned long, parent_ip ) +#ifdef CONFIG_FUNCTION_TRACE_ARGS + __field_struct( struct ftrace_regs, regs ) +#endif ), F_printk(" %ps <-- %ps", diff --git a/kernel/trace/trace_functions.c b/kernel/trace/trace_functions.c index 3b0cea37e029..7ff651a0b45a 100644 --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -25,6 +25,9 @@ static void function_trace_call(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs); static void +function_args_trace_call(unsigned long ip, unsigned long parent_ip, + struct ftrace_ops *op, struct ftrace_regs *fregs); +static void function_stack_trace_call(unsigned long ip, unsigned long parent_ip, struct ftrace_ops *op, struct ftrace_regs *fregs); static void @@ -42,9 +45,10 @@ enum { TRACE_FUNC_NO_OPTS = 0x0, /* No flags set. */ TRACE_FUNC_OPT_STACK = 0x1, TRACE_FUNC_OPT_NO_REPEATS = 0x2, + TRACE_FUNC_OPT_ARGS = 0x4, /* Update this to next highest bit. */ - TRACE_FUNC_OPT_HIGHEST_BIT = 0x4 + TRACE_FUNC_OPT_HIGHEST_BIT = 0x8 }; #define TRACE_FUNC_OPT_MASK (TRACE_FUNC_OPT_HIGHEST_BIT - 1) @@ -114,6 +118,8 @@ static ftrace_func_t select_trace_function(u32 flags_val) switch (flags_val & TRACE_FUNC_OPT_MASK) { case TRACE_FUNC_NO_OPTS: return function_trace_call; + case TRACE_FUNC_OPT_ARGS: + return function_args_trace_call; case TRACE_FUNC_OPT_STACK: return function_stack_trace_call; case TRACE_FUNC_OPT_NO_REPEATS: @@ -198,7 +204,34 @@ function_trace_call(unsigned long ip, unsigned long parent_ip, cpu = smp_processor_id(); data = per_cpu_ptr(tr->array_buffer.data, cpu); if (!atomic_read(&data->disabled)) - trace_function(tr, ip, parent_ip, trace_ctx); + trace_function(tr, ip, parent_ip, trace_ctx, NULL); + + ftrace_test_recursion_unlock(bit); +} + +static void +function_args_trace_call(unsigned long ip, unsigned long parent_ip, + struct ftrace_ops *op, struct ftrace_regs *fregs) +{ + struct trace_array *tr = op->private; + struct trace_array_cpu *data; + unsigned int trace_ctx; + int bit; + int cpu; + + if (unlikely(!tr->function_enabled)) + return; + + bit = ftrace_test_recursion_trylock(ip, parent_ip); + if (bit < 0) + return; + + trace_ctx = tracing_gen_ctx(); + + cpu = smp_processor_id(); + data = per_cpu_ptr(tr->array_buffer.data, cpu); + if (!atomic_read(&data->disabled)) + trace_function(tr, ip, parent_ip, trace_ctx, fregs); ftrace_test_recursion_unlock(bit); } @@ -247,7 +280,7 @@ function_stack_trace_call(unsigned long ip, unsigned long parent_ip, if (likely(disabled == 1)) { trace_ctx = tracing_gen_ctx_flags(flags); - trace_function(tr, ip, parent_ip, trace_ctx); + trace_function(tr, ip, parent_ip, trace_ctx, NULL); #ifdef CONFIG_UNWINDER_FRAME_POINTER if (ftrace_pids_enabled(op)) skip++; @@ -329,7 +362,7 @@ function_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip, trace_ctx = tracing_gen_ctx_flags(flags); process_repeats(tr, ip, parent_ip, last_info, trace_ctx); - trace_function(tr, ip, parent_ip, trace_ctx); + trace_function(tr, ip, parent_ip, trace_ctx, NULL); out: ftrace_test_recursion_unlock(bit); @@ -368,7 +401,7 @@ function_stack_no_repeats_trace_call(unsigned long ip, unsigned long parent_ip, trace_ctx = tracing_gen_ctx_flags(flags); process_repeats(tr, ip, parent_ip, last_info, trace_ctx); - trace_function(tr, ip, parent_ip, trace_ctx); + trace_function(tr, ip, parent_ip, trace_ctx, NULL); __trace_stack(tr, trace_ctx, STACK_SKIP); } @@ -382,6 +415,9 @@ static struct tracer_opt func_opts[] = { { TRACER_OPT(func_stack_trace, TRACE_FUNC_OPT_STACK) }, #endif { TRACER_OPT(func-no-repeats, TRACE_FUNC_OPT_NO_REPEATS) }, +#ifdef CONFIG_FUNCTION_TRACE_ARGS + { TRACER_OPT(func-args, TRACE_FUNC_OPT_ARGS) }, +#endif { } /* Always set a last empty entry */ }; diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c index fce064e20570..096002c99d70 100644 --- a/kernel/trace/trace_irqsoff.c +++ b/kernel/trace/trace_irqsoff.c @@ -150,7 +150,7 @@ irqsoff_tracer_call(unsigned long ip, unsigned long parent_ip, trace_ctx = tracing_gen_ctx_flags(flags); - trace_function(tr, ip, parent_ip, trace_ctx); + trace_function(tr, ip, parent_ip, trace_ctx, fregs); atomic_dec(&data->disabled); } @@ -278,7 +278,7 @@ __trace_function(struct trace_array *tr, if (is_graph(tr)) trace_graph_function(tr, ip, parent_ip, trace_ctx); else - trace_function(tr, ip, parent_ip, trace_ctx); + trace_function(tr, ip, parent_ip, trace_ctx, NULL); } #else diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c index 70405c4cceb6..8fdee7b9cdba 100644 --- a/kernel/trace/trace_output.c +++ b/kernel/trace/trace_output.c @@ -1058,9 +1058,13 @@ enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags, } static void print_fn_trace(struct trace_seq *s, unsigned long ip, - unsigned long parent_ip, int flags) + unsigned long parent_ip, + struct ftrace_regs *fregs, + int flags) { seq_print_ip_sym(s, ip, flags); + if (fregs) + print_function_args(s, fregs, ip); if ((flags & TRACE_ITER_PRINT_PARENT) && parent_ip) { trace_seq_puts(s, " <-"); @@ -1074,10 +1078,14 @@ static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags, { struct ftrace_entry *field; struct trace_seq *s = &iter->seq; + struct ftrace_regs *fregs = NULL; trace_assign_type(field, iter->ent); - print_fn_trace(s, field->ip, field->parent_ip, flags); +#if IS_ENABLED(CONFIG_FUNCTION_TRACE_ARGS) + fregs = &field->regs; +#endif + print_fn_trace(s, field->ip, field->parent_ip, fregs, flags); trace_seq_putc(s, '\n'); return trace_handle_return(s); @@ -1742,7 +1750,7 @@ trace_func_repeats_print(struct trace_iterator *iter, int flags, trace_assign_type(field, iter->ent); - print_fn_trace(s, field->ip, field->parent_ip, flags); + print_fn_trace(s, field->ip, field->parent_ip, NULL, flags); trace_seq_printf(s, " (repeats: %u, last_ts:", field->count); trace_print_time(s, iter, iter->ts - FUNC_REPEATS_GET_DELTA_TS(field)); diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c index 130ca7e7787e..39043c955761 100644 --- a/kernel/trace/trace_sched_wakeup.c +++ b/kernel/trace/trace_sched_wakeup.c @@ -224,7 +224,7 @@ wakeup_tracer_call(unsigned long ip, unsigned long parent_ip, return; local_irq_save(flags); - trace_function(tr, ip, parent_ip, trace_ctx); + trace_function(tr, ip, parent_ip, trace_ctx, fregs); local_irq_restore(flags); atomic_dec(&data->disabled); @@ -309,7 +309,7 @@ __trace_function(struct trace_array *tr, if (is_graph(tr)) trace_graph_function(tr, ip, parent_ip, trace_ctx); else - trace_function(tr, ip, parent_ip, trace_ctx); + trace_function(tr, ip, parent_ip, trace_ctx, NULL); } static int wakeup_flag_changed(struct trace_array *tr, u32 mask, int set)