Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753811AbdIHOCH (ORCPT ); Fri, 8 Sep 2017 10:02:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52462 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751907AbdIHOCF (ORCPT ); Fri, 8 Sep 2017 10:02:05 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 87104C047B6B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=zsun@redhat.com Date: Fri, 8 Sep 2017 10:02:04 -0400 (EDT) From: "Ziqian SUN (Zamir)" To: rostedt@goodmis.org, linux-kernel@vger.kernel.org Cc: mingo@redhat.com, karolherbst@gmail.com, ppaalanen@gmail.com, akpm@linux-foundation.org Message-ID: <1421464012.10956132.1504879324216.JavaMail.zimbra@redhat.com> In-Reply-To: <1504066770-19814-1-git-send-email-zsun@redhat.com> References: <1504066770-19814-1-git-send-email-zsun@redhat.com> Subject: Re: [PATCH v2] tracing: Ignore mmiotrace from kernel commandline MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.72.12.62, 10.4.195.21] Thread-Topic: tracing: Ignore mmiotrace from kernel commandline Thread-Index: PrWKaHalBg1THAccXPSZlhvmywdWeQ== X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 08 Sep 2017 14:02:05 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3937 Lines: 126 Hi Steve, Is this solution acceptable? Any suggestions? Thanks. ----- Original Message ----- > From: "Ziqian SUN (Zamir)" > > The mmiotrace tracer cannot be enabled with ftrace=mmiotrace in > kernel commandline. With this patch, a trace_noboot_tracer_list > is implemented and will be checked during system boot. If the > tracer declares itself as not for boot up, system will print out > a message and continue booting. > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=196557 > Signed-off-by: Ziqian SUN (Zamir) > --- > kernel/trace/trace.c | 34 +++++++++++++++++++++++++++++++++- > kernel/trace/trace.h | 11 +++++++++++ > kernel/trace/trace_mmiotrace.c | 4 ++++ > 3 files changed, 48 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index 44004d8..0d25b1e 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -319,6 +319,33 @@ void trace_free_pid_list(struct trace_pid_list > *pid_list) > kfree(pid_list); > } > > +struct mutex trace_noboot_tracer_lock; > + > +DEFINE_MUTEX(trace_noboot_tracer_lock); > +LIST_HEAD(trace_noboot_tracer_list); > + > +void trace_noboot_tracer_put(struct tracer_noboot *noboot_tracer) > +{ > + mutex_lock(&trace_noboot_tracer_lock); > + list_add(&noboot_tracer->list, &trace_noboot_tracer_list); > + mutex_unlock(&trace_noboot_tracer_lock); > +} > + > +bool trace_noboot_tracer_find(const char *str) > +{ > + mutex_lock(&trace_noboot_tracer_lock); > + struct tracer_noboot *ptr = NULL; > + > + list_for_each_entry(ptr, &trace_noboot_tracer_list, list) { > + if (strcmp(ptr->name, str) == 0) { > + mutex_unlock(&trace_noboot_tracer_lock); > + return true; > + } > + } > + mutex_unlock(&trace_noboot_tracer_lock); > + return false; > +} > + > /** > * trace_find_filtered_pid - check if a pid exists in a filtered_pid list > * @filtered_pids: The list of pids to check > @@ -1641,8 +1668,13 @@ int __init register_tracer(struct tracer *type) > if (strncmp(default_bootup_tracer, type->name, MAX_TRACER_SIZE)) > goto out_unlock; > > + /* If the tracer should not be enabled by kernel parameter */ > + if (trace_noboot_tracer_find(type->name)) { > + pr_warn("Tracer '%s' cannot be enabled during boot\n", type->name); > + goto out_unlock; > + } > + > printk(KERN_INFO "Starting tracer '%s'\n", type->name); > - /* Do we want this tracer to start on bootup? */ > tracing_set_tracer(&global_trace, type->name); > default_bootup_tracer = NULL; > > diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h > index 490ba22..23bc668 100644 > --- a/kernel/trace/trace.h > +++ b/kernel/trace/trace.h > @@ -502,6 +502,17 @@ enum { > TRACE_IRQ_BIT, > }; > > +/* > + * For tracer that cannot be enabled during boot time. > + */ > + > +struct tracer_noboot { > + const char *name; > + struct list_head list; > +}; > + > +void trace_noboot_tracer_put(struct tracer_noboot *noboot_tracer); > + > #define trace_recursion_set(bit) do { (current)->trace_recursion |= > (1<<(bit)); } while (0) > #define trace_recursion_clear(bit) do { (current)->trace_recursion &= > ~(1<<(bit)); } while (0) > #define trace_recursion_test(bit) ((current)->trace_recursion & (1<<(bit))) > diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c > index cd7480d..06aa0a5 100644 > --- a/kernel/trace/trace_mmiotrace.c > +++ b/kernel/trace/trace_mmiotrace.c > @@ -286,6 +286,10 @@ static enum print_line_t mmio_print_line(struct > trace_iterator *iter) > > __init static int init_mmio_trace(void) > { > + struct tracer_noboot mmio_notrace; > + > + mmio_notrace.name = "mmiotrace"; > + trace_noboot_tracer_put(&mmio_notrace); > return register_tracer(&mmio_tracer); > } > device_initcall(init_mmio_trace); > -- > 1.8.3.1 > > -- Ziqian SUN (Zamir) Red Hat Red Hat Software (Beijing) Co.,Ltd 1D86 6D4A 49CE 4BBD 72CF FCF5 D856 6E11 F2A0 525E