Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp887869pxb; Sat, 16 Jan 2021 10:25:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYZw8fzoYFNqLBsKsU7Lqz4eyMDXDIoLPorkfMz8cEJFbFwFU30Z23DeHSm0a4A1XQAjTu X-Received: by 2002:a17:906:b002:: with SMTP id v2mr12770180ejy.531.1610821501087; Sat, 16 Jan 2021 10:25:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610821501; cv=none; d=google.com; s=arc-20160816; b=cM3jPZwAYNWLdkRJyb9N79RvZPdIP+eokjdXTikyDmSt0PK5wiPiQtAE6KXjOEWfKe uA3JMY7BzG9iTDz9WgduYvNX+ntSPMKvC+HJ1jnXSNskjrN/sFSedcqntQ0p8uoNRZKw SGIE3S5Syt8mGhBVePcREwQmZGydOZDvnsseL5fxtaMzN1xY4ca32Vg6mgdCBn9KTz6x bjKEJZL+hrcnkqvcBz+l0M5zQZzlgRVK1oLWOag6z8Ix8c4nlLJMJ17hQ9LLW68WBR3A Y9zJG7PhNxuun7qjsGkHllONkl/ruWND5mV//Ol4rNv90ZbHZWJd7anONk2K7uVxc3az YzXA== 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:date:subject:cc:to:from; bh=lHjW+leRrs6GWS14rKAV++F6v2qPAAfOYvuy4dpJHns=; b=N4oiA36uUVXZ8PWiMMZDOD1lOBHV+kE0jQ0DW1XvOeoGHi/ZuWboNfE/fo7nnpw51Z hFNoyZKcm6btAcn8l45nVZN2Z3DXaE7cyI1u7F0A/BT49KOp0kcMtXLEL3x5bk/DqHKB GnINYT7TAm0CGfarQWBPSoAOcDTR2N6DgeK8bVg+lWUQZUiPIAh4IVKFIo2HMkvpcNSd ARgKxhu2rLAIWJzlxtgWVAvei3jnOBOI4Bk+13jARgr1KRVravJ7KmP6tE0m+HKVsDv7 y1D8N0D+jtOWn45prAejA+YYG4JDUZF+xuBKOx5jxYS08P7wL7T8Am2tdRkG+j/bLa2/ NiPw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z24si627809eja.111.2021.01.16.10.24.37; Sat, 16 Jan 2021 10:25:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728065AbhAPSW5 (ORCPT + 99 others); Sat, 16 Jan 2021 13:22:57 -0500 Received: from foss.arm.com ([217.140.110.172]:56652 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbhAPSWw (ORCPT ); Sat, 16 Jan 2021 13:22:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 14F1AED1; Sat, 16 Jan 2021 10:22:07 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (e107158-lin.cambridge.arm.com [10.1.194.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B9AC73F70D; Sat, 16 Jan 2021 10:22:05 -0800 (PST) From: Qais Yousef To: netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Yonghong Song , Steven Rostedt , "Peter Zijlstra (Intel)" , linux-kernel@vger.kernel.org, Qais Yousef Subject: [PATCH v2 bpf-next 1/2] trace: bpf: Allow bpf to attach to bare tracepoints Date: Sat, 16 Jan 2021 18:21:32 +0000 Message-Id: <20210116182133.2286884-2-qais.yousef@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210116182133.2286884-1-qais.yousef@arm.com> References: <20210116182133.2286884-1-qais.yousef@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some subsystems only have bare tracepoints (a tracepoint with no associated trace event) to avoid the problem of trace events being an ABI that can't be changed. From bpf presepective, bare tracepoints are what it calls RAW_TRACEPOINT(). Since bpf assumed there's 1:1 mapping, it relied on hooking to DEFINE_EVENT() macro to create bpf mapping of the tracepoints. Since bare tracepoints use DECLARE_TRACE() to create the tracepoint, bpf had no knowledge about their existence. By teaching bpf_probe.h to parse DECLARE_TRACE() in a similar fashion to DEFINE_EVENT(), bpf can find and attach to the new raw tracepoints. Enabling that comes with the contract that changes to raw tracepoints don't constitute a regression if they break existing bpf programs. We need the ability to continue to morph and modify these raw tracepoints without worrying about any ABI. Update Documentation/bpf/bpf_design_QA.rst to document this contract. Signed-off-by: Qais Yousef --- Documentation/bpf/bpf_design_QA.rst | 6 ++++++ include/trace/bpf_probe.h | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Documentation/bpf/bpf_design_QA.rst b/Documentation/bpf/bpf_design_QA.rst index 2df7b067ab93..0e15f9b05c9d 100644 --- a/Documentation/bpf/bpf_design_QA.rst +++ b/Documentation/bpf/bpf_design_QA.rst @@ -208,6 +208,12 @@ data structures and compile with kernel internal headers. Both of these kernel internals are subject to change and can break with newer kernels such that the program needs to be adapted accordingly. +Q: Are tracepoints part of the stable ABI? +------------------------------------------ +A: NO. Tracepoints are tied to internal implementation details hence they are +subject to change and can break with newer kernels. BPF programs need to change +accordingly when this happens. + Q: How much stack space a BPF program uses? ------------------------------------------- A: Currently all program types are limited to 512 bytes of stack diff --git a/include/trace/bpf_probe.h b/include/trace/bpf_probe.h index cd74bffed5c6..a23be89119aa 100644 --- a/include/trace/bpf_probe.h +++ b/include/trace/bpf_probe.h @@ -55,8 +55,7 @@ /* tracepoints with more than 12 arguments will hit build error */ #define CAST_TO_U64(...) CONCATENATE(__CAST, COUNT_ARGS(__VA_ARGS__))(__VA_ARGS__) -#undef DECLARE_EVENT_CLASS -#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ +#define __BPF_DECLARE_TRACE(call, proto, args) \ static notrace void \ __bpf_trace_##call(void *__data, proto) \ { \ @@ -64,6 +63,10 @@ __bpf_trace_##call(void *__data, proto) \ CONCATENATE(bpf_trace_run, COUNT_ARGS(args))(prog, CAST_TO_U64(args)); \ } +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ + __BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args)) + /* * This part is compiled out, it is only here as a build time check * to make sure that if the tracepoint handling changes, the @@ -111,6 +114,11 @@ __DEFINE_EVENT(template, call, PARAMS(proto), PARAMS(args), size) #define DEFINE_EVENT_PRINT(template, name, proto, args, print) \ DEFINE_EVENT(template, name, PARAMS(proto), PARAMS(args)) +#undef DECLARE_TRACE +#define DECLARE_TRACE(call, proto, args) \ + __BPF_DECLARE_TRACE(call, PARAMS(proto), PARAMS(args)) \ + __DEFINE_EVENT(call, call, PARAMS(proto), PARAMS(args), 0) + #include TRACE_INCLUDE(TRACE_INCLUDE_FILE) #undef DEFINE_EVENT_WRITABLE -- 2.25.1