Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1310315rwo; Wed, 2 Aug 2023 11:54:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlFVW/HyKjQL5p2Y/cJRCXfYaiCVrCKvpTnQn9XQ7SA7f+ffb+xy5iowFKUOV9OTx8zeTKK/ X-Received: by 2002:a17:907:760d:b0:99b:cdfd:fb44 with SMTP id jx13-20020a170907760d00b0099bcdfdfb44mr8017225ejc.9.1691002487405; Wed, 02 Aug 2023 11:54:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691002487; cv=none; d=google.com; s=arc-20160816; b=uJgVucd1yzrMrT7XpxFUyb7IOLkKlJoIdyqHNvuoDPtgFDTyAo7V98dPluBJimck8K mSHomU+QSej0D85bdSoMR2Ww+Uwct5OOQNY7S4gNbSyc+BujNcDrBMF89Pd79NdRKasR gK7I/w0/FDSHRzhJyidbmh0QOXDwNQVJVMHg/OOa7OX/wLDrxCAl7KvMdJ4y7Uz1yRnT SxD38sMDMQSbZ7AhMnk2BzGpmmKADrJdtRBYLG4mE7UOo/lGMfk9qy1W+fFwJhPXhk7l wTk1vUL6yNTlojp2WyXMffx6OHLlx+JmZNJGP3XcKxeCH8v36DV6GO9xL0bhA6Uzxyni HdwA== 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=Ts9PjQF+d06CnZ4NHHtCvTIMUe8RTgL9534A2fuPK1U=; fh=y1I6zzbZ2HwaZOvGQYXtUilX/9pq3h08t87iFgDw4LE=; b=pV41F2dnb1U4G6QoWpD9Sbern0za6Nyfl/AsvfjTf424Nklr3xRdWzSVp0h4zoUjqf 3idT9EWiUWkOy5e6nhWtB9cM7kgzT6u8FSmAn+/e+RC7m3v2Lu6TKhr/wUHXdRwNDgxi syo/f6V5C+8Nb9hBMDfS+5+62HrgGXlQvuxqIBFHrBqhp7Q4+sTAnMMEB3j9hS+Y+sY1 3G7HtR4Z0YGB+3k4oJ2ZU268tIL8V07iz7pJPgPO9+VIfCmkArI1pq4svgpgqgVue9kS VfDrHnOIHAlyhWUwfXLVUihOYvY7DeGAea32MqYWUjfDVdyc0Yo3/K1N5daD+mqK65y2 HGDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=l1Sq1p2C; 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 p26-20020a17090635da00b0098e1627c0e4si7626873ejb.777.2023.08.02.11.54.22; Wed, 02 Aug 2023 11:54:47 -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=l1Sq1p2C; 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 S233769AbjHBSY2 (ORCPT + 99 others); Wed, 2 Aug 2023 14:24:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbjHBSY0 (ORCPT ); Wed, 2 Aug 2023 14:24:26 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC8611717; Wed, 2 Aug 2023 11:24:25 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2b9c66e2e36so1834231fa.1; Wed, 02 Aug 2023 11:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691000664; x=1691605464; 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=Ts9PjQF+d06CnZ4NHHtCvTIMUe8RTgL9534A2fuPK1U=; b=l1Sq1p2CrCPnOa7VKOCx+PpzLFNmbxuPIdrniaIMzhAo+hX2a7fAWRdhP1rwiGGNl9 ZzJgNaoctxHOGc0EoE2aGQmJZ4v1xYQx9R35X7nwrZAjxtCEBJcnXiazHrjLIxkffhem gFz+sFdMXDhvybJi8su0Kt4vJd4LXC2TP02FbggLHPGmnhUeVuhWle/Fd17cMFZkmhnf J/g1SsMbHFJ0Qgwh6QCIah8pOp/XqWdEf4DV9UZXBuZhuPDmVX1duuKqbpwurxuyaXlj /+B9RM3Jm+kLdaDsKlv5R2RmzScx5PNYyPIiemZj4rmUcW9Pifntv5bEqtFm5+t5rsyT v+tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691000664; x=1691605464; 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=Ts9PjQF+d06CnZ4NHHtCvTIMUe8RTgL9534A2fuPK1U=; b=WXQrXUmRgwn3EpDFjq31vT4JCNBAvY82OHVNJV5ofbommxlypKoRmEc8Z3CVYBBGQE Thdv6yuq9JCGLm6nWgF9zkbjRkX5ikouceqpi5Zkjg1v535MMC7NnuI70eEE/IujdQjx D4nm/irwzufGRkd6xHTgsECKc/BpaVj/aw624GFRHc/mIszwwcOTjds7euTLvHBuBdmU go6iIwUi+Ao+WB7anCrLXfbVe+w1SI4fAkLKQiCwHIo+Ect8mnw/BliCfDGfKc0jq5Sc +WBtHEIMbFGN0ziU6punra22RQF68ci8XD9xfhg/PH0H2Fyx/GV6y1V91zGoXF/IXRvY eKsA== X-Gm-Message-State: ABy/qLYAmerzgrGQQ+mGLJ5mCEqEcTDBjQodFaYehxE52bZT+MhcVKIs VCwtC68skr9/i6oNlMDhlOfox3BxnT9UhVzBIdc= X-Received: by 2002:a2e:b98b:0:b0:2b9:90fb:3502 with SMTP id p11-20020a2eb98b000000b002b990fb3502mr2441722ljp.9.1691000663641; Wed, 02 Aug 2023 11:24:23 -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> In-Reply-To: <20230802225634.f520080cd9de759d687a2b0a@kernel.org> From: Alexei Starovoitov Date: Wed, 2 Aug 2023 11:24:12 -0700 Message-ID: Subject: Re: [PATCH v4 3/9] bpf/btf: Add a function to search a member of a struct/union To: Masami Hiramatsu Cc: Steven Rostedt , 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_NONE,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 6:56=E2=80=AFAM Masami Hiramatsu wrote: > > On Tue, 1 Aug 2023 20:40:54 -0400 > Steven Rostedt wrote: > > > On Wed, 2 Aug 2023 09:21:46 +0900 > > Masami Hiramatsu (Google) wrote: > > > > > > Then use kprobes. When I asked Masami what the difference between f= probes > > > > and kprobes was, he told me that it would be that it would no longe= r rely > > > > on the slower FTRACE_WITH_REGS. But currently, it still does. > > > > > > kprobes needs to keep using pt_regs because software-breakpoint excep= tion > > > handler gets that. And fprobe is used for bpf multi-kprobe interface, > > > but I think it can be optional. > > > > > > So until user-land tool supports the ftrace_regs, you can just disabl= e > > > using fprobes if CONFIG_DYNAMIC_FTRACE_WITH_REGS=3Dn > > > > I'm confused. I asked about the difference between kprobes on ftrace > > and fprobes, and you said it was to get rid of the requirement of > > FTRACE_WITH_REGS. > > > > https://lore.kernel.org/all/20230120205535.98998636329ca4d5f8325bc3@ke= rnel.org/ > > Yes, it is for enabling fprobe (and fprobe-event) on more architectures. > I don't think it's possible to change everything at once. So, it will be > changed step by step. At the first step, I will replace pt_regs with > ftrace_regs, and make bpf_trace.c and fprobe_event depends on > FTRACE_WITH_REGS. > > At this point, we can split the problem into two, how to move bpf on > ftrace_regs and how to move fprobe-event on ftrace_regs. fprobe-event > change is not hard because it is closing in the kernel and I can do it. > But for BPF, I need to ask BPF user-land tools to support ftrace_regs. > > > > > > > > > Then you can safely use > > > > > > struct pt_regs *regs =3D ftrace_get_regs(fregs); > > > > > > I think we can just replace the CONFIG_FPROBE ifdefs with > > > CONFIG_DYNAMIC_FTRACE_WITH_REGS in kernel/trace/bpf_trace.c > > > And that will be the first version of using ftrace_regs in fprobe. > > > > But it is still slow. The FTRACE_WITH_REGS gives us the full pt_regs > > and saves all registers including flags, which is a very slow operation > > (and noticeable in profilers). > > Yes, to solve this part, we need to work with BPF user-land people. > I guess the BPF is accessing registers from pt_regs with fixed offset > which is calculated from pt_regs layout in the user-space. This is a non starter. bpf progs expect arch dependent 'struct pt_regs *' and we cannot change tha= t.