From patchwork Fri Apr 8 20:34:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Nakryiko X-Patchwork-Id: 12807189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E208C433EF for ; Fri, 8 Apr 2022 20:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233872AbiDHUgt convert rfc822-to-8bit (ORCPT ); Fri, 8 Apr 2022 16:36:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232768AbiDHUgs (ORCPT ); Fri, 8 Apr 2022 16:36:48 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73BA0105AAB for ; Fri, 8 Apr 2022 13:34:44 -0700 (PDT) Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 238JaCtF011188 for ; Fri, 8 Apr 2022 13:34:43 -0700 Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3fat3r96xn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Fri, 08 Apr 2022 13:34:43 -0700 Received: from twshared13315.14.prn3.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:21d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 8 Apr 2022 13:34:43 -0700 Received: by devbig019.vll3.facebook.com (Postfix, from userid 137359) id 7193116FC5A10; Fri, 8 Apr 2022 13:34:35 -0700 (PDT) From: Andrii Nakryiko To: , , CC: , Subject: [PATCH bpf-next 0/3] Add target-less tracing SEC() definitions Date: Fri, 8 Apr 2022 13:34:30 -0700 Message-ID: <20220408203433.2988727-1-andrii@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-GUID: zcJq9jebmP_g86Mj5sz58Nnd2kgpeAdC X-Proofpoint-ORIG-GUID: zcJq9jebmP_g86Mj5sz58Nnd2kgpeAdC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-04-08_08,2022-04-08_01,2022-02-23_01 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Allow specifying "target-less" SEC() definitions for tracing BPF programs, both non-BTF-backed (kprobes, tracepoints, raw tracepoints) and BTF-backed (fentry/fexit, iter, lsm, etc). There are various situations where attach target cannot be known at compilation time, so libbpf's insistence on specifying something leads to users having to add random test like SEC("kprobe/whatever") and then specifying correct target at runtime using APIs like bpf_program__attach_kprobe(). So this patch set improves ergonomics by allowing simple SEC() definitions that define BPF program type and nothing else. Such programs won't be auto-attachable, of course, but they also won't fail skeleton auto-attachment, just like we do this for uprobes. Andrii Nakryiko (3): libbpf: allow "incomplete" basic tracing SEC() definitions libbpf: support target-less SEC() definitions for BTF-backed programs selftests/bpf: use target-less SEC() definitions in various tests tools/lib/bpf/libbpf.c | 118 ++++++++++++------ .../selftests/bpf/prog_tests/attach_probe.c | 10 ++ .../bpf/prog_tests/kprobe_multi_test.c | 14 +-- .../selftests/bpf/progs/kprobe_multi.c | 14 +++ .../selftests/bpf/progs/test_attach_probe.c | 23 +++- .../selftests/bpf/progs/test_module_attach.c | 2 +- 6 files changed, 135 insertions(+), 46 deletions(-)