Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1328745pxb; Sat, 15 Jan 2022 08:59:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOUlzIxoUe0/YXO5yoMG8xQudKW0O4j01qhWaZvnlyU85nOSFoDdHGXmH0GYPq+yH0lcJG X-Received: by 2002:a17:907:7e82:: with SMTP id qb2mr11879140ejc.291.1642265963061; Sat, 15 Jan 2022 08:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642265963; cv=none; d=google.com; s=arc-20160816; b=xVO3p/9iP+VDFafFhClksI3GoQot0edzEURC3FLXl1uM2+5Z6Uv08z4pz3ISQ0rs0T FfBhPbnRlEhCiFvQG8xjeO+3M7OS63u+rh1BEFduj6xNxBGHhwkCqRwe7VcMbBOVE35I yYtZsI0pGJolPLk/2GMjN/VBfTnPLJh8gU0HpJ56KYUmFTZ1CgAPgnHRHlJ03Q3yVHY0 hPsLar2cjlMOMJwnLbB9FnZDSBTg6iRNySrpzyfFP9wyfOKETUNVhr9bHAASJjUJ/dHD wjHa5EWNzw3R4fpNKqfTnn5vDaCWU3gE8LkDyta26taA0H5QlCgulp9rYSlCSZwZceGM B4Eg== 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 :dkim-signature; bh=K91KBuknKqo+lDvE7Q5xS1mivicVWj2raOFdYBAdpJY=; b=aoqDsmAnQkweZhKD2YB3Cw/YT3sjbBDqia9TXvb25MZIhwgdRK6kwzdvfyd1A8wBFY HXkOjWw64qxLLBU/l3YoQHrJmokhzxVg5MSKhog/V/7i7GR7fMg7HpoSsahwmKbiicFI R6T5cTJQhouTVpe8Fu+qM41+SJspYSFWVLsgavL8swsdDIMJZJ2dovFETnqp2TEwttED KQxnhOMD+0BUfy8EfTxV4smy20cHS9Gf+hiRn5fHptlqIOSofsNFPTw7lnJ45gedjnjU +e9dPwURlIpwNZVGS/BJmzJlXdW4pqVSJgv9MArGYq4bUzdgLRS8Q16Fx3IdaIMCa6Ia tQ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZCQYVVEZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq37si5008509ejc.226.2022.01.15.08.58.58; Sat, 15 Jan 2022 08:59:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZCQYVVEZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232492AbiAOEjR (ORCPT + 99 others); Fri, 14 Jan 2022 23:39:17 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:46010 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbiAOEjQ (ORCPT ); Fri, 14 Jan 2022 23:39:16 -0500 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 D8EC9B82A3F; Sat, 15 Jan 2022 04:39:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB737C36AE3; Sat, 15 Jan 2022 04:39:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642221553; bh=Lmw0vnQYmWnz1sy8w6vxj9DD1VhxFXZBl4P4Jg4yq/w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ZCQYVVEZGKXxUXg07KpzKKYBf449x8VFMf4m6GuD2mqoi+QiHmDAOu8vU6moy9CK8 zWTxMxTX5/L5M1Ka2gA2sgmMS+oRyeecauqGf8wD0v+E8EEv9o5GjQ4720OUKadL6Z 0FrUNOWwuWnUatKXjZtLVwcFZOBmH97XizYRIgt4BXmGVEEnXK1OGANfounfdyJexz odmNVhmDZ3OV5IJY+c8b+oCSjd6zWHfDixXtEjFiTGGa8/Y8aYgfxnMt5FQ4IQvIOa Gw1wVApnGt2fXnW+QOBPH7KaYzvvDjROUPMFhWLYKfXipl4anZz3Gv0lr3GW06ERkc YGpyCsbdkLiWw== Date: Sat, 15 Jan 2022 13:39:07 +0900 From: Masami Hiramatsu To: Jiri Olsa Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , netdev@vger.kernel.org, bpf@vger.kernel.org, lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Steven Rostedt , "Naveen N . Rao" , Anil S Keshavamurthy , "David S . Miller" Subject: Re: [RFC PATCH v2 3/8] rethook: Add a generic return hook Message-Id: <20220115133907.2a713806100fc0f7a562a96b@kernel.org> In-Reply-To: References: <164199616622.1247129.783024987490980883.stgit@devnote2> <164199620208.1247129.13021391608719523669.stgit@devnote2> <20220113221532.c48abf7f56d29ba95dcb0dc6@kernel.org> X-Mailer: Sylpheed 3.7.0 (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 On Fri, 14 Jan 2022 16:18:13 +0100 Jiri Olsa wrote: > On Thu, Jan 13, 2022 at 10:15:32PM +0900, Masami Hiramatsu wrote: > > On Thu, 13 Jan 2022 13:25:52 +0100 > > Jiri Olsa wrote: > > > > > On Wed, Jan 12, 2022 at 11:03:22PM +0900, Masami Hiramatsu wrote: > > > > Add a return hook framework which hooks the function > > > > return. Most of the idea came from the kretprobe, but > > > > this is independent from kretprobe. > > > > Note that this is expected to be used with other > > > > function entry hooking feature, like ftrace, fprobe, > > > > adn kprobes. Eventually this will replace the > > > > kretprobe (e.g. kprobe + rethook = kretprobe), but > > > > at this moment, this is just a additional hook. > > > > > > this looks similar to the code kretprobe is using now > > > > Yes, I've mostly re-typed the code :) > > > > > would it make sense to incrementaly change current code to provide > > > this rethook interface? instead of big switch of current kretprobe > > > to kprobe + new rethook interface in future? > > > > Would you mean modifying the kretprobe instance code to provide > > similar one, and rename it at some point? > > My original idea is to keep the current kretprobe code and build > > up the similar one, and switch to it at some point. Actually, > > I don't want to change the current kretprobe interface itself, > > but the backend will be changed. For example, current kretprobe > > has below interface. > > > > struct kretprobe { > > struct kprobe kp; > > kretprobe_handler_t handler; > > kretprobe_handler_t entry_handler; > > int maxactive; > > int nmissed; > > size_t data_size; > > struct freelist_head freelist; > > struct kretprobe_holder *rph; > > }; > > > > My idea is switching it to below. > > > > struct kretprobe { > > struct kprobe kp; > > kretprobe_handler_t handler; > > kretprobe_handler_t entry_handler; > > int maxactive; > > int nmissed; > > size_t data_size; > > struct rethook *rethook; > > }; > > looks good, will this be a lot of changes? Yes and no, we can easily replace the kretprobe generic trampoline callback (since it almost same, and have same feature), but it also needs to update per-arch kretprobe trampoline to rethook trampoline. > could you include it in the patchset? Let me try, but since it involves many archs (which support kretprobes) it may take a time to be merged. Thank you, > > thanks, > jirka > > > > > Of course 'kretprobe_instance' may need to be changed... > > > > struct kretprobe_instance { > > struct rethook_node; > > char data[]; > > }; > > > > But even though, since there is 'get_kretprobe(ri)' wrapper, user > > will be able to access the 'struct kretprobe' from kretprobe_instance > > transparently. > > > > Thank you, > > > > > > -- > > Masami Hiramatsu > > > -- Masami Hiramatsu