Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2471101pxb; Mon, 11 Jan 2021 10:24:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzG4ulChnZiCt8eUzTkUWhhE8S+UbH/LkXqkd83pEFPuhV0QQU4Odxi81uMdeE2PAf4Cy2J X-Received: by 2002:a17:906:d0c2:: with SMTP id bq2mr519936ejb.1.1610389463724; Mon, 11 Jan 2021 10:24:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610389463; cv=none; d=google.com; s=arc-20160816; b=elc0ja3porF5kyqCbcJsd0fBON5Dyhe5saBhRl4MOM+MFb043sGmlgS2/T+qYTriGq 7JzK9as9vJ2T1JnvMLAKrejxZqeX5ZG90+AI+b2glXVe5UrxpEauF2F2w2IIncLg8m8Z l3vXw7es3kkneZfMAt52rTKWCdDUK/J6CGRTdYne0AXR83y73wFQKeIRLqJIfsMQRwXB HpquswiSsSBH6c3klhUTo176n6zBdNkfCjH+3oYCns49FRkUBhdBeQ2UACD3H7otdNc2 t9LSd+zQnXq9gDYcBBvV/3RDzdawpkYNLoegrpKOEVvCIpxav8+Cv6/YSvNyc2cgpsIJ m3Wg== 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=4rAsS73uSdIld7D4Ghr/dyLBYMq0HCEebyUnDh/AsOE=; b=OO/UzOEJwxObx41ip9phVSczF5LCinTxl4lv4390DtsuappYRKfzVLNINu23cxOJ6o DlM0dZBSR5icc53IOZjja79etENeGdPmwtaszfdcJvo06t4bkmHTWrQbVCL35dryCDBz j1cwOpyRUailFLQo9OSrnMax1TXCqg5/4XqH4spQq5rm48H77oc7JkKUkr2N8V9TXZNJ B/Da/aeD+EKWN5dwGZnGlI7B1oEdcAIjgArukXALqN29OanW/5T+ZempIJjYyt1GUk6c Nwp8F5ckfXfJHjrCSstZuPv8H2Yua3otSeNyu1y2TaJO/vYLYQ+jrOpgNR9VBFzJISYZ 4fng== 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 v21si221992edy.237.2021.01.11.10.23.59; Mon, 11 Jan 2021 10:24:23 -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 S2390339AbhAKSVf (ORCPT + 99 others); Mon, 11 Jan 2021 13:21:35 -0500 Received: from foss.arm.com ([217.140.110.172]:34224 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390214AbhAKSVe (ORCPT ); Mon, 11 Jan 2021 13:21:34 -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 BC75011B3; Mon, 11 Jan 2021 10:20:48 -0800 (PST) Received: from e107158-lin.cambridge.arm.com (unknown [10.1.194.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 853133F70D; Mon, 11 Jan 2021 10:20:47 -0800 (PST) From: Qais Yousef To: netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Steven Rostedt , "Peter Zijlstra (Intel)" , linux-kernel@vger.kernel.org, Qais Yousef Subject: [PATCH bpf-next 1/2] trace: bpf: Allow bpf to attach to bare tracepoints Date: Mon, 11 Jan 2021 18:20:26 +0000 Message-Id: <20210111182027.1448538-2-qais.yousef@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210111182027.1448538-1-qais.yousef@arm.com> References: <20210111182027.1448538-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..cf1496b162b1 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