Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1669790rwo; Wed, 2 Aug 2023 19:27:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlFbuCCXsOgp4SvELkc/jzIVzeAK1sTnnhBwvipwwWMt25L2KKmftOSEifainIbnkCZ5lZ3U X-Received: by 2002:a17:906:104d:b0:987:fe18:1c56 with SMTP id j13-20020a170906104d00b00987fe181c56mr7373984ejj.47.1691029641806; Wed, 02 Aug 2023 19:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691029641; cv=none; d=google.com; s=arc-20160816; b=Nf3lPiEwWHrNLLUa8xP0Su9tVpC0QcqRtTgrWb12EyHwmM/FDf/XA4x6WLDKXHNPaK QxZ/1fMnLhvdfj2pJ+bJyba9yfZQWJ1SodbMWwGZb2f5e1PRjq43l24Y4xIlhP4DZlZw 7vUTgtedzb6pypia/1kP2oS85tTsehTJ3xw4aAqErJ/y//1bsTy8TMT1kaVWEjRiggS8 M961Up7iRTVeSQf6vU7xAkT1/HSpuGtL4v/otzVxZntHbRJ9hlUiyRt6WKnNIKb2Guz0 h54csLPQzXo1l68gWeReMoizVW907hC6fFVfSku16Yr4OlEzw4ATqaRt9MeSuQFS7tzV 3RkQ== 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=9PKRuoSa6OOJ2tlp+T7QERCw6flltPWH8hOTwUndPag=; fh=sYtt1HmrSwLgkXfLETfOhj4pptkxDfotPGQZYsiBsW4=; b=S19+ZBniP5MyUcTOsx5g7Xp67oXZ/8n4VBjJSC1Rz6lPGHDXkqIH1VrE1RAwqmc0Sf uJi4uivCJ8BsQJIfza94fy8ZqbRRAEj616p9Mp9o6fp6AUDJFHoM63ubFsrXN5eMEr+H Y30RZMvKu3i+coCL4bqL3ZMcmRvkk5LDxBf9HNPVCeSdVkgOTuBpMrNoI3OF5Sqi+iHP 1WgMaSPzfzI/03eS7lplQ0GPsjpky7twNjrUmXXkxcjwe/IDNsOcOFhdVye1xd18OZVG TMo8YVnjCrubXCnSzgiB1BLV6uG1kTYH1omp1jGRC3Y7TJvsMp7dN3ndhH+ENcRdBR3Z T4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u19FFhV2; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz21-20020a170906f2d500b0098718971f52si11283069ejb.87.2023.08.02.19.26.57; Wed, 02 Aug 2023 19:27:21 -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=@kernel.org header.s=k20201202 header.b=u19FFhV2; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231444AbjHCB6N (ORCPT + 99 others); Wed, 2 Aug 2023 21:58:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232700AbjHCB5w (ORCPT ); Wed, 2 Aug 2023 21:57:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04AA830EF; Wed, 2 Aug 2023 18:55:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9650161BAF; Thu, 3 Aug 2023 01:55:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9989EC433C7; Thu, 3 Aug 2023 01:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691027733; bh=8bcmBU6UJXfBBUjLouuDS8paEUI0aVBdp/2XqX+Gop4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=u19FFhV2TK+D+tVZD87Zm5hkMwHS8OoJgc7dVKX0fn9QT9ZTiwGReEZKV3JHR9syR LR76vtAlG1FQ/MK27TEEMQhswKRZ0eL8HARcPWkZTII4h1BlOSxRnhCLrMVF45VxdM kPyw7nK75ayI7lIE8UinDqMdIrS3F+xBspjiHKWd4qtcIzKq8Bh+YZnKGlTokzHFfx IqWBKLjCybEoggTKv58GcbuK/sEh4K6hLoiWcbjCsZ37ghpMhnrStkv+le+4bBzOlt cLPst9olh0Z1hrISOyfLooTy37ojSX7uSCc825cvCZHTHtJVlWr0aDVWJBW9xW9MG/ kuVX7cgU09BTw== Date: Thu, 3 Aug 2023 10:55:27 +0900 From: Masami Hiramatsu (Google) To: Florent Revest Cc: Steven Rostedt , Alexei Starovoitov , 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 , Peter Zijlstra , Thomas Gleixner Subject: Re: [PATCH v4 3/9] bpf/btf: Add a function to search a member of a struct/union Message-Id: <20230803105527.838017f58531af25c125f577@kernel.org> In-Reply-To: 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> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 Wed, 2 Aug 2023 17:47:03 +0200 Florent Revest wrote: > On Wed, Aug 2, 2023 at 3:56 PM 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 fprobes > > > > > and kprobes was, he told me that it would be that it would no longer rely > > > > > on the slower FTRACE_WITH_REGS. But currently, it still does. > > > > > > > > kprobes needs to keep using pt_regs because software-breakpoint exception > > > > 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 disable > > > > using fprobes if CONFIG_DYNAMIC_FTRACE_WITH_REGS=n > > > > > > 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@kernel.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. > > Ah! I finally found the branch where I had pushed my proof of concept > of fprobe with ftrace_regs... it's a few months old and I didn't get > it in a state such that it could be sent to the list but maybe this > can save you a little bit of lead time Masami :) (especially the bpf > and arm64 specific bits) > > https://github.com/FlorentRevest/linux/commits/bpf-arm-complete > > 08afb628c6e1 ("ftrace: Add a macro to forge an incomplete pt_regs from > a ftrace_regs") > 203e96fe1790 ("fprobe, rethook: Use struct ftrace_regs instead of > struct pt_regs") > 1a9e280b9b16 ("arm64,rethook,kprobes: Replace kretprobe with rethook on arm64") > 7751c6db9f9d ("bpf: Fix bpf get_func_ip() on arm64 multi-kprobe programs") > a10c49c0d717 ("selftests/bpf: Update the tests deny list on aarch64") Thanks for the work! I also pushed my patches on https://kernel.googlesource.com/pub/scm/linux/kernel/git/mhiramat/linux/+/refs/heads/topic/fprobe-ftrace-regs 628e6c19d7dc ("tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS") 311c98c29cfd ("fprobe: Use fprobe_regs in fprobe entry handler") This doesn't cover arm64 and rethook, but provides ftrace_regs optimized fprobe-event code, which uses a correct APIs for ftrace_regs. For the rethook we still need to provide 2 version for kretprobe(pt_regs) and fprobe(ftrace_regs). I think eventually we should replace the kretprobe with fprobe, but current rethook is tightly coupled with kretprobe and the kretprobe needs pt_regs. So, I would like to keep arm64 kretprobe impl, and add new rethook with ftrace_regs. Or, maybe we need these 2 configs intermediately. CONFIG_RETHOOK_WITH_REGS - in this case, kretprobe uses rethook CONFIG_RETHOOK_WITH_ARGS - in this case, kretprobe uses its own stack The problem is ftrace_regs only depends on CONFIG_DYNAMIC_FTRACE_WITH_*. Thank you, -- Masami Hiramatsu (Google)