Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3309737pxb; Mon, 24 Jan 2022 07:03:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2wYnMqurCyFtpJboRP2hUaf1qQao8/2X1LMDWfTqSKMryMhAqc7nv+0lsPw29/fNcIBMF X-Received: by 2002:a17:902:bb83:b0:14a:30c5:4176 with SMTP id m3-20020a170902bb8300b0014a30c54176mr14374505pls.67.1643036617042; Mon, 24 Jan 2022 07:03:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643036617; cv=none; d=google.com; s=arc-20160816; b=z4w1BFoXIRydCuo90Yz6ikiIVyDlXbaNqqmgw2wQoByr81wbd5yh+RAPin5GfRWs0u yL0Z6tDaEOqV1tUL9v4M13gDaJQp2sr8lEFw3VgHrIu+M7jm9bWePH9sXc4vaJZA36J7 Wiatwx000hTYWpDIR++HeFvNPF7HLRvw+CcM6qb5le+M9Dbuhjp86fW2L1INIEvmC8IQ SYq6YzDY0pCNaS/rdb6x43ytIpcEQHX0nY1I9iqKSDVQF4ZDhA6H2HbQm+/wjbqGHe7z M6mHtCvnEu+qHV0tbqcyLmkELI9ulC4f+qitfPesq7lsvYthvqQxD6r4zSI0P5QU7MZm lw/A== 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=WO5w67scXtmUbA2INaUsY8Qoz4NF3rEncpDeStYNvAo=; b=W/nUf94uBcvLk/1ljmBKl4/NyLspyoyFjqzTgP31hKjy1Jz2qSVzNBjT3GzODYRY90 wlV/YynzfHPQAzYj82mI0vWc3mdZd3TLFRZNUQuJCBHw5/6bzGa3xRxZKR6YhqgDNNv5 z7heS0xST5OEsPsqfYslPHajR9kHwnfIc9Tpem/9EgqKR8/rCK8Ymkq3pQ5IqFLBz1ct gbt0ujW+V8mcHXGGymFuM1GhpT2zS05/aS188gICnBfK7rz4fe2YrAg+yPq7hIvMXnwL AmKG1r1xBeaIjU65rr7Y4Q0R+PVVAjrGQr9xq6uK8H+fBkdyUSO7pXo9K5xBAOK9zqWK ZB8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="lBBXF/Gu"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si15238270pfj.178.2022.01.24.07.03.10; Mon, 24 Jan 2022 07:03:37 -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=@kernel.org header.s=k20201202 header.b="lBBXF/Gu"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240558AbiAXAYP (ORCPT + 99 others); Sun, 23 Jan 2022 19:24:15 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:53184 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235008AbiAXAYO (ORCPT ); Sun, 23 Jan 2022 19:24:14 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id 69CB2B80E51; Mon, 24 Jan 2022 00:24:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 440D9C340E3; Mon, 24 Jan 2022 00:24:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642983852; bh=P/lqko8P7xtknEbgcLI6VJ2sVk31CTsnfJpTAf51kzc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lBBXF/Gus2uXDKe22zqfrtIXigjUonbKhX2TOoaBF4bAOru3YrdFtiaLJHLPs5e93 KiYidh5zf400FOhYUOfXvD0u187I6gN6oT3i1s/cmvoUZp8OSb2C3glzYdGpXvgjt8 UHW/cIV8Pv+37vv1EIAFg34u+si0S8d8H+CHLVkrjPvvx0yuQNAeynDDcsIZlmJo8I mPPdcMSyKY/BADiWiQs/qQtpIOxKA2eu10ZWzhL7NvXnQawm43Vl/UkwCeZgVcfQD2 eA8zMx/i2Arw0Ch+v/o3FnaFYI1WwBDj9xQZL1qWhZG7ooTKnU9+rFZi2yYShsvKBu 1N6R/xIR7/5vQ== Date: Mon, 24 Jan 2022 09:24:05 +0900 From: Masami Hiramatsu To: Jiri Olsa Cc: Andrii Nakryiko , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Networking , bpf , 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 v3 0/9] fprobe: Introduce fprobe function entry/exit probe Message-Id: <20220124092405.665e9e0fc3ce14b16a1a9fcf@kernel.org> In-Reply-To: References: <164260419349.657731.13913104835063027148.stgit@devnote2> <20220121135510.7cfa6540e31824aa39b1c1b8@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 24 Jan 2022 00:50:13 +0100 Jiri Olsa wrote: > On Fri, Jan 21, 2022 at 09:29:00AM -0800, Andrii Nakryiko wrote: > > On Thu, Jan 20, 2022 at 8:55 PM Masami Hiramatsu wrote: > > > > > > On Thu, 20 Jan 2022 14:24:15 -0800 > > > Andrii Nakryiko wrote: > > > > > > > On Wed, Jan 19, 2022 at 6:56 AM Masami Hiramatsu wrote: > > > > > > > > > > Hello Jiri, > > > > > > > > > > Here is the 3rd version of fprobe. I added some comments and > > > > > fixed some issues. But I still saw some problems when I add > > > > > your selftest patches. > > > > > > > > > > This series introduces the fprobe, the function entry/exit probe > > > > > with multiple probe point support. This also introduces the rethook > > > > > for hooking function return as same as kretprobe does. This > > > > > abstraction will help us to generalize the fgraph tracer, > > > > > because we can just switch it from rethook in fprobe, depending > > > > > on the kernel configuration. > > > > > > > > > > The patch [1/9] and [7/9] are from Jiri's series[1]. Other libbpf > > > > > patches will not be affected by this change. > > > > > > > > > > [1] https://lore.kernel.org/all/20220104080943.113249-1-jolsa@kernel.org/T/#u > > > > > > > > > > However, when I applied all other patches on top of this series, > > > > > I saw the "#8 bpf_cookie" test case has been stacked (maybe related > > > > > to the bpf_cookie issue which Andrii and Jiri talked?) And when I > > > > > remove the last selftest patch[2], the selftest stopped at "#112 > > > > > raw_tp_test_run". > > > > > > > > > > [2] https://lore.kernel.org/all/20220104080943.113249-1-jolsa@kernel.org/T/#m242d2b3a3775eeb5baba322424b15901e5e78483 > > > > > > > > > > Note that I used tools/testing/selftests/bpf/vmtest.sh to check it. > > > > > > > > > > This added 2 more out-of-tree patches. [8/9] is for adding wildcard > > > > > support to the sample program, [9/9] is a testing patch for replacing > > > > > kretprobe trampoline with rethook. > > > > > According to this work, I noticed that using rethook in kretprobe > > > > > needs 2 steps. > > > > > 1. port the rethook on all architectures which supports kretprobes. > > > > > (some arch requires CONFIG_KPROBES for rethook) > > > > > 2. replace kretprobe trampoline with rethook for all archs, at once. > > > > > This must be done by one treewide patch. > > > > > > > > > > Anyway, I'll do the kretprobe update in the next step as another series. > > > > > (This testing patch is just for confirming the rethook is correctly > > > > > implemented.) > > > > > > > > > > BTW, on the x86, ftrace (with fentry) location address is same as > > > > > symbol address. But on other archs, it will be different (e.g. arm64 > > > > > will need 2 instructions to save link-register and call ftrace, the > > > > > 2nd instruction will be the ftrace location.) > > > > > Does libbpf correctly handle it? > > hm, I'm probably missing something, but should this be handled by arm > specific kernel code? user passes whatever is found in kallsyms, right? In x86, fentry nop is always placed at the first instruction of the function, but the other arches couldn't do that if they use LR (link register) for storing return address instead of stack. E.g. arm64 saves lr and call the ftrace. Then ftrace location address of a function is not the symbol address. Anyway, I updated fprobe to handle those cases. I also found some issues on rethook, so let me update the series again. > > > > > > > > libbpf doesn't do anything there. The interface for kprobe is based on > > > > function name and kernel performs name lookups internally to resolve > > > > IP. For fentry it's similar (kernel handles IP resolution), but > > > > instead of function name we specify BTF ID of a function type. > > > > > > Hmm, according to Jiri's original patch, it seems to pass an array of > > > addresses. So I thought that has been resolved by libbpf. > > > > > > + struct { > > > + __aligned_u64 addrs; > > > > I think this is a pointer to an array of pointers to zero-terminated C strings > > I used direct addresses, because bpftrace already has them, so there was > no point passing strings, I cann add support for that So now both direct address array or symbol array are OK. Thank you, -- Masami Hiramatsu