Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp691018pxb; Fri, 14 Jan 2022 14:10:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzH01ozBjiOztx9G1PO/bsCdJYDiopYV0HlvWpr2mB65qhSSK+iBKgGL5kM1JYkYUlV88Xm X-Received: by 2002:a17:902:d716:b0:149:89cc:6b23 with SMTP id w22-20020a170902d71600b0014989cc6b23mr11345829ply.162.1642198216260; Fri, 14 Jan 2022 14:10:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642198216; cv=none; d=google.com; s=arc-20160816; b=Iq6dALqS8hoFJzP1gkZWj358jltsNL2PspxtpuhdNPGa0JhgI6A1C4wy4vQKmBCcz8 9doGOsLObzitSQxW8GTrUabOVLucxQom9hzOWGH+l9uhcoL2QEyzMzL7cD7xl3fxx6yC 4tR94nfK7uOsEzG7kSgIKDc3PdaEM+P/ni5zQ/pNpzxjHr+5mDbZJ1v1o2d2XXjzaAXl pQ+2XDBdU/uJChLVlOgoEkh07ZdxBW9BpMF87RZqAqHkDlh3Q71FpPKny0Eii/B50jLx kstmz9zYuiMzmRTZtSd5R4PTtVEX+Ews8PCIfwcVxVhSoybq9gpw48nrAM/GQ3GR11wP oSig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mq7Qsa4OmDK/Jlw1qDgigFZECUU5BuQWP0ItOaVJNWo=; b=UzMKW0cvUAqZH5R9FRCvR3rYyvxUiY5TCklL98t2ONIDad1L/5AbRjgNjFynFKm9Ke v02lh0n7Yz+i5RPa81uqmmRg8sNWnVOmEaRQvntLBxndw1TbahbYg2PDeW9HbUmURPyN RrezWvOtyDzN4fXHWh4FN5d4p4EMjFsT+ASBMw3MVyWnH1R97LPY+HxJxO71/ZqvcLUs p4dZF/PoA+jfhocvk6pcZVpCZsYiFfaF3N3PhqvA7jAJS/qjy2z81Ymg9bGDsxG3pi5c GVJNXcL0CkDRkR5bJjYnSRKhc0AW3aiHGctWPUxBKzOkDdUUkfauxKpjeA25hp1D1GdQ ZpOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZeucIdIg; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx17si8076884pjb.150.2022.01.14.14.10.03; Fri, 14 Jan 2022 14:10:16 -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=@redhat.com header.s=mimecast20190719 header.b=ZeucIdIg; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242660AbiANPSe (ORCPT + 99 others); Fri, 14 Jan 2022 10:18:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55759 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242959AbiANPST (ORCPT ); Fri, 14 Jan 2022 10:18:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642173498; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mq7Qsa4OmDK/Jlw1qDgigFZECUU5BuQWP0ItOaVJNWo=; b=ZeucIdIgmkF3cWpS9V0GN147mip9/F55mgfksqSQlqfGm4e5vdzVdhsoMyd1XlQIBfkRKd uoAeLztpyC7Kc6UK7GnhEIM3tY2t7CyMbgceFavhgOMhPAD2XUECKwNRruuQMKkVG4BLb0 +r48shTFmoQpcTe++Nbg3ZJa8Ln/Xk0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-144-6CJ-6FwWPaWasv5g_ttmSA-1; Fri, 14 Jan 2022 10:18:17 -0500 X-MC-Unique: 6CJ-6FwWPaWasv5g_ttmSA-1 Received: by mail-wr1-f72.google.com with SMTP id d24-20020adf9b98000000b001c7e34c40bbso1162236wrc.16 for ; Fri, 14 Jan 2022 07:18:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mq7Qsa4OmDK/Jlw1qDgigFZECUU5BuQWP0ItOaVJNWo=; b=fOBeoy7i/IOzOW7DdyV0ziF2fg0J52KWcrMAtsP/MpKT9XgA5gjaw4L77OkefC9ITz 8nKv4HRZJJ8MJ9guSEY9aOorzXU4RVHZOThe4w2pExDGoq/ir5pUCt3eAnVFCj3cPD5K kQWySXE6D2bk27sS3cynUvQUSEyiLvfoj47lwVuYaU/VhDZSQeUoFtAWoLUTSz3vDB1m nvnFFGlkn40QeT6OCbXhGcPcL3FPssvVoaDF9tBsDQfx4bmFL1Sez30T8jT6pzOcHdyQ hLPimX321uAnNe2t9EQBSiFEedPCZ6q9GbMQgrCWs+8y9WObKVgAs6ZWXdNlCZN1F837 NSLQ== X-Gm-Message-State: AOAM532fMSMnY8E6rZdketwcfvyIu0Tv/FJNKBJWEsdQcGkAbFFzHsFv mAJUtRUhwYbkTQZoqJ94O5eqqjexuQxBiTDrmFoNPwtBk2Qp1VBJn6/4xdVj0eKe7fofVYQ/B+R h56vK9B9+1GLitF4heCE0zL5g X-Received: by 2002:a50:a6ce:: with SMTP id f14mr9121093edc.105.1642173495967; Fri, 14 Jan 2022 07:18:15 -0800 (PST) X-Received: by 2002:a50:a6ce:: with SMTP id f14mr9121072edc.105.1642173495809; Fri, 14 Jan 2022 07:18:15 -0800 (PST) Received: from krava (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id u1sm2488013edp.19.2022.01.14.07.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jan 2022 07:18:15 -0800 (PST) Date: Fri, 14 Jan 2022 16:18:13 +0100 From: Jiri Olsa To: Masami Hiramatsu 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: References: <164199616622.1247129.783024987490980883.stgit@devnote2> <164199620208.1247129.13021391608719523669.stgit@devnote2> <20220113221532.c48abf7f56d29ba95dcb0dc6@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220113221532.c48abf7f56d29ba95dcb0dc6@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? could you include it in the patchset? 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 >