Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1481589rwo; Wed, 2 Aug 2023 15:05:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlHEWQ3VHePXUti1lA1+lQsjUT7wYKhXAtHhV6dLASv+1NWfF2siBY1S01SNbv2S5gUEq4q+ X-Received: by 2002:a05:6e02:1c2d:b0:349:296c:9b8a with SMTP id m13-20020a056e021c2d00b00349296c9b8amr10607182ilh.2.1691013935930; Wed, 02 Aug 2023 15:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691013935; cv=none; d=google.com; s=arc-20160816; b=PXAjy+NNnV4cd7rd6TsqpHei+rbDwsL5c72qrcZrRhFge2g7NiA8TD5KyVzfFlUIxV uMMY1vEce9CNiiZFi9Vmx9b2MI94Lhi2jXiZWx1WHZOLWBaJe9tK4ILbYkNmuiba6iGm BjcjvEzpH2zdAIy5BCnRCcq55YaVACMEcoT9fZYtXnE7A+xm0FnaKV4tIgAG9BUiRv7g d83XK3gRhaBI6o2pVGxYypKl0zPClWAkv8CTrO6GV4QX1ejrvhL2FB3N0xjQcL37U4Z1 L/U6n8SMYGL/z9zQAW+aBzD4eHLyGbXWRwikAjsqjm+pPyfMXvIv73eRvMK/skHeEWaJ mAXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=0utdvIhX3amp8utvvS+BAk3g+AmsUNViXEgeD6WJsZ4=; fh=uCWdrVl2eOEjuijMA5Y+8irSBS2z+K896sRRGoC2NAk=; b=gvhGUg0rFvHyDx3pQvKkSKxNnEpneGDFUW0qMlIXNaLAgigumiJGe6RTeWPdv2IBO9 dqIE9tFYT0EUm6k0ggmxuyZ9drF35kNZ8UpTq+dQBC/fXUbjyXZZsvvaRJaddKEQ5IIk gpCfsRFATb1vQUSFvMoDm9mtrkdFOakCqUviXp9KP9Q9H57Bnf1LYJDo1MIsny0rKRNs MRLIHX30yih5AytFNID6sIBpAzl3ICqTTh9Teu2kvdyg0/2DUTQu4ksw1RMvn+2isgIQ AvCvSaW/rKNx3yAcwyEHVa0/PU5BcOIT0cquL6OC8Bu/UM4L4wjy8qAJ3MY10qhG8LrL nrgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EuhMrUrx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pf18-20020a17090b1d9200b00263c23a5693si1813204pjb.13.2023.08.02.15.05.18; Wed, 02 Aug 2023 15:05:35 -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; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EuhMrUrx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232585AbjHBV3H (ORCPT + 99 others); Wed, 2 Aug 2023 17:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231453AbjHBV3F (ORCPT ); Wed, 2 Aug 2023 17:29:05 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AF781734; Wed, 2 Aug 2023 14:29:04 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2b9b9f0387dso4070511fa.0; Wed, 02 Aug 2023 14:29:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691011742; x=1691616542; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0utdvIhX3amp8utvvS+BAk3g+AmsUNViXEgeD6WJsZ4=; b=EuhMrUrxRGKAFB4uDxWeh2sbofFgEXon1HQFmho2U6hPIm9c7pGsR0PFFr1ShuhOGM XxjCspEy/2Dr1X99sL97YkjEFgfNeTM9rNAMfIv4JhwKXKCkoj2acZXhC2aOQv5a1HHc Sp+KGaSYtC5xgo9+9S7xBiwA1uzFw6Oc6D1zSl6tc+C/+iLgt0JzaKNn6Jt5V4/QAUFW FBNqDFrqY5FlQeRInStqV2gLHL31JWId5EBr79DB6E7yMBtdmDqrJEir3PNoJOcdVg0z buRHv2SgyvnBfAyf4vGmxqa9lkEo07D+K4+YIQNoVOxWpIKXlbFGLreBFtRAcnzDvOzS R9ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691011742; x=1691616542; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0utdvIhX3amp8utvvS+BAk3g+AmsUNViXEgeD6WJsZ4=; b=lcGAvyb7veiTSlYZsqwVtS+55MMUxE15U8aha8mnXk7OhfKvgeBNvqjpxyJ6RCSdwf IPnsgPREpGuPIY80gFyVZu7sZ/q2C69ogKL3L+ba6HvNPV5pFcimbCqQh1Yzp3lF0QnY 3O4wgAQFPV55GRWHNl9dWcD4Gb2zuFP6XYstVnpVUX6J0zwg1MBtKUkm0EJeb1jvFLT1 GnKss3LBisrtZ2ag+//AkcoYWNegfgsOL6SlqBziuWBsgi70zD7rOJ70MSR1gqqrScG6 eM+DDbsjgSi269UBXJp1ZmdE62SkN5gBmhsbcCjKMYKbG9yWli+NMH69sEQeLw1SqAuy dCIw== X-Gm-Message-State: ABy/qLbQuiuLB1Sko4Cm3Je6ydWWRcRwsxe+51jFC7Ud681UDHPsOiJb KUpucu2m5yB28CBWppDsY/u88iYAO78aaWZgO98= X-Received: by 2002:a2e:959a:0:b0:2b6:e283:32cb with SMTP id w26-20020a2e959a000000b002b6e28332cbmr5472066ljh.23.1691011742309; Wed, 02 Aug 2023 14:29:02 -0700 (PDT) MIME-Version: 1.0 References: <169078860386.173706.3091034523220945605.stgit@devnote2> <169078863449.173706.2322042687021909241.stgit@devnote2> <20230801085724.9bb07d2c82e5b6c6a6606848@kernel.org> <20230802000228.158f1bd605e497351611739e@kernel.org> <20230801112036.0d4ee60d@gandalf.local.home> <20230801113240.4e625020@gandalf.local.home> <20230801190920.7a1abfd5@gandalf.local.home> <20230802092146.9bda5e49528e6988ab97899c@kernel.org> <20230801204054.3884688e@rorschach.local.home> <20230802225634.f520080cd9de759d687a2b0a@kernel.org> <20230802143845.3ce6ed61@gandalf.local.home> <20230802161220.579b2220@gandalf.local.home> In-Reply-To: <20230802161220.579b2220@gandalf.local.home> From: Alexei Starovoitov Date: Wed, 2 Aug 2023 14:28:50 -0700 Message-ID: Subject: Re: [PATCH v4 3/9] bpf/btf: Add a function to search a member of a struct/union To: Steven Rostedt Cc: Masami Hiramatsu , linux-trace-kernel@vger.kernel.org, LKML , Martin KaFai Lau , bpf , Sven Schnelle , Alexei Starovoitov , Jiri Olsa , Arnaldo Carvalho de Melo , Daniel Borkmann , Alan Maguire , Mark Rutland , Florent Revest , Peter Zijlstra , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,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 Wed, Aug 2, 2023 at 1:12=E2=80=AFPM Steven Rostedt = wrote: > > On Wed, 2 Aug 2023 12:48:14 -0700 > Alexei Starovoitov wrote: > > > On Wed, Aug 2, 2023 at 11:38=E2=80=AFAM Steven Rostedt wrote: > > > > > > On Wed, 2 Aug 2023 11:24:12 -0700 > > > Alexei Starovoitov wrote: > > > > > > > This is a non starter. > > > > bpf progs expect arch dependent 'struct pt_regs *' and we cannot ch= ange that. > > > > > > If the progs are compiled into native code, isn't there optimizations= that > > > could be done? That is, if ftrace_regs is available, and the bpf prog= ram is > > > just using the subset of pt_regs, is it possible that it could be com= piled > > > to use ftrace_regs? > > > > > > Forgive my ignorance on how BPF programs turn into executables when r= unning > > > in the kernel. > > > > Right. It's possible for the verifier to do an offset rewrite, > > forbid certain access, always return 0 on load from certain offset, > > and so on. > > It's all non trivial amount of work. > > ftrace_partial_regs() from ftrace_regs into pt_regs is so much simpler. > > Sure, and the copy could be the solution we have in the near future, but = if > we could optimize it in the future, then perhaps it would be worth doing = it. > > Also, how are the bpf programs referencing the pt_regs? Typically through macros that abstract arch differences away in tools/lib/bpf/bpf_tracing.h PT_REGS_PARM1 PT_REGS_PARM1_CORE PT_REGS_PARM1_SYSCALL pt_regs at syscall entry is special, since syscall calling convention is different from the rest of the kernel. ftrace_regs cannot help with that either. > Could a ftrace_regs > API be added too? Potentially yes, but I don't see the value. bpf users are slowly migrating to fentry/fexit that has accurate args and return value and much faster. kprobes are still heavily used, of course. multi-kprobe (with fprobe_ips underneath) is a new addition that is also very important to some users. > If the verifier sees that the program is using > ftrace_regs, it could then use the lighter weight fprobes for access, > otherwise it falls back to the kprobe version. > > -- Steve