From patchwork Sat Sep 8 20:27:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Prakash Ranjan X-Patchwork-Id: 10593161 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0011E13AC for ; Sat, 8 Sep 2018 20:28:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7421F29898 for ; Sat, 8 Sep 2018 20:28:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63E4D298AF; Sat, 8 Sep 2018 20:28:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 082FB29898 for ; Sat, 8 Sep 2018 20:28:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727774AbeIIBOy (ORCPT ); Sat, 8 Sep 2018 21:14:54 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:45222 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbeIIBOx (ORCPT ); Sat, 8 Sep 2018 21:14:53 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1F4926029D; Sat, 8 Sep 2018 20:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438475; bh=TaRl/MxrrLf6Qbwd4CMG77mIUVzj9WM9re940VH+6M0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i61+rhVThsJFHChSL7IfWf7aOHlVWp/Kuq9ys2GzU00fwEndHotC6C6xDAxTfN03L +R23RfbbFz6e2/9HYy8ar1JRtHl5+omwQlKW1NpF77ZQSyfTDO/2O1vCK8DwJldOd5 uPOC4XYYFtwaf8SSib5dq9RFudIblV9lFdqhnzXA= Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 06D366029D; Sat, 8 Sep 2018 20:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438473; bh=TaRl/MxrrLf6Qbwd4CMG77mIUVzj9WM9re940VH+6M0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QQyRMgKzC1WgR7XSo3k3vOOg4v6BBJtOICDH6nLGS9m8rVAN47J3rgRDnEEul6pqG zdXYQ9NNRcZHxUJnhqMpgLYgR0UUFJU7vUxFEYkSrG8B83x42CR/aVlyI23jurazT7 5LbfPtEkLP3NKw9Tspu9QlA1Vmvf/6HIuUyRaEi4= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 06D366029D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Steven Rostedt , Ingo Molnar , Laura Abbott , Kees Cook , Anton Vorontsov , Rob Herring , devicetree@vger.kernel.org, Colin Cross , Jason Baron , Tony Luck , Arnd Bergmann , Catalin Marinas , Will Deacon , Joel Fernandes , Masami Hiramatsu , Joe Perches , Jim Cromie Cc: Rajendra Nayak , Vivek Gautam , Sibi Sankar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Greg Kroah-Hartman , Ingo Molnar , Tom Zanussi , Prasad Sodagudi , tsoni@codeaurora.org, Bryan Huntsman , Tingwei Zhang , Sai Prakash Ranjan Subject: [PATCH 1/6] dt-bindings: ramoops: Add event-size property Date: Sun, 9 Sep 2018 01:57:02 +0530 Message-Id: <4ec22906649fb3f6ab9570d8d4bf214e61512664.1536430404.git.saiprakash.ranjan@codeaurora.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add an optional property called event-size to reserve log buffer for trace events. Signed-off-by: Sai Prakash Ranjan --- .../devicetree/bindings/reserved-memory/ramoops.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/reserved-memory/ramoops.txt b/Documentation/devicetree/bindings/reserved-memory/ramoops.txt index 0eba562fe5c6..4f835ef65635 100644 --- a/Documentation/devicetree/bindings/reserved-memory/ramoops.txt +++ b/Documentation/devicetree/bindings/reserved-memory/ramoops.txt @@ -14,8 +14,8 @@ Any remaining space will be used for a circular buffer of oops and panic records. These records have a configurable size, with a size of 0 indicating that they should be disabled. -At least one of "record-size", "console-size", "ftrace-size", or "pmsg-size" -must be set non-zero, but are otherwise optional as listed below. +At least one of "record-size", "console-size", "event-size", "ftrace-size", or +"pmsg-size" must be set non-zero, but are otherwise optional as listed below. Required properties: @@ -36,6 +36,9 @@ Optional properties: - console-size: size in bytes of log buffer reserved for kernel messages (defaults to 0: disabled) +- event-size: size in bytes of log buffer reserved for trace events + (defaults to 0: disabled) + - ftrace-size: size in bytes of log buffer reserved for function tracing and profiling (defaults to 0: disabled) From patchwork Sat Sep 8 20:27:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Prakash Ranjan X-Patchwork-Id: 10593165 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7530814BD for ; Sat, 8 Sep 2018 20:28:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62AA9299C2 for ; Sat, 8 Sep 2018 20:28:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5393B299D9; Sat, 8 Sep 2018 20:28:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57EBE299C2 for ; Sat, 8 Sep 2018 20:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727801AbeIIBPR (ORCPT ); Sat, 8 Sep 2018 21:15:17 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47022 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727795AbeIIBPR (ORCPT ); Sat, 8 Sep 2018 21:15:17 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 9506560AD9; Sat, 8 Sep 2018 20:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438497; bh=2qCdT0/E8JuJRbEQWvnqn8ufJsjPu9ZXXqIzW2bPtEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JtyqalJHzihFCfc6uJStnw3X91qfvUvMvzb5C/jD6OpYiji7NQGsGHiBKTolSS5h0 qwd2/ICVnun7ExWG7tAEY5vkIwj03zmWMg8hA0WHALVwEwTYM+XfVh/WvTlBTd3Xql 3CPvn5UHYSZyQIiFJ1CqIUi9eSA63+RFgP1M0IM0= Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 399C3608BF; Sat, 8 Sep 2018 20:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438487; bh=2qCdT0/E8JuJRbEQWvnqn8ufJsjPu9ZXXqIzW2bPtEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VpkYCZamDN1XQrI+xiOlgEPNbXWdOjNnEi3PG/hJbDKjlBGzmevd+BG+LcIpdh+Lb ezEjTCFRI0yhP0ahkel97KYx6RoHaVVvBRBAejMvT1vdQzzdDwS7wPgIr5E8fklOUU n5ztiPLJ05ui+Wue+NHZUMpKdSZG6Y4Oez4bkYz8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 399C3608BF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Steven Rostedt , Ingo Molnar , Laura Abbott , Kees Cook , Anton Vorontsov , Rob Herring , devicetree@vger.kernel.org, Colin Cross , Jason Baron , Tony Luck , Arnd Bergmann , Catalin Marinas , Will Deacon , Joel Fernandes , Masami Hiramatsu , Joe Perches , Jim Cromie Cc: Rajendra Nayak , Vivek Gautam , Sibi Sankar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Greg Kroah-Hartman , Ingo Molnar , Tom Zanussi , Prasad Sodagudi , tsoni@codeaurora.org, Bryan Huntsman , Tingwei Zhang , Sai Prakash Ranjan Subject: [PATCH 2/6] pstore: Add event tracing support Date: Sun, 9 Sep 2018 01:57:03 +0530 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently pstore has function trace support which can be used to get the function call chain with limited data. Event tracing has extra data which is useful to debug wide variety of issues and is heavily used across the kernel. Adding this support to pstore can be very helpful to debug different subsystems since almost all of them have trace events already available. And also it is useful to debug unknown resets or crashes since we can get lot more info from event tracing by viewing the last occurred events. High frequency tracepoints such as sched and irq has also been tested. This implementation is similar to "tp_printk" command line feature of ftrace by Steven. For example, sample pstore output of tracing sched events after reboot: # mount -t pstore pstore /sys/fs/pstore/ # tail /sys/fs/pstore/event-ramoops-0 sched_switch: prev_comm=swapper/1 prev_pid=0 prev_prio=120 prev_state=S ==> next_comm=rcu_preempt next_pid=10 next_prio=120 sched_switch: prev_comm=rcu_preempt prev_pid=10 prev_prio=120 prev_state=R+ ==> next_comm=swapper/1 next_pid=0 next_prio=120 sched_waking: comm=rcu_sched pid=11 prio=120 target_cpu=002 sched_wakeup: comm=rcu_sched pid=11 prio=120 target_cpu=002 sched_switch: prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=S ==> next_comm=rcu_sched next_pid=11 next_prio=120 sched_switch: prev_comm=rcu_sched prev_pid=11 prev_prio=120 prev_state=R+ ==> next_comm=swapper/2 next_pid=0 next_prio=120 sched_waking: comm=reboot pid=1867 prio=120 target_cpu=000 sched_wakeup: comm=reboot pid=1867 prio=120 target_cpu=000 sched_switch: prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=S ==> next_comm=reboot next_pid=1867 next_prio=120 Signed-off-by: Sai Prakash Ranjan --- fs/pstore/Kconfig | 2 +- fs/pstore/ftrace.c | 55 ++++++++++++++++++++++++++++++++++++++ fs/pstore/inode.c | 4 +++ fs/pstore/ram.c | 44 +++++++++++++++++++++++++++--- include/linux/pstore.h | 2 ++ include/linux/pstore_ram.h | 1 + 6 files changed, 104 insertions(+), 4 deletions(-) diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 503086f7f7c1..6fe087b13a51 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -126,7 +126,7 @@ config PSTORE_PMSG config PSTORE_FTRACE bool "Persistent function tracer" - depends on PSTORE + depends on PSTORE && PSTORE!=m depends on FUNCTION_TRACER depends on DEBUG_FS help diff --git a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c index 06aab07b6bb7..d47dc93ac098 100644 --- a/fs/pstore/ftrace.c +++ b/fs/pstore/ftrace.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include "internal.h" @@ -62,6 +64,59 @@ static struct ftrace_ops pstore_ftrace_ops __read_mostly = { .func = pstore_ftrace_call, }; +void notrace pstore_event_call(struct trace_event_buffer *fbuffer) +{ + struct trace_iterator *iter; + struct trace_seq *s; + struct trace_event_call *event_call; + struct pstore_record record; + struct trace_event *event; + struct seq_buf *seq; + unsigned long flags; + + if (!psinfo) + return; + + if (unlikely(oops_in_progress)) + return; + + pstore_record_init(&record, psinfo); + record.type = PSTORE_TYPE_EVENT; + + iter = kmalloc(sizeof(*iter), GFP_KERNEL); + if (!iter) + return; + + event_call = fbuffer->trace_file->event_call; + if (!event_call || !event_call->event.funcs || + !event_call->event.funcs->trace) + goto fail_event; + + event = &fbuffer->trace_file->event_call->event; + + spin_lock_irqsave(&psinfo->buf_lock, flags); + + trace_seq_init(&iter->seq); + iter->ent = fbuffer->entry; + event_call->event.funcs->trace(iter, 0, event); + trace_seq_putc(&iter->seq, 0); + + if (seq->size > psinfo->bufsize) + seq->size = psinfo->bufsize; + + s = &iter->seq; + seq = &s->seq; + + record.buf = (char *)(seq->buffer); + record.size = seq->len; + psinfo->write(&record); + + spin_unlock_irqrestore(&psinfo->buf_lock, flags); + +fail_event: + kfree(iter); +} + static DEFINE_MUTEX(pstore_ftrace_lock); static bool pstore_ftrace_enabled; diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index 5fcb845b9fec..f099152abbbd 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -345,6 +345,10 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record) scnprintf(name, sizeof(name), "console-%s-%llu", record->psi->name, record->id); break; + case PSTORE_TYPE_EVENT: + scnprintf(name, sizeof(name), "event-%s-%llu", + record->psi->name, record->id); + break; case PSTORE_TYPE_FTRACE: scnprintf(name, sizeof(name), "ftrace-%s-%llu", record->psi->name, record->id); diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index bbd1e357c23d..f60d41c0309e 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -48,6 +48,10 @@ static ulong ramoops_console_size = MIN_MEM_SIZE; module_param_named(console_size, ramoops_console_size, ulong, 0400); MODULE_PARM_DESC(console_size, "size of kernel console log"); +static ulong ramoops_event_size = MIN_MEM_SIZE; +module_param_named(event_size, ramoops_event_size, ulong, 0400); +MODULE_PARM_DESC(event_size, "size of event log"); + static ulong ramoops_ftrace_size = MIN_MEM_SIZE; module_param_named(ftrace_size, ramoops_ftrace_size, ulong, 0400); MODULE_PARM_DESC(ftrace_size, "size of ftrace log"); @@ -86,6 +90,7 @@ MODULE_PARM_DESC(ramoops_ecc, struct ramoops_context { struct persistent_ram_zone **dprzs; /* Oops dump zones */ struct persistent_ram_zone *cprz; /* Console zone */ + struct persistent_ram_zone *eprz; /* Event zone */ struct persistent_ram_zone **fprzs; /* Ftrace zones */ struct persistent_ram_zone *mprz; /* PMSG zone */ phys_addr_t phys_addr; @@ -93,6 +98,7 @@ struct ramoops_context { unsigned int memtype; size_t record_size; size_t console_size; + size_t event_size; size_t ftrace_size; size_t pmsg_size; int dump_oops; @@ -103,6 +109,7 @@ struct ramoops_context { /* _read_cnt need clear on ramoops_pstore_open */ unsigned int dump_read_cnt; unsigned int console_read_cnt; + unsigned int event_read_cnt; unsigned int max_ftrace_cnt; unsigned int ftrace_read_cnt; unsigned int pmsg_read_cnt; @@ -118,6 +125,7 @@ static int ramoops_pstore_open(struct pstore_info *psi) cxt->dump_read_cnt = 0; cxt->console_read_cnt = 0; + cxt->event_read_cnt = 0; cxt->ftrace_read_cnt = 0; cxt->pmsg_read_cnt = 0; return 0; @@ -277,6 +285,11 @@ static ssize_t ramoops_pstore_read(struct pstore_record *record) 1, &record->id, &record->type, PSTORE_TYPE_CONSOLE, 0); + if (!prz_ok(prz)) + prz = ramoops_get_next_prz(&cxt->eprz, &cxt->event_read_cnt, + 1, &record->id, &record->type, + PSTORE_TYPE_EVENT, 0); + if (!prz_ok(prz)) prz = ramoops_get_next_prz(&cxt->mprz, &cxt->pmsg_read_cnt, 1, &record->id, &record->type, @@ -385,6 +398,11 @@ static int notrace ramoops_pstore_write(struct pstore_record *record) return -ENOMEM; persistent_ram_write(cxt->cprz, record->buf, record->size); return 0; + } else if (record->type == PSTORE_TYPE_EVENT) { + if (!cxt->eprz) + return -ENOMEM; + persistent_ram_write(cxt->eprz, record->buf, record->size); + return 0; } else if (record->type == PSTORE_TYPE_FTRACE) { int zonenum; @@ -475,6 +493,9 @@ static int ramoops_pstore_erase(struct pstore_record *record) case PSTORE_TYPE_CONSOLE: prz = cxt->cprz; break; + case PSTORE_TYPE_EVENT: + prz = cxt->eprz; + break; case PSTORE_TYPE_FTRACE: if (record->id >= cxt->max_ftrace_cnt) return -EINVAL; @@ -699,6 +720,7 @@ static int ramoops_parse_dt(struct platform_device *pdev, parse_size("record-size", pdata->record_size); parse_size("console-size", pdata->console_size); + parse_size("event-size", pdata->event_size); parse_size("ftrace-size", pdata->ftrace_size); parse_size("pmsg-size", pdata->pmsg_size); parse_size("ecc-size", pdata->ecc_info.ecc_size); @@ -747,7 +769,8 @@ static int ramoops_probe(struct platform_device *pdev) } if (!pdata->mem_size || (!pdata->record_size && !pdata->console_size && - !pdata->ftrace_size && !pdata->pmsg_size)) { + !pdata->event_size && !pdata->ftrace_size && + !pdata->pmsg_size)) { pr_err("The memory size and the record/console size must be " "non-zero\n"); goto fail_out; @@ -757,6 +780,8 @@ static int ramoops_probe(struct platform_device *pdev) pdata->record_size = rounddown_pow_of_two(pdata->record_size); if (pdata->console_size && !is_power_of_2(pdata->console_size)) pdata->console_size = rounddown_pow_of_two(pdata->console_size); + if (pdata->event_size && !is_power_of_2(pdata->event_size)) + pdata->event_size = rounddown_pow_of_two(pdata->event_size); if (pdata->ftrace_size && !is_power_of_2(pdata->ftrace_size)) pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size); if (pdata->pmsg_size && !is_power_of_2(pdata->pmsg_size)) @@ -767,6 +792,7 @@ static int ramoops_probe(struct platform_device *pdev) cxt->memtype = pdata->mem_type; cxt->record_size = pdata->record_size; cxt->console_size = pdata->console_size; + cxt->event_size = pdata->event_size; cxt->ftrace_size = pdata->ftrace_size; cxt->pmsg_size = pdata->pmsg_size; cxt->dump_oops = pdata->dump_oops; @@ -775,8 +801,8 @@ static int ramoops_probe(struct platform_device *pdev) paddr = cxt->phys_addr; - dump_mem_sz = cxt->size - cxt->console_size - cxt->ftrace_size - - cxt->pmsg_size; + dump_mem_sz = cxt->size - cxt->console_size - cxt->event_size + - cxt->ftrace_size - cxt->pmsg_size; err = ramoops_init_przs("dump", dev, cxt, &cxt->dprzs, &paddr, dump_mem_sz, cxt->record_size, &cxt->max_dump_cnt, 0, 0); @@ -788,6 +814,11 @@ static int ramoops_probe(struct platform_device *pdev) if (err) goto fail_init_cprz; + err = ramoops_init_prz("event", dev, cxt, &cxt->eprz, &paddr, + cxt->event_size, 0); + if (err) + goto fail_init_eprz; + cxt->max_ftrace_cnt = (cxt->flags & RAMOOPS_FLAG_FTRACE_PER_CPU) ? nr_cpu_ids : 1; @@ -825,6 +856,8 @@ static int ramoops_probe(struct platform_device *pdev) cxt->pstore.flags = PSTORE_FLAGS_DMESG; if (cxt->console_size) cxt->pstore.flags |= PSTORE_FLAGS_CONSOLE; + if (cxt->event_size) + cxt->pstore.flags |= PSTORE_FLAGS_EVENT; if (cxt->ftrace_size) cxt->pstore.flags |= PSTORE_FLAGS_FTRACE; if (cxt->pmsg_size) @@ -845,6 +878,7 @@ static int ramoops_probe(struct platform_device *pdev) record_size = pdata->record_size; dump_oops = pdata->dump_oops; ramoops_console_size = pdata->console_size; + ramoops_event_size = pdata->event_size; ramoops_pmsg_size = pdata->pmsg_size; ramoops_ftrace_size = pdata->ftrace_size; @@ -858,6 +892,8 @@ static int ramoops_probe(struct platform_device *pdev) kfree(cxt->pstore.buf); fail_clear: cxt->pstore.bufsize = 0; + persistent_ram_free(cxt->eprz); +fail_init_eprz: persistent_ram_free(cxt->mprz); fail_init_mprz: fail_init_fprz: @@ -877,6 +913,7 @@ static int ramoops_remove(struct platform_device *pdev) kfree(cxt->pstore.buf); cxt->pstore.bufsize = 0; + persistent_ram_free(cxt->eprz); persistent_ram_free(cxt->mprz); persistent_ram_free(cxt->cprz); ramoops_free_przs(cxt); @@ -916,6 +953,7 @@ static void ramoops_register_dummy(void) dummy_data->mem_type = mem_type; dummy_data->record_size = record_size; dummy_data->console_size = ramoops_console_size; + dummy_data->event_size = ramoops_event_size; dummy_data->ftrace_size = ramoops_ftrace_size; dummy_data->pmsg_size = ramoops_pmsg_size; dummy_data->dump_oops = dump_oops; diff --git a/include/linux/pstore.h b/include/linux/pstore.h index a15bc4d48752..c31bb9567b4a 100644 --- a/include/linux/pstore.h +++ b/include/linux/pstore.h @@ -44,6 +44,7 @@ enum pstore_type_id { PSTORE_TYPE_PPC_COMMON = 6, PSTORE_TYPE_PMSG = 7, PSTORE_TYPE_PPC_OPAL = 8, + PSTORE_TYPE_EVENT = 9, PSTORE_TYPE_UNKNOWN = 255 }; @@ -193,6 +194,7 @@ struct pstore_info { #define PSTORE_FLAGS_CONSOLE (1 << 1) #define PSTORE_FLAGS_FTRACE (1 << 2) #define PSTORE_FLAGS_PMSG (1 << 3) +#define PSTORE_FLAGS_EVENT (1 << 4) extern int pstore_register(struct pstore_info *); extern void pstore_unregister(struct pstore_info *); diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h index e6d226464838..f01055c6cc40 100644 --- a/include/linux/pstore_ram.h +++ b/include/linux/pstore_ram.h @@ -95,6 +95,7 @@ struct ramoops_platform_data { unsigned int mem_type; unsigned long record_size; unsigned long console_size; + unsigned long event_size; unsigned long ftrace_size; unsigned long pmsg_size; int dump_oops; From patchwork Sat Sep 8 20:27:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Prakash Ranjan X-Patchwork-Id: 10593167 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5351713AC for ; Sat, 8 Sep 2018 20:28:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CC9229FDE for ; Sat, 8 Sep 2018 20:28:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E67229FF3; Sat, 8 Sep 2018 20:28:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 728F929FDE for ; Sat, 8 Sep 2018 20:28:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727854AbeIIBPW (ORCPT ); Sat, 8 Sep 2018 21:15:22 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47332 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbeIIBPV (ORCPT ); Sat, 8 Sep 2018 21:15:21 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6C1FF60B7E; Sat, 8 Sep 2018 20:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438502; bh=AiSXsPqgnxBl1egXl/tp3X3Wzh3/ubPlMcQVEh4lyNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQxGqXy3aN9v9BDyV1hNUMnCecllfWEK0KzM9Y6QuUUtQiAX1wIgJfIzdmyGQXROJ snsgJdEQl+iptnHGOicuxXi35hJ2oholZqlMd4dTE1DAhQl96p+s4Qp92gqZtbQQcR qwlb/DcUa8ybR1ESnRfbHEAnTnE3SXUcCidbVQCQ= Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id DFF8760B1E; Sat, 8 Sep 2018 20:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438499; bh=AiSXsPqgnxBl1egXl/tp3X3Wzh3/ubPlMcQVEh4lyNA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=URaZCK1J+o6uXRiuqyC65hLBXkGlkRc+8xDI8Hp3qHR+PiBaD8/8ruJR03ziFft7l vmCfWRXcujze2gx3Y2kfS7MqABb98muk0s1eypur0MSiT7/qvzHRG5Z7bYtT+PM9ns EXFINMuETD1m/kJp4NK2rJFuznM55j0jP+MMdLAg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DFF8760B1E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Steven Rostedt , Ingo Molnar , Laura Abbott , Kees Cook , Anton Vorontsov , Rob Herring , devicetree@vger.kernel.org, Colin Cross , Jason Baron , Tony Luck , Arnd Bergmann , Catalin Marinas , Will Deacon , Joel Fernandes , Masami Hiramatsu , Joe Perches , Jim Cromie Cc: Rajendra Nayak , Vivek Gautam , Sibi Sankar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Greg Kroah-Hartman , Ingo Molnar , Tom Zanussi , Prasad Sodagudi , tsoni@codeaurora.org, Bryan Huntsman , Tingwei Zhang , Sai Prakash Ranjan Subject: [PATCH 3/6] tracing: Add tp_pstore cmdline to have tracepoints go to pstore Date: Sun, 9 Sep 2018 01:57:04 +0530 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the kernel command line tp_pstore option that will have tracepoints go to persistent ram buffer as well as to the trace buffer for further debugging. This is similar to tp_printk cmdline option of ftrace. Pstore support for event tracing is already added and we enable logging to pstore only if cmdline is specified. Passing "tp_pstore" will activate logging to pstore. To turn it off, the sysctl /proc/sys/kernel/tracepoint_pstore can have '0' echoed into it. Note, this only works if the cmdline option is used. Echoing 1 into the sysctl file without the cmdline option will have no affect. Signed-off-by: Sai Prakash Ranjan --- .../admin-guide/kernel-parameters.txt | 21 ++++++++ include/linux/ftrace.h | 6 ++- kernel/sysctl.c | 7 +++ kernel/trace/Kconfig | 22 +++++++- kernel/trace/trace.c | 51 +++++++++++++++++++ kernel/trace/trace.h | 7 +++ 6 files changed, 112 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 9871e649ffef..622cf64d4e5b 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -4519,6 +4519,27 @@ frequency tracepoints such as irq or sched, can cause the system to live lock. + tp_pstore[FTRACE] + Have the tracepoints sent to persistent ram buffer for + debugging. This is useful for debugging early boot up + and other kernel issues where the system hangs or + reboots due to some unclocked access or some buggy + driver. Instead of spamming the console with unwanted + logs, we can send the logs to pstore buffer for further + debugging. + + Last occurred events in the pstore log will be helpful + in identifying the reset cause. + + For example, to trace sched event, add to the command + line: + trace_event=sched tp_pstore + + To turn off having tracepoints sent to pstore, + echo 0 > /proc/sys/kernel/tracepoint_pstore + Note, echoing 1 into this file without the + tracepoint_pstore kernel cmdline option has no effect. + traceoff_on_warning [FTRACE] enable this option to disable tracing when a warning is hit. This turns off "tracing_on". Tracing can diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index a397907e8d72..7c3074e7ec6b 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h @@ -900,6 +900,7 @@ enum ftrace_dump_mode; extern enum ftrace_dump_mode ftrace_dump_on_oops; extern int tracepoint_printk; +extern int tracepoint_pstore; extern void disable_trace_on_warning(void); extern int __disable_trace_on_warning; @@ -907,9 +908,12 @@ extern int __disable_trace_on_warning; int tracepoint_printk_sysctl(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos); +int tracepoint_pstore_sysctl(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos); #else /* CONFIG_TRACING */ -static inline void disable_trace_on_warning(void) { } +static inline void disable_trace_on_warning(void) { } #endif /* CONFIG_TRACING */ #ifdef CONFIG_FTRACE_SYSCALLS diff --git a/kernel/sysctl.c b/kernel/sysctl.c index cc02050fd0c4..3cc1223b8955 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -653,6 +653,13 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = tracepoint_printk_sysctl, }, + { + .procname = "tracepoint_pstore", + .data = &tracepoint_pstore, + .maxlen = sizeof(tracepoint_pstore), + .mode = 0644, + .proc_handler = tracepoint_pstore_sysctl, + }, #endif #ifdef CONFIG_KEXEC_CORE { diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index 5e3de28c7677..d0eed268ee85 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -774,6 +774,27 @@ config TRACING_EVENTS_GPIO help Enable tracing events for gpio subsystem +config TRACING_EVENTS_IO + bool "Trace IO read/write events" + help + Enable tracing events for IO read/write operations. + This is useful for debugging random hangs or resets + caused due to unclocked access or some buggy driver. + + Output of this trace event can be overwhelming and hence + dynamic filtering option based on dynamic debug library + is provided to narrow down the issues. + + Eg: Trace all register read/write of mmc subsystem with + below command line: + + dyndbg="file drivers/mmc/* +p" trace_event=io + + See Documentation/admin-guide/dynamic-debug-howto.rst for + more info on using dynamic debug. + + If unsure, say N. + config GCOV_PROFILE_FTRACE bool "Enable GCOV profiling on ftrace subsystem" depends on GCOV_KERNEL @@ -789,4 +810,3 @@ config GCOV_PROFILE_FTRACE endif # FTRACE endif # TRACING_SUPPORT - diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index bf6f1d70484d..018cbbefb769 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -73,6 +73,11 @@ struct trace_iterator *tracepoint_print_iter; int tracepoint_printk; static DEFINE_STATIC_KEY_FALSE(tracepoint_printk_key); +/* Pipe tracepoints to pstore */ +struct trace_iterator *tracepoint_pstore_iter; +int tracepoint_pstore; +static DEFINE_STATIC_KEY_FALSE(tracepoint_pstore_key); + /* For tracers that don't implement custom flags */ static struct tracer_opt dummy_tracer_opt[] = { { } @@ -238,6 +243,14 @@ static int __init set_tracepoint_printk(char *str) } __setup("tp_printk", set_tracepoint_printk); +static int __init set_tracepoint_pstore(char *str) +{ + if ((strcmp(str, "=0") != 0 && strcmp(str, "=off") != 0)) + tracepoint_pstore = 1; + return 1; +} +__setup("tp_pstore", set_tracepoint_pstore); + unsigned long long ns2usecs(u64 nsec) { nsec += 500; @@ -2376,11 +2389,45 @@ int tracepoint_printk_sysctl(struct ctl_table *table, int write, return ret; } +static DEFINE_MUTEX(tracepoint_pstore_mutex); + +int tracepoint_pstore_sysctl(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, + loff_t *ppos) +{ + int save_tracepoint_pstore; + int ret; + + mutex_lock(&tracepoint_pstore_mutex); + save_tracepoint_pstore = tracepoint_pstore; + + ret = proc_dointvec(table, write, buffer, lenp, ppos); + + if (!tracepoint_pstore_iter) + tracepoint_pstore = 0; + + if (save_tracepoint_pstore == tracepoint_pstore) + goto out; + + if (tracepoint_pstore) + static_key_enable(&tracepoint_pstore_key.key); + else + static_key_disable(&tracepoint_pstore_key.key); + + out: + mutex_unlock(&tracepoint_pstore_mutex); + + return ret; +} + void trace_event_buffer_commit(struct trace_event_buffer *fbuffer) { if (static_key_false(&tracepoint_printk_key.key)) output_printk(fbuffer); + if (static_key_false(&tracepoint_pstore_key.key)) + pstore_event_call(fbuffer); + event_trigger_unlock_commit(fbuffer->trace_file, fbuffer->buffer, fbuffer->event, fbuffer->entry, fbuffer->flags, fbuffer->pc); @@ -8596,6 +8643,10 @@ void __init early_trace_init(void) else static_key_enable(&tracepoint_printk_key.key); } + + if (tracepoint_pstore) + static_key_enable(&tracepoint_pstore_key.key); + tracer_alloc_buffers(); } diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 3b8c0e24ab30..edc28d0c27eb 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1843,5 +1843,12 @@ static inline void tracer_hardirqs_off(unsigned long a0, unsigned long a1) { } #endif extern struct trace_iterator *tracepoint_print_iter; +extern struct trace_iterator *tracepoint_pstore_iter; + +#ifdef CONFIG_PSTORE_FTRACE +extern void pstore_event_call(struct trace_event_buffer *fbuffer); +#else +static inline void pstore_event_call(struct trace_event_buffer *fbuffer) { } +#endif #endif /* _LINUX_KERNEL_TRACE_H */ From patchwork Sat Sep 8 20:27:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Prakash Ranjan X-Patchwork-Id: 10593169 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1150714BD for ; Sat, 8 Sep 2018 20:28:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3E7929FDE for ; Sat, 8 Sep 2018 20:28:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6CAE29FF3; Sat, 8 Sep 2018 20:28:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 694A029FDE for ; Sat, 8 Sep 2018 20:28:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727748AbeIIBPh (ORCPT ); Sat, 8 Sep 2018 21:15:37 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:48184 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbeIIBPh (ORCPT ); Sat, 8 Sep 2018 21:15:37 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C5DA760BE5; Sat, 8 Sep 2018 20:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438517; bh=C/LmQnYfl6uhopQ+JIJ/5yeYbPDjbnsOKnwIwHTeK20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eh873Sm83cyaiaS1HhzOsrlPCUbANXxQQXlCzWDIHR3hxNoU/GuyJV5Ym5p/63qTV PIUkCkLCR/Vl6Zcu0w4Vn1Xfj0b6iVyBqZZQZxidJAQPfvRiiqCr0Oq5e/zu65YQSr tFzS9kcluDtE88GCFpJ7sazhUDYC8K00V6nMhgVY= Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E6FEC60BE2; Sat, 8 Sep 2018 20:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438511; bh=C/LmQnYfl6uhopQ+JIJ/5yeYbPDjbnsOKnwIwHTeK20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fGmEfsSGvH+m8EHSnOJCoE7lE+VGDErRPsektqsELsKsR9SfNEsL6l+2dJbL96BDh tR1fij8qIELbUFxBCoSGHNNhYf624/nQDzHxHIy8zFK9LW4qSPo4xEPyQTkuu8CseD cepgLH7dzf4lgErgmFzIrSxAZMXDbYh0XR+gqinA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E6FEC60BE2 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Steven Rostedt , Ingo Molnar , Laura Abbott , Kees Cook , Anton Vorontsov , Rob Herring , devicetree@vger.kernel.org, Colin Cross , Jason Baron , Tony Luck , Arnd Bergmann , Catalin Marinas , Will Deacon , Joel Fernandes , Masami Hiramatsu , Joe Perches , Jim Cromie Cc: Rajendra Nayak , Vivek Gautam , Sibi Sankar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Greg Kroah-Hartman , Ingo Molnar , Tom Zanussi , Prasad Sodagudi , tsoni@codeaurora.org, Bryan Huntsman , Tingwei Zhang , Sai Prakash Ranjan Subject: [PATCH 4/6] arm64/io: Add tracepoint for register accesses Date: Sun, 9 Sep 2018 01:57:05 +0530 Message-Id: <84677d700f0e894142bf3460292c695bb1a946e4.1536430404.git.saiprakash.ranjan@codeaurora.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Generic IO read/write i.e., __raw_{read,write}{b,l,w,q} are typically used to read/write from/to memory mapped registers, which can cause hangs or some undefined behaviour if access unclocked. Tracing these register accesses can be very helpful to debug such issues during initial development stages. This can be used later for tracing arm IO register accesses. Sample output format of register access trace is below: io_write: type=writel cpu=3 ts:1424714326 data=0xffff00000d1065a4 caller=qcom_smsm_probe+0x52c/0x678 io_write: type=writel cpu=3 ts:1424962659 data=0xffff00000d106608 caller=qcom_smsm_probe+0x52c/0x678 Signed-off-by: Sai Prakash Ranjan --- arch/arm64/kernel/io.c | 22 +++++++++++ include/asm-generic/io-trace.h | 70 ++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 include/asm-generic/io-trace.h diff --git a/arch/arm64/kernel/io.c b/arch/arm64/kernel/io.c index 79b17384effa..a9db07f66477 100644 --- a/arch/arm64/kernel/io.c +++ b/arch/arm64/kernel/io.c @@ -19,6 +19,10 @@ #include #include #include +#include + +#define CREATE_TRACE_POINTS +#include /* * Copy data from IO memory space to "real" memory space. @@ -106,3 +110,21 @@ void __memset_io(volatile void __iomem *dst, int c, size_t count) } } EXPORT_SYMBOL(__memset_io); + +#if defined(CONFIG_TRACING_EVENTS_IO) +void do_trace_io_write(const char *type, void *addr) +{ + trace_io_write(type, raw_smp_processor_id(), sched_clock(), addr, + _RET_IP_); +} +EXPORT_SYMBOL(do_trace_io_write); +EXPORT_TRACEPOINT_SYMBOL(io_write); + +void do_trace_io_read(const char *type, void *addr) +{ + trace_io_read(type, raw_smp_processor_id(), sched_clock(), addr, + _RET_IP_); +} +EXPORT_SYMBOL(do_trace_io_read); +EXPORT_TRACEPOINT_SYMBOL(io_read); +#endif diff --git a/include/asm-generic/io-trace.h b/include/asm-generic/io-trace.h new file mode 100644 index 000000000000..e57b52d8976a --- /dev/null +++ b/include/asm-generic/io-trace.h @@ -0,0 +1,70 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM io + +#if !defined(CONFIG_TRACING_EVENTS_IO) +#define NOTRACE +#endif + +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_FILE io-trace + +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH asm-generic + +#if !defined(_TRACE_IO_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_IO_H + +#include + +/* + * Tracepoint for generic IO read/write, i.e., __raw_{read,write}{b,l,w,q}() + */ +DECLARE_EVENT_CLASS(io_trace_class, + + TP_PROTO(const char *type, int cpu, u64 ts, void *addr, + unsigned long ret_ip), + + TP_ARGS(type, cpu, ts, addr, ret_ip), + + TP_STRUCT__entry( + __string( type, type ) + __field( int, cpu ) + __field( u64, ts ) + __field( void *, addr ) + __field( unsigned long, ret_ip ) + ), + + TP_fast_assign( + __assign_str(type, type); + __entry->cpu = cpu; + __entry->ts = ts; + __entry->addr = addr; + __entry->ret_ip = ret_ip; + ), + + TP_printk("type=%s cpu=%d ts:%llu data=0x%lx caller=%pS", + __get_str(type), __entry->cpu, __entry->ts, + (unsigned long)__entry->addr, (void *)__entry->ret_ip) +); + +DEFINE_EVENT(io_trace_class, io_read, + + TP_PROTO(const char *type, int cpu, u64 ts, void *addr, + unsigned long ret_ip), + + TP_ARGS(type, cpu, ts, addr, ret_ip) +); + +DEFINE_EVENT(io_trace_class, io_write, + + TP_PROTO(const char *type, int cpu, u64 ts, void *addr, + unsigned long ret_ip), + + TP_ARGS(type, cpu, ts, addr, ret_ip) +); + +#endif /* _TRACE_IO_H */ + +/* This part must be outside protection */ +#include From patchwork Sat Sep 8 20:27:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Prakash Ranjan X-Patchwork-Id: 10593173 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E43113AC for ; Sat, 8 Sep 2018 20:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CD1E29FDE for ; Sat, 8 Sep 2018 20:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10EDD29FF3; Sat, 8 Sep 2018 20:28:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79E9229FDE for ; Sat, 8 Sep 2018 20:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727789AbeIIBPs (ORCPT ); Sat, 8 Sep 2018 21:15:48 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49060 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbeIIBPs (ORCPT ); Sat, 8 Sep 2018 21:15:48 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AD54A60C4B; Sat, 8 Sep 2018 20:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438528; bh=s/4HW6Ju/hAPrCTV9+MZr06mE12Pko0OOktWpH8Rzyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mnxs8KChdBJX97/83BjmZXVl68/GK+dQsHodh4/2cHWIcm4wU6q7wiDb2r18TpAID p7VWL/eQyLEZcue9lbBWlkdiloyuf8FuPde0fK5lQ3JV9l43q4VhFNXUkmOu3lhB1i 7/oy1AEOmIfkX82tDRaeFgKoc791YAx3cdKDpvxo= Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id C0ABA60BE1; Sat, 8 Sep 2018 20:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438523; bh=s/4HW6Ju/hAPrCTV9+MZr06mE12Pko0OOktWpH8Rzyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QVFeaYzL7OivItbKyrt8rYyWRZ+DjN8wvYCUM9QQP/d3Ir0HWwEgVQo4Kcb0fwMs0 J6NlkUPmeFAPJSpGAGgL6KxGXDxycFE36wOXBf2B5IYX3QaedKYfw6m9LhFT1lV650 RnjVQjM6zSeJcnf2wXcNasW6/2OIRQ2ToXhKZmXM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C0ABA60BE1 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Steven Rostedt , Ingo Molnar , Laura Abbott , Kees Cook , Anton Vorontsov , Rob Herring , devicetree@vger.kernel.org, Colin Cross , Jason Baron , Tony Luck , Arnd Bergmann , Catalin Marinas , Will Deacon , Joel Fernandes , Masami Hiramatsu , Joe Perches , Jim Cromie Cc: Rajendra Nayak , Vivek Gautam , Sibi Sankar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Greg Kroah-Hartman , Ingo Molnar , Tom Zanussi , Prasad Sodagudi , tsoni@codeaurora.org, Bryan Huntsman , Tingwei Zhang , Sai Prakash Ranjan Subject: [PATCH 5/6] arm64/io: Add header for instrumentation of io operations Date: Sun, 9 Sep 2018 01:57:06 +0530 Message-Id: X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The new asm-generic/io-instrumented.h will keep arch code clean and separate from instrumented version which traces io register accesses. This instrumented header can later be included in arm as well for tracing io register accesses. Suggested-by: Will Deacon Signed-off-by: Sai Prakash Ranjan Acked-by: Steven Rostedt (VMware) --- arch/arm64/include/asm/io.h | 25 ++++++--------- include/asm-generic/io-instrumented.h | 45 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 include/asm-generic/io-instrumented.h diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 35b2e50f17fb..768a6a8c5778 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -36,32 +36,27 @@ /* * Generic IO read/write. These perform native-endian accesses. */ -#define __raw_writeb __raw_writeb -static inline void __raw_writeb(u8 val, volatile void __iomem *addr) +static inline void arch_raw_writeb(u8 val, volatile void __iomem *addr) { asm volatile("strb %w0, [%1]" : : "rZ" (val), "r" (addr)); } -#define __raw_writew __raw_writew -static inline void __raw_writew(u16 val, volatile void __iomem *addr) +static inline void arch_raw_writew(u16 val, volatile void __iomem *addr) { asm volatile("strh %w0, [%1]" : : "rZ" (val), "r" (addr)); } -#define __raw_writel __raw_writel -static inline void __raw_writel(u32 val, volatile void __iomem *addr) +static inline void arch_raw_writel(u32 val, volatile void __iomem *addr) { asm volatile("str %w0, [%1]" : : "rZ" (val), "r" (addr)); } -#define __raw_writeq __raw_writeq -static inline void __raw_writeq(u64 val, volatile void __iomem *addr) +static inline void arch_raw_writeq(u64 val, volatile void __iomem *addr) { asm volatile("str %x0, [%1]" : : "rZ" (val), "r" (addr)); } -#define __raw_readb __raw_readb -static inline u8 __raw_readb(const volatile void __iomem *addr) +static inline u8 arch_raw_readb(const volatile void __iomem *addr) { u8 val; asm volatile(ALTERNATIVE("ldrb %w0, [%1]", @@ -71,8 +66,7 @@ static inline u8 __raw_readb(const volatile void __iomem *addr) return val; } -#define __raw_readw __raw_readw -static inline u16 __raw_readw(const volatile void __iomem *addr) +static inline u16 arch_raw_readw(const volatile void __iomem *addr) { u16 val; @@ -83,8 +77,7 @@ static inline u16 __raw_readw(const volatile void __iomem *addr) return val; } -#define __raw_readl __raw_readl -static inline u32 __raw_readl(const volatile void __iomem *addr) +static inline u32 arch_raw_readl(const volatile void __iomem *addr) { u32 val; asm volatile(ALTERNATIVE("ldr %w0, [%1]", @@ -94,8 +87,7 @@ static inline u32 __raw_readl(const volatile void __iomem *addr) return val; } -#define __raw_readq __raw_readq -static inline u64 __raw_readq(const volatile void __iomem *addr) +static inline u64 arch_raw_readq(const volatile void __iomem *addr) { u64 val; asm volatile(ALTERNATIVE("ldr %0, [%1]", @@ -193,6 +185,7 @@ extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size); #define iowrite32be(v,p) ({ __iowmb(); __raw_writel((__force __u32)cpu_to_be32(v), p); }) #define iowrite64be(v,p) ({ __iowmb(); __raw_writeq((__force __u64)cpu_to_be64(v), p); }) +#include #include /* diff --git a/include/asm-generic/io-instrumented.h b/include/asm-generic/io-instrumented.h new file mode 100644 index 000000000000..7b050e2487ed --- /dev/null +++ b/include/asm-generic/io-instrumented.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_IO_INSTRUMENTED_H +#define _ASM_GENERIC_IO_INSTRUMENTED_H + +#if defined(CONFIG_TRACING_EVENTS_IO) +#include + +extern struct tracepoint __tracepoint_io_write; +extern struct tracepoint __tracepoint_io_read; +#define io_tracepoint_active(t) static_key_false(&(t).key) +extern void do_trace_io_write(const char *type, void *addr); +extern void do_trace_io_read(const char *type, void *addr); +#else +#define io_tracepoint_active(t) false +static inline void do_trace_io_write(const char *type, void *addr) {} +static inline void do_trace_io_read(const char *type, void *addr) {} +#endif /* CONFIG_TRACING_EVENTS_IO */ + +#define __raw_write(v, a, _l) ({ \ + volatile void __iomem *_a = (a); \ + if (io_tracepoint_active(__tracepoint_io_write)) \ + do_trace_io_write(__stringify(write##_l), (void __force *)(_a));\ + arch_raw_write##_l((v), _a); \ + }) + +#define __raw_writeb(v, a) __raw_write((v), a, b) +#define __raw_writew(v, a) __raw_write((v), a, w) +#define __raw_writel(v, a) __raw_write((v), a, l) +#define __raw_writeq(v, a) __raw_write((v), a, q) + +#define __raw_read(a, _l, _t) ({ \ + _t __a; \ + const volatile void __iomem *_a = (a); \ + if (io_tracepoint_active(__tracepoint_io_read)) \ + do_trace_io_read(__stringify(read##_l), (void __force *)(_a)); \ + __a = arch_raw_read##_l(_a); \ + __a; \ + }) + +#define __raw_readb(a) __raw_read((a), b, u8) +#define __raw_readw(a) __raw_read((a), w, u16) +#define __raw_readl(a) __raw_read((a), l, u32) +#define __raw_readq(a) __raw_read((a), q, u64) + +#endif /* _ASM_GENERIC_IO_INSTRUMENTED_H */ From patchwork Sat Sep 8 20:27:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Prakash Ranjan X-Patchwork-Id: 10593175 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B02D614BD for ; Sat, 8 Sep 2018 20:29:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E78729FDE for ; Sat, 8 Sep 2018 20:29:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9246F29FF3; Sat, 8 Sep 2018 20:29:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0648329FDE for ; Sat, 8 Sep 2018 20:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727794AbeIIBQD (ORCPT ); Sat, 8 Sep 2018 21:16:03 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:49640 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727616AbeIIBQD (ORCPT ); Sat, 8 Sep 2018 21:16:03 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id AA1B060B13; Sat, 8 Sep 2018 20:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438544; bh=dcL3X7HX8ZGPU0DB9PsLxCltgveK0h3iXWnF5pjRVPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hF0Sqty3xJkmFLuqZqpZOln93XWsjDwBx5FBF+dFP6vj4k7RVzS/YMNj3XZydOvHd h1No5e575pcy3JlBacATehZejm8Il5InjUT/Upui8POBla0GFeVbVjlgnbzJEd/4o/ V/p+t1bX0MFHHmKY8Ouug6H0a4cvwvC+oP7s9xUQ= Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8CFC460C1C; Sat, 8 Sep 2018 20:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1536438534; bh=dcL3X7HX8ZGPU0DB9PsLxCltgveK0h3iXWnF5pjRVPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SkqE3K7bQaKZCAfx06p9amAaL8dor2EU0VQi4ypFPCupbiJOg3YgUI13vkt8O54XF vRS8xd9nR87+YCstYqOmNNpaFmZYqDEepgQIVZDratLMUh3Xj77O5e/SftA/dYnazA xFAFvTt3ugOQyTUBxPJMiAXt/nMnJlb8ROJhBuwI= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8CFC460C1C Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Steven Rostedt , Ingo Molnar , Laura Abbott , Kees Cook , Anton Vorontsov , Rob Herring , devicetree@vger.kernel.org, Colin Cross , Jason Baron , Tony Luck , Arnd Bergmann , Catalin Marinas , Will Deacon , Joel Fernandes , Masami Hiramatsu , Joe Perches , Jim Cromie Cc: Rajendra Nayak , Vivek Gautam , Sibi Sankar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Greg Kroah-Hartman , Ingo Molnar , Tom Zanussi , Prasad Sodagudi , tsoni@codeaurora.org, Bryan Huntsman , Tingwei Zhang , Sai Prakash Ranjan Subject: [PATCH 6/6] dynamic_debug: Add flag for dynamic event tracing Date: Sun, 9 Sep 2018 01:57:07 +0530 Message-Id: <3f0166ff19ae44dbf92cbb239ebf25fa8a4f243c.1536430404.git.saiprakash.ranjan@codeaurora.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Debugging a specific driver or subsystem can be a lot easier if we can trace events specific to that driver or subsystem. This type of filtering can be achieved using existing dynamic debug library which provides a way to filter based on files, functions and modules. Using this, provide an additional flag 'e' to filter event tracing to specified input. For example, tracing all IO read/write can be overwhelming and of no use when debugging a specific driver or a subsystem. So switch to dynamic event tracing for register accesses. Example for tracing register accesses in drivers/soc/qcom/* and the pstore output is given below: # dyndbg="file drivers/soc/qcom/* +e" trace_event=io tp_pstore # reboot -f # mount -t pstore pstore /sys/fs/pstore # cat /sys/fs/pstore/event-ramoops-0 io_write: type=writel cpu=1 ts:1423596253 data=0xffff00000d2065a4 caller=qcom_smsm_probe+0x524/0x670 io_write: type=writel cpu=1 ts:1423945889 data=0xffff00000d206608 caller=qcom_smsm_probe+0x524/0x670 Note: Tracing is activated only when flag is enabled either through command line or through dynamic debug control file. Signed-off-by: Sai Prakash Ranjan --- include/asm-generic/io-instrumented.h | 28 +++++++++++++++++++++++++-- include/linux/dynamic_debug.h | 1 + lib/dynamic_debug.c | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/io-instrumented.h b/include/asm-generic/io-instrumented.h index 7b050e2487ed..023f28571ea3 100644 --- a/include/asm-generic/io-instrumented.h +++ b/include/asm-generic/io-instrumented.h @@ -2,6 +2,8 @@ #ifndef _ASM_GENERIC_IO_INSTRUMENTED_H #define _ASM_GENERIC_IO_INSTRUMENTED_H +#include + #if defined(CONFIG_TRACING_EVENTS_IO) #include @@ -19,7 +21,7 @@ static inline void do_trace_io_read(const char *type, void *addr) {} #define __raw_write(v, a, _l) ({ \ volatile void __iomem *_a = (a); \ if (io_tracepoint_active(__tracepoint_io_write)) \ - do_trace_io_write(__stringify(write##_l), (void __force *)(_a));\ + dynamic_io_write(__stringify(write##_l), (void __force *)(_a)); \ arch_raw_write##_l((v), _a); \ }) @@ -32,7 +34,7 @@ static inline void do_trace_io_read(const char *type, void *addr) {} _t __a; \ const volatile void __iomem *_a = (a); \ if (io_tracepoint_active(__tracepoint_io_read)) \ - do_trace_io_read(__stringify(read##_l), (void __force *)(_a)); \ + dynamic_io_read(__stringify(read##_l), (void __force *)(_a)); \ __a = arch_raw_read##_l(_a); \ __a; \ }) @@ -42,4 +44,26 @@ static inline void do_trace_io_read(const char *type, void *addr) {} #define __raw_readl(a) __raw_read((a), l, u32) #define __raw_readq(a) __raw_read((a), q, u64) +#if defined(CONFIG_DYNAMIC_DEBUG) && defined(CONFIG_TRACING_EVENTS_IO) +#define dynamic_io_write(type, addr) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, type); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_EVENT)) \ + do_trace_io_write(type, addr); \ +} while (0) + +#define dynamic_io_read(type, addr) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, type); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_EVENT)) \ + do_trace_io_read(type, addr); \ +} while (0) +#elif defined(CONFIG_TRACING_EVENTS_IO) +#define dynamic_io_write(type, addr) do_trace_io_write(type, addr) +#define dynamic_io_read(type, addr) do_trace_io_read(type, addr) +#else +#define dynamic_io_write(type, addr) +#define dynamic_io_read(type, addr) +#endif /* CONFIG_DYNAMIC_DEBUG && CONFIG_TRACING_EVENTS_IO */ + #endif /* _ASM_GENERIC_IO_INSTRUMENTED_H */ diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 2fd8006153c3..14e595c51002 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -32,6 +32,7 @@ struct _ddebug { #define _DPRINTK_FLAGS_INCL_FUNCNAME (1<<2) #define _DPRINTK_FLAGS_INCL_LINENO (1<<3) #define _DPRINTK_FLAGS_INCL_TID (1<<4) +#define _DPRINTK_FLAGS_EVENT (1<<5) #if defined DEBUG #define _DPRINTK_FLAGS_DEFAULT _DPRINTK_FLAGS_PRINT #else diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index c7c96bc7654a..694957a8ae54 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -78,6 +78,7 @@ static inline const char *trim_prefix(const char *path) static struct { unsigned flag:8; char opt_char; } opt_array[] = { { _DPRINTK_FLAGS_PRINT, 'p' }, + { _DPRINTK_FLAGS_EVENT, 'e' }, { _DPRINTK_FLAGS_INCL_MODNAME, 'm' }, { _DPRINTK_FLAGS_INCL_FUNCNAME, 'f' }, { _DPRINTK_FLAGS_INCL_LINENO, 'l' },