Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp84460pxb; Tue, 15 Feb 2022 08:54:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJx264+PtJRNtFuvW7+fwNG2MuQdjG1YXVaAyd7pgMQDXL+jA3hyKy1lB6hV/YXdAIHP8zGn X-Received: by 2002:aa7:c50c:: with SMTP id o12mr4744849edq.371.1644944082419; Tue, 15 Feb 2022 08:54:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644944082; cv=none; d=google.com; s=arc-20160816; b=VVJPTJPDadDZmkSVuAH52UFLzG499jHFk6pzRHrDt74eJGTJ7AvfXpHaRwXG63J05y Pwqw3HCINZDRgTJN2NF6FDf365Zmipn30SE+PBRywnikZxSR0827r8MnUW3O8WFwyLqm L0BfLUptMAT1UxJzhLUoBcnnd1mCiny94vBM+vm/wYWZRSaNcFwJsSaBDIjzUDmXg598 bewgfiEV2M5p3cPWKwEnlLGgCDu88IYebwdf8bRcaIChmxzenbYz7GsTLUxLXHRHKQnw aTtH9/Rt4RI2VrNTGe41ZGwJAKdZnL0iidBQLrh4MiQ27d8XpRxahLU8EK43A4tBcC8l z7XQ== 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=cMonv7xaO6W2uDtPgih+2WsLBFw0f9k5ASPeVt5i5+U=; b=tHC5bqqx2V25N0k5XXUk1qK7LcJgUeuixIeI5aAAkQEzoETSGeK1mXZWyVixd5mxSp pPUvtjdyeWB2uqDNIcp5ZZHbg1/ZjNGd3D2UjOTPEF5Xc15wyN9txFsx9KVlpgKSKlma dheQ16Xl4m4WgXiI0Y73MBKI3YCGyvT34Ad+6L9C4iOA1cvcxLJDpw/LyRwP8s/PX6LQ UJWoiWZVpqSkTdZEMdmjEolnOWUTceM4S6ikUNpERtkSS68pXymC6qqJoL9xhhSmJ1sX yTNZQaVFK148drukYnG6gsG3ub9HMe6k1c1yChuPNWZvQQfFuxUzjfMBXkzuecw5FJ3A 57Uw== 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 hc13si15977537ejc.901.2022.02.15.08.54.18; Tue, 15 Feb 2022 08:54:42 -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; 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 S238734AbiBOOjG (ORCPT + 99 others); Tue, 15 Feb 2022 09:39:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232373AbiBOOjF (ORCPT ); Tue, 15 Feb 2022 09:39:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31E9E10240E; Tue, 15 Feb 2022 06:38:55 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id D2E92B81A64; Tue, 15 Feb 2022 14:38:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14DDAC340EB; Tue, 15 Feb 2022 14:38:50 +0000 (UTC) Date: Tue, 15 Feb 2022 09:38:49 -0500 From: Steven Rostedt To: "Naveen N. Rao" Cc: Christophe Leroy , Jiri Kosina , Joe Lawrence , Josh Poimboeuf , Miroslav Benes , Ingo Molnar , Michael Ellerman , Petr Mladek , "linux-kernel@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "live-patching@vger.kernel.org" , Masami Hiramatsu Subject: Re: [PATCH v2 09/13] powerpc/ftrace: Implement CONFIG_DYNAMIC_FTRACE_WITH_ARGS Message-ID: <20220215093849.556d5444@gandalf.local.home> In-Reply-To: <1644930705.g64na2kgvd.naveen@linux.ibm.com> References: <5831f711a778fcd6eb51eb5898f1faae4378b35b.1640017960.git.christophe.leroy@csgroup.eu> <1644852011.qg7ud9elo2.naveen@linux.ibm.com> <1b28f52a-f8b7-6b5c-e726-feac4123517d@csgroup.eu> <875ypgo0f3.fsf@mpe.ellerman.id.au> <1644930705.g64na2kgvd.naveen@linux.ibm.com> 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 On Tue, 15 Feb 2022 19:06:48 +0530 "Naveen N. Rao" wrote: > As I understand it, the reason ftrace_get_regs() was introduced was to > be able to only return the pt_regs, if _all_ registers were saved into > it, which we don't do when coming in through ftrace_caller(). See the > x86 implementation (commit 02a474ca266a47 ("ftrace/x86: Allow for > arguments to be passed in to ftrace_regs by default"), which returns > pt_regs conditionally. I can give you the history of ftrace_caller and ftrace_regs_caller. ftrace_caller saved just enough as was denoted for gcc mcount trampolines. The new fentry which happens at the start of the function, whereas mcount happens after the stack frame is set up, may change the rules on some architectures. As for ftrace_regs_caller, that was created for kprobes. As the majority of kprobes were added at the start of the function, it made sense to hook into ftrace as the ftrace trampoline call is much faster than taking a breakpoint interrupt. But to keep compatibility with breakpoint interrupts, we needed to fill in all the registers, and make it act just like a breakpoint interrupt. I've been wanting to record function parameters, and because the ftrace trampoline must at a minimum save the function parameters before calling the ftrace callbacks, all the information for those parameters were being saved but were never exposed to the ftrace callbacks. I created the the DYNAMIC_FTRACE_WITH_ARGS to expose them. I first just used pt_regs with just the parameters filled in, but that was criticized as it could be confusing where the non filled in pt_regs might be used and thinking they are legitimate. So I created ftrace_regs that would give you just the function arguments (if DYNAMIC_FTRACE_WITH_ARGS is defined), or it will give you a full pt_regs, if the caller came from the ftrace_regs_caller. If not, it will give you a NULL pointer. The first user to use the args was live kernel patching, as they only need that and the return pointer. -- Steve