Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2767170pxb; Thu, 3 Feb 2022 13:59:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJw3SuPce0e73gVIYF7Ar3ExhYN/inAyr9uWKPe1q1jmTCpCHo+6v6Zrm1eUWGWQOX214iK0 X-Received: by 2002:a63:7103:: with SMTP id m3mr56639pgc.501.1643925553010; Thu, 03 Feb 2022 13:59:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643925552; cv=none; d=google.com; s=arc-20160816; b=j7hqPDAAJWXaXP0EPm4HykJoLQJafKDbnXuWoX93H4lqWuebgvnSjkQ1mTq0tSPXom eTPPyvasYGt5O3WEBB8pHDzRbjn1qGvLHakdCUGl38e0+sakvH//xDtS2atndq37jzlG H45XF+DZ8sHtkWlj1q+7Di57m7QtsGDbh1YeVcltFt4t77bbvXgyfpI+2A2sYnTlSQmQ vdTFOx0Za8iyczqLYXelfc+PEzaYIkrru8wh8CPY9OBaxWBMejp8/KdJtlUi94u7UvBI m3ZbM7MNDCjFtTOuXtKy0DaYbiSOk1NDT2unu7v2jsJndmiAehAqpWgzVE9ZS3bDiq+e VxGQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=eoBEdHsWn1QD68AtpyuWojbCmpscK/IojyHyc83t4H4=; b=j70v8HpFXJJiV2UI4kOdMlgebGx40FLtBzl3z8G2EtesXnT5i1i3H1AxdxFa5IlnYy 88Jh3ZBMdcbCYgeLZe3y2DxeWTgM0bgUkSZg9/ND8U+98Gmsmwnk0SbD7fVJZFx+wIO3 bndNKDfrds3LCXUlvuPSbiko2YR6xZKa+rsvJUxmy+LjTG1Xp1UcpFQ0pttLnQcMN5B9 n9PegQ366y/Ycc1w2KHovwV7PnP91jQD7Dw9hWsmYkiHU1CraH6iswmeqImhbS9RSm3g o5HCE+4MXZSnbWqt+Nv3rJcjM/CW6+MWIMKjD8OSlO9PhJEyAAU4NS3m4gPUad1L0P1/ 2Q4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kyg41tsy; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j2si74436pfc.28.2022.02.03.13.59.00; Thu, 03 Feb 2022 13:59:12 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=Kyg41tsy; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240250AbiBBNxj (ORCPT + 99 others); Wed, 2 Feb 2022 08:53:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28169 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231912AbiBBNxh (ORCPT ); Wed, 2 Feb 2022 08:53:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643810017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=eoBEdHsWn1QD68AtpyuWojbCmpscK/IojyHyc83t4H4=; b=Kyg41tsyHLBnmnxineNG5CpHXa6hSr+hnUy8sC6uvTVhvLMsbVYiAruj36N1uX5ivhW51P 84VMPHNGbLV3XVHfF9zVJOWcLeNWQb/FX3s4S3y1mxPXDmUpNR4MKfEJItdHGj8/IhSeYC 0GyDzcDPEG8nE54WPTRFJCEg/Cmcsu8= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-336-2WYyn-caOOOLlLOdXne1vQ-1; Wed, 02 Feb 2022 08:53:35 -0500 X-MC-Unique: 2WYyn-caOOOLlLOdXne1vQ-1 Received: by mail-ed1-f72.google.com with SMTP id i22-20020a0564020f1600b00407b56326a2so10468143eda.18 for ; Wed, 02 Feb 2022 05:53:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eoBEdHsWn1QD68AtpyuWojbCmpscK/IojyHyc83t4H4=; b=dsPGl1FndY+06AjOA+uH1aXzvb/P9uMSva+4BSu4xYTCx3D1i4eIQHY0rThulY2pBt ATqM6230jzusRhhCamPX6vpzqAUE0f6xNX+OzV+DWIN31tWh5lDifSWrFPssr9hbmLfQ LwHaha31kdkynaoKy25+PkgXq8k3N4FGqaF+piGWW7HuF06FAhALjwlCXEUixjOKi+hP PYa+tLiv8Dpmsjcj8I6ja0oL9o7ADl/surgk83xvyiGq/POrenVv9EAdCVWyUPo0rQia SDwKERWkpVCalPdIGbster5tAZDpLg6Iy9K8E+rz0itvL+fbtdLP7vgiEcCpTJXS4CCL QR3w== X-Gm-Message-State: AOAM532ehq5kHvsII2Mcm/JgKkcgr3oOu7050bmuZBFSpZaxqInxFQ1r 9YJrgBpK5uK7CqqRNg/l3tdfYpr+h/EfsASpTED/I/sv8F9p3HG6fbBDpjxZpxkf3iGxMXBi31U SeHMt8QQe4k+C2qdfGewJt/wX X-Received: by 2002:a17:907:d04:: with SMTP id gn4mr20014765ejc.86.1643810014727; Wed, 02 Feb 2022 05:53:34 -0800 (PST) X-Received: by 2002:a17:907:d04:: with SMTP id gn4mr20014745ejc.86.1643810014525; Wed, 02 Feb 2022 05:53:34 -0800 (PST) Received: from krava.redhat.com (nat-pool-brq-u.redhat.com. [213.175.37.12]) by smtp.gmail.com with ESMTPSA id fn3sm15672986ejc.47.2022.02.02.05.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 05:53:34 -0800 (PST) From: Jiri Olsa X-Google-Original-From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, lkml , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Steven Rostedt , Jiri Olsa Subject: [PATCH 0/8] bpf: Add fprobe link Date: Wed, 2 Feb 2022 14:53:25 +0100 Message-Id: <20220202135333.190761-1-jolsa@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi, this patchset adds new link type BPF_LINK_TYPE_FPROBE that attaches kprobe program through fprobe API [1] instroduced by Masami. The fprobe API allows to attach probe on multiple functions at once very fast, because it works on top of ftrace. On the other hand this limits the probe point to the function entry or return. With bpftrace support I see following attach speed: # perf stat --null -r 5 ./src/bpftrace -e 'kprobe:x* { } i:ms:1 { exit(); } ' Attaching 2 probes... Attaching 3342 functions ... 1.4960 +- 0.0285 seconds time elapsed ( +- 1.91% ) Also available at: https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git bpf/fprobe_link thanks, jirka [1] https://lore.kernel.org/bpf/20220202162925.bd74e7970fc35cb4236eef48@kernel.org/T/#t --- Jiri Olsa (8): bpf: Add support to attach kprobe program with fprobe bpf: Add bpf_get_func_ip kprobe helper for fprobe link bpf: Add bpf_cookie support to fprobe libbpf: Add libbpf__kallsyms_parse function libbpf: Add bpf_link_create support for multi kprobes libbpf: Add bpf_program__attach_kprobe_opts for multi kprobes selftest/bpf: Add fprobe attach test selftest/bpf: Add fprobe test for bpf_cookie values include/linux/bpf.h | 2 + include/linux/bpf_types.h | 1 + include/uapi/linux/bpf.h | 14 +++++ kernel/bpf/syscall.c | 327 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- kernel/bpf/verifier.c | 19 +++++- kernel/trace/bpf_trace.c | 32 +++++++++- tools/include/uapi/linux/bpf.h | 14 +++++ tools/lib/bpf/bpf.c | 7 +++ tools/lib/bpf/bpf.h | 9 ++- tools/lib/bpf/libbpf.c | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- tools/lib/bpf/libbpf_internal.h | 5 ++ tools/testing/selftests/bpf/prog_tests/bpf_cookie.c | 73 ++++++++++++++++++++++ tools/testing/selftests/bpf/prog_tests/fprobe_test.c | 117 +++++++++++++++++++++++++++++++++++ tools/testing/selftests/bpf/progs/fprobe.c | 58 ++++++++++++++++++ tools/testing/selftests/bpf/progs/fprobe_bpf_cookie.c | 62 +++++++++++++++++++ 15 files changed, 902 insertions(+), 36 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/fprobe_test.c create mode 100644 tools/testing/selftests/bpf/progs/fprobe.c create mode 100644 tools/testing/selftests/bpf/progs/fprobe_bpf_cookie.c