Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1111996imw; Thu, 14 Jul 2022 17:55:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8FAJC9MMYDbx9udUMKlv8Ya//u1/b8zDZlWMPK81Tv98Pd6JbBIsBC94ek8SZbRbOFHpH X-Received: by 2002:a17:907:2cef:b0:72b:5b3e:3d7a with SMTP id hz15-20020a1709072cef00b0072b5b3e3d7amr11257401ejc.293.1657846504007; Thu, 14 Jul 2022 17:55:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657846504; cv=none; d=google.com; s=arc-20160816; b=BEA9yr8CEK2VnXkKoU1y5g5IfluYQ4i6UEDuU4IRvoMCJnkauSM+6tpCAru6EDdeFz 4nIpqo8RLOUelZA9sEdAYbaFQX+P+ETo/qYd+Zqagkz/0tdNiZAVWIyLhIsOP517V281 9eugW21tESfmSN+lJzBkYzMjzSY+lMbDV5IW9uWPfWOMFj4qRu+Q5EJQKW41qYEotaOV YdUxW1GIHtt4c8TYcaVZjwM5HQgrEc8obKkBZyflYLJiNQdSKk4ZLhKVang9Vl8acJMf p1O4OjotUxMfBN3LE0tKLPmikVWjqdMwRnZXQ5E8kxFn0cxsaGu07chCLdIHf5rgB6k+ 88Pw== 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=8R1PAiOcZKTwG2YpY4Gr36FF4OLYsfYIS0RJGYLd5vg=; b=rEc7ZQmDEbAOj6iPmrcVlfVQLmB/Zo1ImSJ6MDgQT8IHROOIyqO3t+IIgvQLOGwmtF utJ7laS4njd402e7tRgf+21spw4eVQcCXHzxgTHdBrppjvjqDVTRwiKXJUouTBQSk7MC x2yLeXfJGZ465AZDpVDAGwJQp70yxnCP7GW/HzlUNpSiMGioNgb0b6tNJeWThKtQ/O68 ZE5dfpWIYRS99wXWHoZ2bFKE0bXSWknqrDoLjn7l0aW5bCZ3d9Se1sugRT7Nk1gXIxlb u900DNmnsO3VsJMX8Loou7I0rHxKjSYiued0mUeXa9oddHm34Gxlm6quSAlZbUsaA1vo hSKw== 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 z22-20020a05640235d600b0043769e9d1bdsi4368041edc.467.2022.07.14.17.54.39; Thu, 14 Jul 2022 17:55:03 -0700 (PDT) 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 S239660AbiGOAsZ (ORCPT + 99 others); Thu, 14 Jul 2022 20:48:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232576AbiGOAsW (ORCPT ); Thu, 14 Jul 2022 20:48:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C51DC2E6B2; Thu, 14 Jul 2022 17:48:21 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 47EE7620D5; Fri, 15 Jul 2022 00:48:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 152F9C34114; Fri, 15 Jul 2022 00:48:18 +0000 (UTC) Date: Thu, 14 Jul 2022 20:48:17 -0400 From: Steven Rostedt To: Song Liu Cc: Song Liu , Networking , bpf , lkml , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Kernel Team , "jolsa@kernel.org" , "mhiramat@kernel.org" Subject: Re: [PATCH v2 bpf-next 3/5] ftrace: introduce FTRACE_OPS_FL_SHARE_IPMODIFY Message-ID: <20220714204817.2889e280@rorschach.local.home> In-Reply-To: References: <20220602193706.2607681-1-song@kernel.org> <20220602193706.2607681-4-song@kernel.org> <20220713203343.4997eb71@rorschach.local.home> 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 Fri, 15 Jul 2022 00:13:51 +0000 Song Liu wrote: > I think there is one more problem here. If we force all direct trampoline > set IPMODIFY, and remove the SHARE_IPMODIFY flag. It may cause confusion > and/or extra work here (__ftrace_hash_update_ipmodify). I'm saying that the caller (BPF) does not need to set IPMODIFY. Just change the ftrace.c to treat IPMODIFY the same as direct. In fact, the two should be mutually exclusive (from a ftrace point of view). That is, if DIRECT is set, then IPMODIFY must not be. Again, ftrace will take care of the accounting of if a rec has both IPMODIFY and DIRECT on it. > > Say __ftrace_hash_update_ipmodify() tries to attach an ops with IPMODIFY, > and found the rec already has IPMODIFY. At this point, we have to iterate > all ftrace ops (do_for_each_ftrace_op) to confirm whether the IPMODIFY is > from What I'm suggesting is that a DIRECT ops will never set IPMODIFY. Like I mentioned before, ftrace doesn't care if the direct trampoline modifies IP or not. All ftrace will do is ask the owner of the direct ops if it is safe to have an IP modify attached to it or not. And at the same time will tell the direct ops owner that it is adding an IPMODIFY ops such that it can take the appropriate actions. In other words, IPMODIFY on the rec means that it can not attach anything else with an IPMODIFY on it. The direct ops should only set the DIRECT flag. If an IPMODIFY ops is being added, if it already has an IPMODIFY then it will fail right there. If direct is set, then a loop for the direct ops will be done and the callback is made. If the direct ops is OK with the IPMODIFY then it will adjust itself to work with the IPMODIFY and the IPMODIFY will continue to be added (and then set the rec IPMODIFY flag). > > 1) a direct ops that can share IPMODIFY, or > 2) a direct ops that cannot share IPMODIFY, or > 3) another non-direct ops with IPMODIFY. > > For the 1), this attach works, while for 2) and 3), the attach doesn't work. > > OTOH, with current version (v2), we trust the direct ops to set or clear > IPMODIFY. rec with IPMODIFY makes it clear that it cannot share with another > ops with IPMODIFY. Then we don't have to iterate over all ftrace ops here. The only time an iterate should be done is if rec->flags is DIRECT and !IPMODIFY. > > Does this make sense? Did I miss some better solutions? Did I fill in the holes? ;-) -- Steve