From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B4D7C56201 for ; Thu, 29 Oct 2020 01:02:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 055CF207BC for ; Thu, 29 Oct 2020 01:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731011AbgJ1WNK (ORCPT ); Wed, 28 Oct 2020 18:13:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:56464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730829AbgJ1WMX (ORCPT ); Wed, 28 Oct 2020 18:12:23 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BC763247C5; Wed, 28 Oct 2020 15:29:18 +0000 (UTC) Date: Wed, 28 Oct 2020 11:29:16 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Jiri Kosina , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Alexei Starovoitov , Jiri Olsa , Josh Poimboeuf Subject: Re: [RFC][PATCH 1/2 v2] ftrace/x86: Allow for arguments to be passed in to REGS by default Message-ID: <20201028112916.50bcbc69@oasis.local.home> In-Reply-To: <20201028102502.28095c95@oasis.local.home> References: <20201028131542.963014814@goodmis.org> <20201028131909.738751907@goodmis.org> <20201028102502.28095c95@oasis.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Masami, Talking with Peter and Thomas on IRC, where they really don't like passing a partial pt_regs around, got me thinking of redoing the REGS parameter of ftrace. Kprobes is the only user that requires the full registers being saved, and that's only because some kprobe user might want them. On Wed, 28 Oct 2020 10:25:02 -0400 Steven Rostedt wrote: > > typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip, > struct ftrace_ops *op, struct pt_regs *regs); > Most registers of pt_regs at a start of a function is rather useless. What if we got rid of FL_SAVE_REGS all together and had a "ftrace_regs" structure passed in that would have only access to all the argument registers, the stack pointer and the instruction pointer? Then kprobes could just create its own pt_regs, fill in all the data from ftrace_regs and then fill the rest with zeros or possibly whatever the values currently are (does it really matter what those registers are?), including flags. Not only would this simplify the code, it would probably allow moving more of the kprobe code from the arch specific to the generic code, and remove a lot of duplication. This would also help speed up the processing of live kernel patching. And best of all, it would give everything access to the arguments of a function and a stack pointer with out (ab)using pt_regs. Do you think this would be feasible? -- Steve