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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D380AD116F3 for ; Wed, 3 Dec 2025 08:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dcekDfnEj2CstPSYrZZno4lTngUx7RJmJ4IHOnNfYoI=; b=iKZ+QSneOJY7ulUWoGfDG/hY/q tE+PjdlY1cRjXlJnudAI9eqMRG1M1olQSq4Ab7cJl3DD56cggYJyyMbv9lEdUHC0BoICmRshpZw0z 7itTIdJ4pP1yR7FyQD7BW79oLsdSQoAVt1lBqWVor4iItv9d82ssvozbVERT0qju3jC83nFwWj7Uk Xa+Zpa94/jJsXS4o8YI2kCFpkTtyUaOUgCfsV2BceAHOs+PQNh/6Rb4NZDqYUTgHJLHCrPpJ83V5B FTNh+SPW8dUBUFYYNpe3onH3mWmcSkNkfNAunIgc23GSqoi0OQhi5PhdIPSTjglemVpKbQbooq11e zm+OyCyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vQiB8-00000006J2l-3ZlX; Wed, 03 Dec 2025 08:25:38 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vQiB6-00000006J1I-30mG for linux-arm-kernel@lists.infradead.org; Wed, 03 Dec 2025 08:25:38 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 62FB840945; Wed, 3 Dec 2025 08:25:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3EA40C4CEFB; Wed, 3 Dec 2025 08:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764750336; bh=WcyS/E/AX8t/ip8FwSSMLUMvyrZSSGqjazXVjPdQ0cI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sd68vHHk3FrgM/ndqM6F0KwcZkQ17/d6I64Ma6Sn6aw3PjUcVB+Glb4+9xPht1znb 7manH/faXGPZhP+Nl89i3mADzP+JlyXfMJPaopdeOzVvxqIk6eJFTbsvvGN+QmxEIf i3EI4p1bE+YfUK2Jgoid/UT+4MzVMxzNCXgQW1cOe6/37b4tejaishM2SFl7jQPq04 ocHFjvOzU2Cjfcfdb4K72/QUFEyJ5rTBE+yO4nPXpejD77bH4mV5FGgJM9YLbpQjta Tnh7fCNLkwR92UvjpimyZ9puGjXHi6kqxeBPiYDlqs9cl+umiMdF/J9nTX731kiFvj VNAh18hXUFk6g== From: Jiri Olsa To: Steven Rostedt , Florent Revest , Mark Rutland Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Menglong Dong , Song Liu Subject: [PATCHv4 bpf-next 8/9] ftrace: Factor ftrace_ops ops_func interface Date: Wed, 3 Dec 2025 09:24:01 +0100 Message-ID: <20251203082402.78816-9-jolsa@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251203082402.78816-1-jolsa@kernel.org> References: <20251203082402.78816-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251203_002536_808144_818C914E X-CRM114-Status: GOOD ( 13.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We are going to remove "ftrace_ops->private == bpf_trampoline" setup in following changes. Adding ip argument to ftrace_ops_func_t callback function, so we can use it to look up the trampoline. Signed-off-by: Jiri Olsa --- include/linux/ftrace.h | 2 +- kernel/bpf/trampoline.c | 3 ++- kernel/trace/ftrace.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index c27b7381c5f1..515cf5b723dd 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -402,7 +402,7 @@ enum ftrace_ops_cmd { * Negative on failure. The return value is dependent on the * callback. */ -typedef int (*ftrace_ops_func_t)(struct ftrace_ops *op, enum ftrace_ops_cmd cmd); +typedef int (*ftrace_ops_func_t)(struct ftrace_ops *op, unsigned long ip, enum ftrace_ops_cmd cmd); #ifdef CONFIG_DYNAMIC_FTRACE diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index f298bafab76e..17af2aad8382 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -33,7 +33,8 @@ static DEFINE_MUTEX(trampoline_mutex); #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mutex); -static int bpf_tramp_ftrace_ops_func(struct ftrace_ops *ops, enum ftrace_ops_cmd cmd) +static int bpf_tramp_ftrace_ops_func(struct ftrace_ops *ops, unsigned long ip, + enum ftrace_ops_cmd cmd) { struct bpf_trampoline *tr = ops->private; int ret = 0; diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index c77f620b3eb3..9582cb374d4f 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -2049,7 +2049,7 @@ static int __ftrace_hash_update_ipmodify(struct ftrace_ops *ops, */ if (!ops->ops_func) return -EBUSY; - ret = ops->ops_func(ops, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF); + ret = ops->ops_func(ops, rec->ip, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF); if (ret) return ret; } else if (is_ipmodify) { @@ -8984,7 +8984,7 @@ static int prepare_direct_functions_for_ipmodify(struct ftrace_ops *ops) if (!op->ops_func) return -EBUSY; - ret = op->ops_func(op, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER); + ret = op->ops_func(op, ip, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER); if (ret) return ret; } @@ -9031,7 +9031,7 @@ static void cleanup_direct_functions_after_ipmodify(struct ftrace_ops *ops) /* The cleanup is optional, ignore any errors */ if (found_op && op->ops_func) - op->ops_func(op, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER); + op->ops_func(op, ip, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER); } } mutex_unlock(&direct_mutex); -- 2.52.0