From: Jiri Olsa <jolsa@redhat.com>
To: rostedt@goodmis.org, fweisbec@gmail.com, mingo@redhat.com
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCHv2 01/10] tracing/filter: Use static allocation for filter predicates
Date: Thu, 11 Aug 2011 16:25:45 +0200 [thread overview]
Message-ID: <1313072754-4620-2-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1313072754-4620-1-git-send-email-jolsa@redhat.com>
Don't dynamically allocate filter_pred struct, use static memory.
This way we can get rid of the code managing the dynamic filter_pred
struct object.
The create_pred function integrates create_logical_pred function.
This way the static predicate memory is returned only from
one place.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
kernel/trace/trace_events_filter.c | 57 ++++++++++--------------------------
1 files changed, 16 insertions(+), 41 deletions(-)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 256764e..cb295a1 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -630,11 +630,7 @@ find_event_field(struct ftrace_event_call *call, char *name)
static void filter_free_pred(struct filter_pred *pred)
{
- if (!pred)
- return;
-
kfree(pred->field_name);
- kfree(pred);
}
static void filter_clear_pred(struct filter_pred *pred)
@@ -1302,39 +1298,30 @@ parse_operand:
return 0;
}
-static struct filter_pred *create_pred(int op, char *operand1, char *operand2)
+static struct filter_pred *create_pred(struct filter_parse_state *ps,
+ int op, char *operand1, char *operand2)
{
- struct filter_pred *pred;
+ static struct filter_pred pred;
- pred = kzalloc(sizeof(*pred), GFP_KERNEL);
- if (!pred)
- return NULL;
+ memset(&pred, 0, sizeof(pred));
+ pred.op = op;
- pred->field_name = kstrdup(operand1, GFP_KERNEL);
- if (!pred->field_name) {
- kfree(pred);
+ if (op == OP_AND || op == OP_OR)
+ return &pred;
+
+ if (!operand1 || !operand2) {
+ parse_error(ps, FILT_ERR_MISSING_FIELD, 0);
return NULL;
}
- strcpy(pred->regex.pattern, operand2);
- pred->regex.len = strlen(pred->regex.pattern);
-
- pred->op = op;
-
- return pred;
-}
-
-static struct filter_pred *create_logical_pred(int op)
-{
- struct filter_pred *pred;
-
- pred = kzalloc(sizeof(*pred), GFP_KERNEL);
- if (!pred)
+ pred.field_name = kstrdup(operand1, GFP_KERNEL);
+ if (!pred.field_name)
return NULL;
- pred->op = op;
+ strcpy(pred.regex.pattern, operand2);
+ pred.regex.len = strlen(pred.regex.pattern);
- return pred;
+ return &pred;
}
static int check_preds(struct filter_parse_state *ps)
@@ -1643,19 +1630,7 @@ static int replace_preds(struct ftrace_event_call *call,
goto fail;
}
- if (elt->op == OP_AND || elt->op == OP_OR) {
- pred = create_logical_pred(elt->op);
- goto add_pred;
- }
-
- if (!operand1 || !operand2) {
- parse_error(ps, FILT_ERR_MISSING_FIELD, 0);
- err = -EINVAL;
- goto fail;
- }
-
- pred = create_pred(elt->op, operand1, operand2);
-add_pred:
+ pred = create_pred(ps, elt->op, operand1, operand2);
if (!pred) {
err = -ENOMEM;
goto fail;
--
1.7.1
next prev parent reply other threads:[~2011-08-11 14:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-04 10:08 [PATCH 0/10] ftrace/filter: Trace events filtering related fixies Jiri Olsa
2011-08-04 10:08 ` [PATCH 01/10] tracing/filter: Use static allocation for filter predicates Jiri Olsa
2011-08-04 10:08 ` [PATCH 02/10] tracing/filter: Separate predicate init and filter addition Jiri Olsa
2011-08-10 20:51 ` Steven Rostedt
2011-08-04 10:08 ` [PATCH 03/10] tracing/filter: Remove field_name from filter_pred struct Jiri Olsa
2011-08-04 10:08 ` [PATCH 04/10] tracing/filter: Simplify tracepoint event lookup Jiri Olsa
2011-08-04 10:08 ` [PATCH 05/10] tracing/filter: Unify predicate tree walking, change check_pred_tree function to use it Jiri Olsa
2011-08-04 10:08 ` [PATCH 06/10] tracing/filter: Change count_leafs function to use walk_pred_tree Jiri Olsa
2011-08-10 21:05 ` Steven Rostedt
2011-08-04 10:08 ` [PATCH 07/10] tracing/filter: Change fold_pred_tree " Jiri Olsa
2011-08-04 10:08 ` [PATCH 08/10] tracing/filter: Change fold_pred " Jiri Olsa
2011-08-04 10:08 ` [PATCH 09/10] tracing/filter: Change filter_match_preds " Jiri Olsa
2011-08-10 21:14 ` Steven Rostedt
2011-08-10 21:16 ` Steven Rostedt
2011-08-04 10:08 ` [PATCH 10/10] tracing/filter: Add startup tests for events filter Jiri Olsa
2011-08-04 11:22 ` [PATCHv2 " Jiri Olsa
2011-08-10 21:24 ` Steven Rostedt
2011-08-10 21:25 ` [PATCH 0/10] ftrace/filter: Trace events filtering related fixies Steven Rostedt
2011-08-11 14:21 ` Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 " Jiri Olsa
2011-08-11 14:25 ` Jiri Olsa [this message]
2011-08-11 14:25 ` [PATCHv2 02/10] tracing/filter: Separate predicate init and filter addition Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 03/10] tracing/filter: Remove field_name from filter_pred struct Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 04/10] tracing/filter: Simplify tracepoint event lookup Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 05/10] tracing/filter: Unify predicate tree walking, change check_pred_tree function to use it Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 06/10] tracing/filter: Change count_leafs function to use walk_pred_tree Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 07/10] tracing/filter: Change fold_pred_tree " Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 08/10] tracing/filter: Change fold_pred " Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 09/10] tracing/filter: Change filter_match_preds " Jiri Olsa
2011-08-11 14:25 ` [PATCHv2 10/10] tracing/filter: Add startup tests for events filter Jiri Olsa
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=1313072754-4620-2-git-send-email-jolsa@redhat.com \
--to=jolsa@redhat.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
/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
all inboxes | Powered by JetHome®