From patchwork Wed Jan 13 09:10:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12016193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0FD7C433E0 for ; Wed, 13 Jan 2021 09:10:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1A70E2339D for ; Wed, 13 Jan 2021 09:10:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A70E2339D Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 708F68D0023; Wed, 13 Jan 2021 04:10:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B8718D0019; Wed, 13 Jan 2021 04:10:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57F498D0023; Wed, 13 Jan 2021 04:10:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id 400758D0019 for ; Wed, 13 Jan 2021 04:10:27 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 03D2E181AEF23 for ; Wed, 13 Jan 2021 09:10:27 +0000 (UTC) X-FDA: 77700180894.11.face26_600dd7b2751c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id DA735180F8B81 for ; Wed, 13 Jan 2021 09:10:26 +0000 (UTC) X-HE-Tag: face26_600dd7b2751c X-Filterd-Recvd-Size: 7366 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 09:10:26 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id b8so636318wrv.14 for ; Wed, 13 Jan 2021 01:10:26 -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=E7Ff/PeTeEp/tffuQzhGcvBDdqch+30pi5ZCpjQxkBQG2mJEOe2Kq9AXfkAM9RNEQN SF3B52rov9LnbsVmplJS5p0PPT6hpEhSv26O9ra+nIfGvDX64OKrB7O2aHd3QX0zA01D Mc4nbWGmDi1/3lRA8vDUo5lOhIuXhgxZbsBSbwwo9shkH9+5yag+QKSfdNcgEIQ++bSS ZEamoIo6H6nITJjboVGMRRZ0eHNTicyEUsw57sb19J8ITZJktnf+WkVhHHMMg/lqKiOx BB0tnDiei6iI7ff/GWAybcW8ixJN27t/1GWEmAZXKccrzErl5BpHicbF6XL/4gHK2iCr lhGw== 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=VyrF1xgt/bfXvgHVz6Fi0DmyvaAxeOFL6mAshwuVy3nRSkZECbjtj2j9Uf4eFVaoyQ jUjCDonvJVGUpKhc04IrsxdrgK5naTvKoYRvK/xlb+//U7WYmueENGUS91PoXhnCrLC9 mvux32+RELhSlorp48Tl68NXFmFKyf4B5dShG18SXV+Ah7WKtftEIJs64R/qqquUIXgI oh/ynQVeSlCXhWhZy+QmVcvp6MnMYV5Ry3dkBXOQDPIKUZFPcQ/tSK4MNPOg3HILxotG a2abw2tr33OvO/r/41eLk/XSyqUOkMc56MdVvFM/OOvpR7FsOkxvxHj9esf51kycvxL0 LbSQ== X-Gm-Message-State: AOAM532J0L6iTXAAZYpTIidIjH4gpD5DeNok/dioFVaeI+OTZk7DwmXF niHO7dS2Ypuco9i6GsimDi109wRvaOs= X-Google-Smtp-Source: ABdhPJx0I0tRcyIkYioQ7MH7fvVXWyYnBMOYOJ+U8wVSWf5ru1Ukqq8kRjmD7xT65fn3qydqEDid4ZDnZbk= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:f693:9fff:fef4:9ff]) (user=glider job=sendgmr) by 2002:a1c:8195:: with SMTP id c143mr1169117wmd.59.1610529024753; Wed, 13 Jan 2021 01:10:24 -0800 (PST) Date: Wed, 13 Jan 2021 10:10:14 +0100 In-Reply-To: <20210113091017.1444780-1-glider@google.com> Message-Id: <20210113091017.1444780-2-glider@google.com> Mime-Version: 1.0 References: <20210113091017.1444780-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 Cc: Alexander Potapenko , Marco Elver , Andrey Konovalov , Dmitry Vyukov , Ingo Molnar , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , linux-mm@kvack.org X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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); +