From: "K.Prasad" <prasad@linux.vnet.ibm.com>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"K.Prasad" <prasad@linux.vnet.ibm.com>
Subject: [Patch 2/3] ksym_tracer: Allow bulk removal using empty or wildcard string input
Date: Fri, 19 Jun 2009 22:55:12 +0530 [thread overview]
Message-ID: <20090619172512.GC26071@in.ibm.com> (raw)
In-Reply-To: 20090619172035.443923337@prasadkr_t60p.in.ibm.com
[-- Attachment #1: enable_new_features_02 --]
[-- Type: text/plain, Size: 4148 bytes --]
Accept an empty string or wildcard input (of the form *:---) as input for
ksym_trace_filter to perform bulk removal of all monitored entries.
Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com>
---
kernel/trace/trace_ksym.c | 75 +++++++++++++++++++++++++---------------------
1 file changed, 42 insertions(+), 33 deletions(-)
Index: linux-2.6-tip.hbkpt/kernel/trace/trace_ksym.c
===================================================================
--- linux-2.6-tip.hbkpt.orig/kernel/trace/trace_ksym.c
+++ linux-2.6-tip.hbkpt/kernel/trace/trace_ksym.c
@@ -138,6 +138,34 @@ static int ksym_trace_get_access_type(ch
return access;
}
+static void ksym_trace_reset(struct trace_array *tr)
+{
+ struct trace_ksym *entry;
+ struct hlist_node *node, *node1;
+
+ ksym_tracing_enabled = 0;
+
+ mutex_lock(&ksym_tracer_mutex);
+ hlist_for_each_entry_safe(entry, node, node1, &ksym_filter_head,
+ ksym_hlist) {
+ unregister_kernel_hw_breakpoint(entry->ksym_hbp);
+ ksym_filter_entry_count--;
+ hlist_del_rcu(&(entry->ksym_hlist));
+ synchronize_rcu();
+ /* Free the 'input_string' only if reset
+ * after startup self-test
+ */
+#ifdef CONFIG_FTRACE_SELFTEST
+ if (strncmp(entry->ksym_hbp->info.name, KSYM_SELFTEST_ENTRY,
+ strlen(KSYM_SELFTEST_ENTRY)) != 0)
+#endif /* CONFIG_FTRACE_SELFTEST*/
+ kfree(entry->ksym_hbp->info.name);
+ kfree(entry->ksym_hbp);
+ kfree(entry);
+ }
+ mutex_unlock(&ksym_tracer_mutex);
+}
+
/*
* There can be several possible malformed requests and we attempt to capture
* all of them. We enumerate some of the rules
@@ -163,7 +191,7 @@ static int parse_ksym_trace_str(char *in
/* Check for malformed request: (2), (1) and (5) */
if ((!input_string) ||
(strlen(input_string) != (KSYM_TRACER_OP_LEN + 1)) ||
- (*addr == 0))
+ ((*addr == 0) && strncmp(*ksymname, "*", strlen("*"))))
goto return_code;
ret = ksym_trace_get_access_type(input_string);
@@ -211,6 +239,7 @@ int process_new_ksym_entry(char *ksymnam
}
hlist_add_head_rcu(&(entry->ksym_hlist), &ksym_filter_head);
ksym_filter_entry_count++;
+ ksym_tracing_enabled = 1;
return 0;
}
@@ -220,7 +249,7 @@ static ssize_t ksym_trace_filter_read(st
{
struct trace_ksym *entry;
struct hlist_node *node;
- char buf[KSYM_FILTER_ENTRY_LEN * KSYM_TRACER_MAX];
+ char buf[KSYM_FILTER_ENTRY_LEN * KSYM_TRACER_MAX] = "\0";
ssize_t ret, cnt = 0;
mutex_lock(&ksym_tracer_mutex);
@@ -251,9 +280,11 @@ static ssize_t ksym_trace_filter_write(s
unsigned long ksym_addr = 0;
int ret, op, changed = 0;
- /* Ignore echo "" > ksym_trace_filter */
- if (count == 0)
- return 0;
+ /* Clear all breakpoint requests if echo "" > ksym_trace_filter */
+ if (count == 1) {
+ ksym_trace_reset(NULL);
+ return count;
+ }
input_string = kzalloc(count, GFP_KERNEL);
if (!input_string)
@@ -269,6 +300,12 @@ static ssize_t ksym_trace_filter_write(s
kfree(input_string);
return ret;
}
+ /* Clear all breakpoints if echo "*:---" > ksym_trace_filter */
+ if ((strncmp(ksymname, "*", strlen("*")) == 0) && (op == 0)) {
+ ksym_trace_reset(NULL);
+ kfree(input_string);
+ return count;
+ }
mutex_lock(&ksym_tracer_mutex);
@@ -325,34 +362,6 @@ static const struct file_operations ksym
.write = ksym_trace_filter_write,
};
-static void ksym_trace_reset(struct trace_array *tr)
-{
- struct trace_ksym *entry;
- struct hlist_node *node, *node1;
-
- ksym_tracing_enabled = 0;
-
- mutex_lock(&ksym_tracer_mutex);
- hlist_for_each_entry_safe(entry, node, node1, &ksym_filter_head,
- ksym_hlist) {
- unregister_kernel_hw_breakpoint(entry->ksym_hbp);
- ksym_filter_entry_count--;
- hlist_del_rcu(&(entry->ksym_hlist));
- synchronize_rcu();
- /* Free the 'input_string' only if reset
- * after startup self-test
- */
-#ifdef CONFIG_FTRACE_SELFTEST
- if (strncmp(entry->ksym_hbp->info.name, KSYM_SELFTEST_ENTRY,
- strlen(KSYM_SELFTEST_ENTRY)) != 0)
-#endif /* CONFIG_FTRACE_SELFTEST*/
- kfree(entry->ksym_hbp->info.name);
- kfree(entry->ksym_hbp);
- kfree(entry);
- }
- mutex_unlock(&ksym_tracer_mutex);
-}
-
static int ksym_trace_init(struct trace_array *tr)
{
int cpu, ret = 0;
next prev parent reply other threads:[~2009-06-19 17:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090619172035.443923337@prasadkr_t60p.in.ibm.com>
2009-06-19 17:24 ` [Patch 1/3] ksym_tracer: Eliminate trace concatenation and machine stall issues post removal K.Prasad
2009-06-19 23:03 ` Frederic Weisbecker
2009-06-20 3:57 ` K.Prasad
2009-06-23 14:10 ` Frederic Weisbecker
2009-06-19 17:25 ` K.Prasad [this message]
2009-06-19 23:16 ` [Patch 2/3] ksym_tracer: Allow bulk removal using empty or wildcard string input Frederic Weisbecker
2009-06-20 13:37 ` K.Prasad
2009-06-22 7:31 ` Frederic Weisbecker
2009-06-20 13:35 ` [Patch 2/3] ksym_tracer: Allow bulk removal using empty or wildcard string input - ver II K.Prasad
2009-06-23 14:30 ` Frederic Weisbecker
2009-06-19 17:25 ` [Patch 3/3] ksym_tracer: Documentation containing usage guide for ksym tracer K.Prasad
2009-06-19 23:24 ` Frederic Weisbecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090619172512.GC26071@in.ibm.com \
--to=prasad@linux.vnet.ibm.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox