Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp1793334qtg; Wed, 22 Mar 2023 02:06:30 -0700 (PDT) X-Google-Smtp-Source: AK7set8Q8hBn/8lRYm1FrwKfWsZvYyArzliNcJAjJPY3x20ciUP01Y1f3kE4+xJy3obogn2Vpqis X-Received: by 2002:a62:4e47:0:b0:626:166f:6db1 with SMTP id c68-20020a624e47000000b00626166f6db1mr2380940pfb.13.1679475990547; Wed, 22 Mar 2023 02:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679475990; cv=none; d=google.com; s=arc-20160816; b=BiZCBEes2cV9YOW4KAa3hGuustjbYYyjh++7R0+L/w+fM1TreFX52m4Nv9aKgOnAg9 xG/v4BMmm6zbE8ksdp6u2FcrhOr8abx8aXxMuEpcnALqzcMgfl6mIz16WJ8ahbwDawVb 9SqBt2n0Vglpb54WIsw3LG+vdp0xgt11anqhCCFTRWhZs014eD82/M61eoNWSNPeLoHo UklJZlYCteWd9ftS4oS7I0j6SKphT38ser0ePczo01OppQdBbUsaR24LaSTIRh7RPMgk hT29Rzxqj3Ksx79suLvkVI3BZDxjmVZ46RzrBtiHhQ/ho9Y08llVfBTAI/SPyoSiPZ5k Hv8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=XfG2tc43aW3N2lqGieXOYTnJ89/QvYGEjUEhfuPrgsg=; b=u5aQdVmwU8m/GahKMDGtn9N/YEsAX7bIQUxQODRvxctHgKD0/CdJXQCuDDAWvvmmtg 2IhdJzKPBN5oZfS0K5cjdpxpHqjDjk79DDNND3pg7EloclDB2Vk7Piv8pY+VnrkleSMJ GPyLI0sEtv2Ww94lQLjHfDiNdFiOOnYH3AQ9XcTsquvszv0GF55r21b3ZeO854gbZkUJ 7ji5MSc6UIi1pZuFBolaPLhcTt2YrRRNZHw5/LKpJvHOB3O3viPzeXegZH7z0qsJFWzT pP7fTd49haUMCW+jt0CHbZnL6drwEC3rkuD96MSJGbykrHax1VVMdNtGRVUhHCk2CtZq gprw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s17-20020a63ff51000000b00500633a3622si14995864pgk.219.2023.03.22.02.06.18; Wed, 22 Mar 2023 02:06:30 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbjCVJCF (ORCPT + 99 others); Wed, 22 Mar 2023 05:02:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjCVJCD (ORCPT ); Wed, 22 Mar 2023 05:02:03 -0400 Received: from mail-m118111.qiye.163.com (mail-m118111.qiye.163.com [115.236.118.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D5D95B42A; Wed, 22 Mar 2023 02:02:01 -0700 (PDT) Received: from [10.128.10.193] (unknown [117.133.56.22]) by mail-m118111.qiye.163.com (Hmail) with ESMTPA id 9E5CB5807BE; Wed, 22 Mar 2023 17:01:55 +0800 (CST) Message-ID: <88c2c37b-c221-5c27-9663-7026084adf8d@sangfor.com.cn> Date: Wed, 22 Mar 2023 17:01:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v5 1/2] function_graph: Support recording and printing the return value of function Content-Language: en-US To: "Russell King (Oracle)" Cc: mhiramat@kernel.org, rostedt@goodmis.org, mark.rutland@arm.com, will@kernel.org, catalin.marinas@arm.com, palmer@dabbelt.com, paul.walmsley@sifive.com, tglx@linutronix.de, dave.hansen@linux.intel.com, x86@kernel.org, mingo@redhat.com, xiehuan09@gmail.com, dinghui@sangfor.com.cn, huangcun@sangfor.com.cn, dolinux.peng@gmail.com, linux-trace-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20230320131650.482594-1-pengdonglin@sangfor.com.cn> <20230320131650.482594-2-pengdonglin@sangfor.com.cn> From: Donglin Peng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVkaTx4eVkwdS0NOT04YGR0eTFUTARMWGhIXJBQOD1 lXWRgSC1lBWUpKTFVKSEhVTk1VSUlZV1kWGg8SFR0UWUFZT0tIVUpKS09ISFVKS0tVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PC46GSo*Kj0OKRRJLRI3QiE2 NwNPFA9VSlVKTUxCT0xOTEpMS01MVTMWGhIXVQseFRwfFBUcFxIVOwgaFRwdFAlVGBQWVRgVRVlX WRILWUFZSkpMVUpISFVOTVVJSVlXWQgBWUFPTU1DNwY+ X-HM-Tid: 0a87088db1662eb7kusn9e5cb5807be X-HM-MType: 1 X-Spam-Status: No, score=-0.0 required=5.0 tests=NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 2023/3/22 1:31, Russell King (Oracle) wrote: > On Mon, Mar 20, 2023 at 06:16:49AM -0700, Donglin Peng wrote: >> diff --git a/arch/arm/kernel/entry-ftrace.S b/arch/arm/kernel/entry-ftrace.S >> index 3e7bcaca5e07..ba1986e27af8 100644 >> --- a/arch/arm/kernel/entry-ftrace.S >> +++ b/arch/arm/kernel/entry-ftrace.S >> @@ -258,7 +258,15 @@ ENDPROC(ftrace_graph_regs_caller) >> #ifdef CONFIG_FUNCTION_GRAPH_TRACER >> ENTRY(return_to_handler) >> stmdb sp!, {r0-r3} >> +#ifdef CONFIG_FUNCTION_GRAPH_RETVAL >> + /* >> + * Pass both the function return values in the register r0 and r1 >> + * to ftrace_return_to_handler >> + */ >> + add r2, sp, #16 @ sp at exit of instrumented routine >> +#else >> add r0, sp, #16 @ sp at exit of instrumented routine >> +#endif >> bl ftrace_return_to_handler > ... >> -unsigned long ftrace_return_to_handler(unsigned long frame_pointer) >> +static unsigned long __ftrace_return_to_handler(unsigned long retval_1st, >> + unsigned long retval_2nd, unsigned long frame_pointer) > ... >> +#ifdef CONFIG_FUNCTION_GRAPH_RETVAL >> +unsigned long ftrace_return_to_handler(unsigned long retval_1st, >> + unsigned long retval_2nd, unsigned long frame_pointer) >> +{ >> + return __ftrace_return_to_handler(retval_1st, retval_2nd, frame_pointer); >> +} >> +#else >> +unsigned long ftrace_return_to_handler(unsigned long frame_pointer) >> +{ >> + return __ftrace_return_to_handler(0, 0, frame_pointer); >> +} >> +#endif >> + > > Hi, > > To echo Mark's criticism, I also don't like this. I feel it would be > better if ftrace_return_to_handler() always took the same arguments > irrespective of the setting of CONFIG_FUNCTION_GRAPH_RETVAL. > > On 32-bit ARM, we have to stack r0-r3 anyway to prevent the call to > ftrace_return_to_handler() corrupting the return value, and these > are the registers we need. So we might as well pass a pointer to > these stacked registers. Whether that's acceptable on other > architectures, I couldn't say. Agree, I think we can introduce a new structure called pt_ret_regs for each relevant architecture. The pt_ret_regs should only contain the return registers and the frame pointer register, for arm, they are r0~r3 and r11.Then we can pass the pointer to the pt_ret_regs to ftrace_return_to_handler. > > Thanks. >