Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1467669rwd; Thu, 8 Jun 2023 19:23:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NeZQwLygPBGvOYveYuIYkjHOQueMKxlz41X9RdbNG8tBEiInIGE/08DsWmuYTI5Hx5a/u X-Received: by 2002:a05:6a20:8405:b0:10b:9db0:b03f with SMTP id c5-20020a056a20840500b0010b9db0b03fmr4389141pzd.18.1686277403247; Thu, 08 Jun 2023 19:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686277403; cv=none; d=google.com; s=arc-20160816; b=O/+23D4z+NWzptx7WJ2Vp1Kp9h4VVC5ztXl7H0SST/X6/In3Xu0m3+4rLekyJh7oip wqqZPpfThM2lNnsSSzXf5tDDXFKUtrxkw3BK/8+LfyF6gfR2L2TCUgD+FHtI5ftRUTB2 DngQZ6Sil9LHkvysObP+Roh40zbo7yBSBJt2RRIFFds55I5+eBWQ6e7VYRCXqCfvENnL E8Ou9bGt8HXWbkIFJ/skWH8nenScjWDpqZomjp9PCfeoPs8tZ8b5oB9ubcL+FyftE6YJ 9GGYkiaEh53cdNIPpDLZn28JCYoz4vzdA3iV1w+cwsJ9Xqb2DElhhHEsavRsJTGVjJQJ sRmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=qBGLg8/61Z0XRlKCHZ6TeU4xgdCnhjxfTCyCP+9Q1wc=; b=c/D80e7RtAmHCM4UokVqmyYytBdanTV1PtJ+G9wxh+2Eqf5DUgM0bPs9ylwAMQkmkk mYlSr5JYHswucmsE9Q4paEh2aCzvWVDwJFG4e+2UbazrzFf3D7MKWNI6DcYqVM/nmmrF OXSXpMH80ahRt/02pPSmZei+KOB7i8r0G9i42v7jnPcPakTly/Co435uDUO7PAa0IdD2 KThXNi1yRJCtJmyMONmPEeALCgeHHSSn7WXjapQomaSRPJIfZzKPzZRmbBBFkmYl/WBj ms5y0aoy2gED7oACuMVB+kcEVlpVBlSmspmVq/uxPWLn8fU+o6fLv6C/QUh63WcsJmpp eqRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s70-20020a632c49000000b0053f2551834fsi1856273pgs.552.2023.06.08.19.23.09; Thu, 08 Jun 2023 19:23:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238124AbjFIB6r (ORCPT + 99 others); Thu, 8 Jun 2023 21:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238057AbjFIB6n (ORCPT ); Thu, 8 Jun 2023 21:58:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55C6430C5; Thu, 8 Jun 2023 18:58:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D580E61AFB; Fri, 9 Jun 2023 01:58:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DF6BC433EF; Fri, 9 Jun 2023 01:58:36 +0000 (UTC) Date: Thu, 8 Jun 2023 21:58:34 -0400 From: Steven Rostedt To: Donglin Peng Cc: mhiramat@kernel.org, linux@armlinux.org.uk, mark.rutland@arm.com, will@kernel.org, catalin.marinas@arm.com, rmk+kernel@armlinux.org.uk, palmer@dabbelt.com, paul.walmsley@sifive.com, aou@eecs.berkeley.edu, tglx@linutronix.de, dave.hansen@linux.intel.com, x86@kernel.org, bp@alien8.de, hpa@zytor.com, chenhuacai@kernel.org, zhangqing@loongson.cn, kernel@xen0n.name, mingo@redhat.com, peterz@infradead.org, xiehuan09@gmail.com, dinghui@sangfor.com.cn, huangcun@sangfor.com.cn, dolinux.peng@gmail.com, linux-trace-kernel@vger.kernel.org, loongarch@lists.linux.dev, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v11 5/8] riscv: ftrace: Enable HAVE_FUNCTION_GRAPH_RETVAL Message-ID: <20230608215834.729cfda2@gandalf.local.home> In-Reply-To: References: X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Can I get an ack from a RISC-V maintainer? -- Steve On Sat, 8 Apr 2023 05:42:19 -0700 Donglin Peng wrote: > The previous patch ("function_graph: Support recording and printing > the return value of function") has laid the groundwork for the for > the funcgraph-retval, and this modification makes it available on > the RISC-V platform. > > We introduce a new structure called fgraph_ret_regs for the RISC-V > platform to hold return registers and the frame pointer. We then > fill its content in the return_to_handler and pass its address to > the function ftrace_return_to_handler to record the return value. > > Signed-off-by: Donglin Peng > --- > v10: > - Use CONFIG_FUNCTION_GRAPH_TRACER to control fgraph_ret_regs definition > > v9: > - Update the commit message > > v8: > - Modify the control range of CONFIG_HAVE_FUNCTION_GRAPH_RETVAL > --- > arch/riscv/Kconfig | 1 + > arch/riscv/include/asm/ftrace.h | 21 +++++++++++++++++++++ > arch/riscv/kernel/mcount.S | 7 +------ > 3 files changed, 23 insertions(+), 6 deletions(-) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index eb7f29a412f8..108538815309 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -139,6 +139,7 @@ config RISCV > select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8) > select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE > select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL > + select HAVE_FUNCTION_GRAPH_RETVAL if HAVE_FUNCTION_GRAPH_TRACER > select HAVE_FUNCTION_GRAPH_TRACER > select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !PREEMPTION > > diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h > index d47d87c2d7e3..740a979171e5 100644 > --- a/arch/riscv/include/asm/ftrace.h > +++ b/arch/riscv/include/asm/ftrace.h > @@ -111,4 +111,25 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec); > > #endif /* CONFIG_DYNAMIC_FTRACE */ > > +#ifndef __ASSEMBLY__ > +#ifdef CONFIG_FUNCTION_GRAPH_TRACER > +struct fgraph_ret_regs { > + unsigned long a1; > + unsigned long a0; > + unsigned long s0; > + unsigned long ra; > +}; > + > +static inline unsigned long fgraph_ret_regs_return_value(struct fgraph_ret_regs *ret_regs) > +{ > + return ret_regs->a0; > +} > + > +static inline unsigned long fgraph_ret_regs_frame_pointer(struct fgraph_ret_regs *ret_regs) > +{ > + return ret_regs->s0; > +} > +#endif /* ifdef CONFIG_FUNCTION_GRAPH_TRACER */ > +#endif > + > #endif /* _ASM_RISCV_FTRACE_H */ > diff --git a/arch/riscv/kernel/mcount.S b/arch/riscv/kernel/mcount.S > index 30102aadc4d7..8a6e5a9e842a 100644 > --- a/arch/riscv/kernel/mcount.S > +++ b/arch/riscv/kernel/mcount.S > @@ -65,13 +65,8 @@ ENTRY(return_to_handler) > * So alternatively we check the *old* frame pointer position, that is, the > * value stored in -16(s0) on entry, and the s0 on return. > */ > -#ifdef HAVE_FUNCTION_GRAPH_FP_TEST > - mv t6, s0 > -#endif > SAVE_RET_ABI_STATE > -#ifdef HAVE_FUNCTION_GRAPH_FP_TEST > - mv a0, t6 > -#endif > + mv a0, sp > call ftrace_return_to_handler > mv a2, a0 > RESTORE_RET_ABI_STATE