Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7014269rwb; Tue, 15 Nov 2022 06:40:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Y8eQKwgsCTHIS7y3q4AXAj5uUSqwV7K93RuZqYtdPAVVAnxIJE+gPxWh+atnZD8D38cS3 X-Received: by 2002:a17:90a:f3c2:b0:218:1e70:2af with SMTP id ha2-20020a17090af3c200b002181e7002afmr2651906pjb.46.1668523219489; Tue, 15 Nov 2022 06:40:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668523219; cv=none; d=google.com; s=arc-20160816; b=gS1e3cO40OiUH4WAahHs3YIhYTV7QQnic1zD/ceQjAJI7zNkDiEXV3NWuMb2Wf0JQI yFouKEuNsJgZ4XRSgNJc9UpbkRbnXYAbT3WB1l9OshlDG4L5Vck9pOVbKwD1dohifiQ9 kT+hfNTtc/t66A4PPMaYy6jgPxMqQWF3Wh06slwXmVI4WC+s7sNFnbrIwcsiHPVxT7ev bS82olWEkHTHCPPg2VXNDhgQk9sf2mU6fkIRLsHHeivkUqXbjRHKjgHsNTyCVqRvvZyq pEaLOxqminrwOFPstsdslmh0kM85q/5NrMalmqylwU3ALkn1+KHhbm1OWOHu28x7WyTR lYkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=cmXK9z6lLzSd1pSS8Dk1v7eQjL38US75GIaStgS3+Ho=; b=CkrPNKSs5LupPOwBkE7xoYqwqbWBTpmJ5DVf8bbxcwt6gSdJQTMLh7WoI8zfMLFP2O ELQjM0Us5beCBLhCbzuokUxPTwLt1qjnj7pi6s9siVsjJJOJXnwlEajBTJmxobMz690t D+oaZlbh5bzIPk9j9jDy8QpbanjNHhos3gxPf9bvIPnMu7J1ymxD8p+dvuB1HsyOq2Lw MgeBgaf+STiK7vCshO7dd3lIS5ovp8oCGfLCH0RCl7dTkSleSKAgeMM7pN4uO216gVpQ n94tlbxQjmsvoM7ibRj0VW2Cdz3MMkfWB4K74VAeMa7Rz9G6BgjZEWwkl6Qcpy/MmXaV IvLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=2dm9cKIO; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k35-20020a17090a14a600b00212f7abe85csi15479595pja.41.2022.11.15.06.40.07; Tue, 15 Nov 2022 06:40:19 -0800 (PST) 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; dkim=pass header.i=@microchip.com header.s=mchp header.b=2dm9cKIO; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbiKOO0i (ORCPT + 89 others); Tue, 15 Nov 2022 09:26:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229833AbiKOO0e (ORCPT ); Tue, 15 Nov 2022 09:26:34 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F34B2A948 for ; Tue, 15 Nov 2022 06:26:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1668522393; x=1700058393; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=+XERZkaZEnlrgczx883x+W1hcSu7sIngfJcKE+vi5KY=; b=2dm9cKIOBcuXSggW4sEHYk+5uGBu3oM6jYI4wrV9pxjSBvsMiCv0dFAR mYMFQXUk0eaEq8ORkFySpdP8H6lSjIA09HgWoXnMEYv6FtsBP1YS/ncpi I5ocq2BzNP69ORGinHUodSkCZkorQV9D7vvcqQIvgVMeU0lu1KtrMW8k4 hmy3Iabp8sLicPHoWjPzE7jCCn1jizwGwCoVD1kVIVJ7xrrFdTDwYSQeo BlLAIt+4bLTN/9m4Ba62u34d0mHDYsbMhC0nYQglp/hvJrMaUd+KZzSqu hgWgLoarypHkT0tgWMlh3C+VFQsSJ7dCW4QqMgyHyLF9va7Rfdj5twQBf Q==; X-IronPort-AV: E=Sophos;i="5.96,166,1665471600"; d="scan'208";a="189058136" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Nov 2022 07:26:33 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 15 Nov 2022 07:26:32 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12 via Frontend Transport; Tue, 15 Nov 2022 07:26:30 -0700 Date: Tue, 15 Nov 2022 14:26:13 +0000 From: Conor Dooley To: Song Shuai CC: , , , , , , , , Subject: Re: [PATCH 1/3] riscv/ftrace: add ftrace_graph_func Message-ID: References: <20221115061525.112757-1-suagrfillet@gmail.com> <20221115061525.112757-2-suagrfillet@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20221115061525.112757-2-suagrfillet@gmail.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 On Tue, Nov 15, 2022 at 02:15:23PM +0800, Song Shuai wrote: > Here implements ftrace_graph_func as the function graph tracing function > with FTRACE_WITH_REGS defined. > > function_graph_func gets the point of the parent IP and the frame pointer > from fregs and call prepare_ftrace_return for function graph tracing. > > If FTRACE_WITH_REGS isn't defined, the enable/disable helpers of > ftrace_graph_[regs]_call remain for serving the !FTRACE_WITH_REGS > version ftrace_caller. > > Signed-off-by: Song Shuai Hey Song, Last time I saw your email I'd swear it was "sugarfillet", just making sure that it is not a typo. Anyways, checkpatch is whinging about some parenthesis stuff: https://patchwork.kernel.org/project/linux-riscv/patch/20221115061525.112757-2-suagrfillet@gmail.com/ Would be nice to fix that when you resping. Thanks, Conor. > --- > arch/riscv/include/asm/ftrace.h | 13 +++++++++++-- > arch/riscv/kernel/ftrace.c | 16 ++++++++++++++++ > 2 files changed, 27 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/include/asm/ftrace.h b/arch/riscv/include/asm/ftrace.h > index 04dad3380041..b33c98070972 100644 > --- a/arch/riscv/include/asm/ftrace.h > +++ b/arch/riscv/include/asm/ftrace.h > @@ -81,8 +81,17 @@ do { \ > struct dyn_ftrace; > int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec); > #define ftrace_init_nop ftrace_init_nop > -#endif > > -#endif > +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS > +struct ftrace_ops; > +struct ftrace_regs; > +void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, > + struct ftrace_ops *op, struct ftrace_regs *fregs); > +#define ftrace_graph_func ftrace_graph_func > +#endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */ > + > +#endif /* __ASSEMBLY__ */ > + > +#endif /* CONFIG_DYNAMIC_FTRACE */ > > #endif /* _ASM_RISCV_FTRACE_H */ > diff --git a/arch/riscv/kernel/ftrace.c b/arch/riscv/kernel/ftrace.c > index 2086f6585773..2d7ce77d4f33 100644 > --- a/arch/riscv/kernel/ftrace.c > +++ b/arch/riscv/kernel/ftrace.c > @@ -196,6 +196,20 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, > } > > #ifdef CONFIG_DYNAMIC_FTRACE > + > +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS > + > +void ftrace_graph_func(unsigned long ip, unsigned long parent_ip, > + struct ftrace_ops *op, struct ftrace_regs *fregs) > +{ > + struct pt_regs *regs = arch_ftrace_get_regs(fregs); > + unsigned long *parent = (unsigned long *)&(regs->ra); > + > + prepare_ftrace_return(parent, ip, frame_pointer(regs)); > +} > + > +#else /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */ > + > extern void ftrace_graph_call(void); > extern void ftrace_graph_regs_call(void); > int ftrace_enable_ftrace_graph_caller(void) > @@ -223,5 +237,7 @@ int ftrace_disable_ftrace_graph_caller(void) > return __ftrace_modify_call((unsigned long)&ftrace_graph_regs_call, > (unsigned long)&prepare_ftrace_return, false); > } > +#endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */ > + > #endif /* CONFIG_DYNAMIC_FTRACE */ > #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ > -- > 2.20.1 >