Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp207079pxb; Wed, 13 Jan 2021 01:20:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJwhnRKit0S4oLT18AVgcmMljTIz+VDVkHfhzlgTDQqXA67YqdMdTNBKCCRel5uELnmb0VrD X-Received: by 2002:a05:6402:1d24:: with SMTP id dh4mr992857edb.161.1610529608173; Wed, 13 Jan 2021 01:20:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610529608; cv=none; d=google.com; s=arc-20160816; b=FEfgkkPEyoiFk9ilevpZquzC4RHrx0aujfxmT5SdNv1yUcK6wEP9Fszc8s7MvH5xt7 d9mIe8BO48r6adwQ04lhYx5GEaj4jMIgy3ESXWD8woWEFXRi0byN6G2mS48mk7QkUmZo otCe0W8jAIc6wOKgyaPfysRTv+rHIL1aX1Um2cr8vQ4fIeYQtfj4dhXk70yynqQ+OCsx v0Gp/WPUGFLCT2lzov6Lt7jBo6Q2y/puQ/5MpJuImqe7svrXAHh/aSZot8XsC5Pp4NgV qaX0kqmMDHCvJiwPJQx4hmzbmd0FCVNEKgdIVhpRqKQir3wmX54GfxxGZJj+12pgKJAc GDLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=fSzBeKXP0Nh8klQwaoWnqoqW21r9BnvxbYgVEskeqWs=; b=cgU2qioTwlHkcbYsSKdiVPrApzE0tvrTgvspRroFdoFv2FJFRcedjw37SS94F+fS8i YYgsw0SzPnFf0TSkoVlOyA8BuR53iCQslEv1twkRBR91xcghQy/lLDdVvn6JOb63dn6f B6sqH313rcQzsqBjqfYi6H+9ndEgRCliX9LSeu+BwXtqY/czjMZHrGICdGP+53mdIV4N 7RtoU2sMPWVlo7TmMT2Qz3hf/y1kVnyy3EpDyqia05xhGPSd/PE26FMrJpmFJXDx67KN FciQA6ozirmUwBUtKvxwLaDbAO0mc4NX4voI2qLGHEugOxp1LH2T2S+39klhxX64ndS5 R8iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UaLVElNB; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g8si721947edu.166.2021.01.13.01.19.44; Wed, 13 Jan 2021 01:20:08 -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=@google.com header.s=20161025 header.b=UaLVElNB; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727707AbhAMJRq (ORCPT + 99 others); Wed, 13 Jan 2021 04:17:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727695AbhAMJRp (ORCPT ); Wed, 13 Jan 2021 04:17:45 -0500 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B517BC061794 for ; Wed, 13 Jan 2021 01:17:04 -0800 (PST) Received: by mail-wr1-x44a.google.com with SMTP id j5so645478wro.12 for ; Wed, 13 Jan 2021 01:17:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=fSzBeKXP0Nh8klQwaoWnqoqW21r9BnvxbYgVEskeqWs=; b=UaLVElNBweVx72KvGpJgtpmWaCqmMmu6qvX+GlVI4VwcXD9u7ZBdmq7KJ6cKg7U+Se JbSEXj6esp011RsM6SrrBM/Z37oVQzITPDyuGcM05To+x0oATeQSN/7TIcrNixBuGo6Z QMG9aV8Vyk/EBGIQ9hxYPGCkJ7ti7qMr8ycqGDIKhGTT3PijEJaVERzOOwwEjccGtlQO USXR9lOI7yFayytiGWhg8+YPf+a/C17wiLcGFg7PfTFnIbOHKXvexYfXKt1+gOJBpCPZ t6OQniYCIcAhdOsPlGNIwY8dq2Deip0KtYJL0aeRNRHUVD/GnqLQnF49xBSjeAVhI8wE dhQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=fSzBeKXP0Nh8klQwaoWnqoqW21r9BnvxbYgVEskeqWs=; b=a8OvGvyAGijQgZkZ6zoDP0O2zvncDFBj22Qp7RBhl8iI05aaouAmOInjy1Znj9Mzvk +PLa5ZduZ2yZ/R/wV1upvGstl47Y8pwifbnnPJB231bsY464/InL+Of1XogqtDxefYyM +pdR0qUmvuO1bKgQdngXQnzygK+iwvT1PTbiURU4h/HTXb1SNYpuehxHLclkHTdeFb1G hqhLjcMYr8lwGiaejbZH2Knn5Hs7xnNoqYeadlv+a1TedRm8aiuRGZX+YZP3jTbRMSH+ /kethkNMn4qAnmZEVAKSS7vqR9yNE3p5sQIz67PwBOqbGZwyGskju3LOjNOkMp5L0bi0 bGNg== X-Gm-Message-State: AOAM531LDaBnaWlu8q64/Q9BcswHqtiNmxX8nXb8I3GvP7W7GBut+HiY RUHn4AEQTehLhgw0e0L9UDrT9s8cHrQ= Sender: "glider via sendgmr" X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:9ff]) (user=glider job=sendgmr) by 2002:a1c:6484:: with SMTP id y126mr1222870wmb.76.1610529423513; Wed, 13 Jan 2021 01:17:03 -0800 (PST) Date: Wed, 13 Jan 2021 10:16:54 +0100 In-Reply-To: <20210113091657.1456216-1-glider@google.com> Message-Id: <20210113091657.1456216-2-glider@google.com> Mime-Version: 1.0 References: <20210113091657.1456216-1-glider@google.com> X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 1/4] tracing: add error_report trace points From: Alexander Potapenko To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Cc: Alexander Potapenko , Marco Elver , Andrey Konovalov , Dmitry Vyukov , Ingo Molnar , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce error_report_start and error_report_end tracepoints. Those can be used in debugging tools like KASAN, KFENCE, etc. to provide extensions to the error reporting mechanisms (e.g. allow tests hook into error reporting, ease error report collection from production kernels). Another benefit would be making use of ftrace for debugging or benchmarking the tools themselves. Suggested-by: Marco Elver Cc: Andrew Morton Cc: Andrey Konovalov Cc: Dmitry Vyukov Cc: Ingo Molnar Cc: Marco Elver Cc: Petr Mladek Cc: Steven Rostedt Cc: Sergey Senozhatsky Cc: linux-mm@kvack.org Signed-off-by: Alexander Potapenko --- include/trace/events/error_report.h | 51 +++++++++++++++++++++++++++++ kernel/trace/Makefile | 1 + kernel/trace/error_report-traces.c | 11 +++++++ 3 files changed, 63 insertions(+) create mode 100644 include/trace/events/error_report.h create mode 100644 kernel/trace/error_report-traces.c diff --git a/include/trace/events/error_report.h b/include/trace/events/error_report.h new file mode 100644 index 000000000000..bae0129031f0 --- /dev/null +++ b/include/trace/events/error_report.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM error_report + +#if !defined(_TRACE_ERROR_REPORT_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_ERROR_REPORT_H + +#include + +DECLARE_EVENT_CLASS(error_report_template, + TP_PROTO(const char *error_detector, unsigned long id), + TP_ARGS(error_detector, id), + TP_STRUCT__entry(__field(const char *, error_detector) + __field(unsigned long, id)), + TP_fast_assign(__entry->error_detector = error_detector; + __entry->id = id;), + TP_printk("[%s] %lx", __entry->error_detector, + __entry->id)); + +/** + * error_report_start - called before printing the error report + * @error_detector: short string describing the error detection tool + * @id: pseudo-unique descriptor that can help distinguish reports + * from one another. Depending on the tool, good examples + * could be: memory access address, call site, allocation + * site, etc. + * + * This event occurs right before a debugging tool starts printing the error + * report. + */ +DEFINE_EVENT(error_report_template, error_report_start, + TP_PROTO(const char *error_detector, unsigned long id), + TP_ARGS(error_detector, id)); + +/** + * error_report_end - called after printing the error report + * @error_detector: short string describing the error detection tool + * @id: pseudo-unique descriptor, matches that passed to + * error_report_start + * + * This event occurs right after a debugging tool finishes printing the error + * report. + */ +DEFINE_EVENT(error_report_template, error_report_end, + TP_PROTO(const char *error_detector, unsigned long id), + TP_ARGS(error_detector, id)); + +#endif /* _TRACE_ERROR_REPORT_H */ + +/* This part must be outside protection */ +#include diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 7e44cea89fdc..b28d3e5013cd 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -81,6 +81,7 @@ obj-$(CONFIG_SYNTH_EVENTS) += trace_events_synth.o obj-$(CONFIG_HIST_TRIGGERS) += trace_events_hist.o obj-$(CONFIG_BPF_EVENTS) += bpf_trace.o obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe.o +obj-$(CONFIG_TRACEPOINTS) += error_report-traces.o obj-$(CONFIG_TRACEPOINTS) += power-traces.o ifeq ($(CONFIG_PM),y) obj-$(CONFIG_TRACEPOINTS) += rpm-traces.o diff --git a/kernel/trace/error_report-traces.c b/kernel/trace/error_report-traces.c new file mode 100644 index 000000000000..80960c52c705 --- /dev/null +++ b/kernel/trace/error_report-traces.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Error reporting trace points + */ + +#define CREATE_TRACE_POINTS +#include + +EXPORT_TRACEPOINT_SYMBOL_GPL(error_report_start); +EXPORT_TRACEPOINT_SYMBOL_GPL(error_report_end); + -- 2.30.0.284.gd98b1dd5eaa7-goog