* [PATCH 1/7] cpumask: use new operators in kernel/trace
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
@ 2009-06-15 15:42 ` Steven Rostedt
2009-06-15 15:42 ` [PATCH 2/7] tracing: fix undeclared PAGE_SIZE in include/linux/trace_seq.h Steven Rostedt
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2009-06-15 15:42 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Rusty Russell
[-- Attachment #1: 0001-cpumask-use-new-operators-in-kernel-trace.patch --]
[-- Type: text/plain, Size: 1476 bytes --]
From: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
LKML-Reference: <200906122115.30787.rusty@rustcorp.com.au>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/kmemtrace.c | 2 +-
kernel/trace/ring_buffer.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/kmemtrace.c b/kernel/trace/kmemtrace.c
index 86cdf67..1edaa95 100644
--- a/kernel/trace/kmemtrace.c
+++ b/kernel/trace/kmemtrace.c
@@ -186,7 +186,7 @@ static int kmem_trace_init(struct trace_array *tr)
int cpu;
kmemtrace_array = tr;
- for_each_cpu_mask(cpu, cpu_possible_map)
+ for_each_cpu(cpu, cpu_possible_mask)
tracing_reset(tr, cpu);
kmemtrace_start_probes();
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 2e642b2..9c31c9f 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3105,7 +3105,7 @@ static int rb_cpu_notify(struct notifier_block *self,
switch (action) {
case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN:
- if (cpu_isset(cpu, *buffer->cpumask))
+ if (cpumask_test_cpu(cpu, buffer->cpumask))
return NOTIFY_OK;
buffer->buffers[cpu] =
@@ -3116,7 +3116,7 @@ static int rb_cpu_notify(struct notifier_block *self,
return NOTIFY_OK;
}
smp_wmb();
- cpu_set(cpu, *buffer->cpumask);
+ cpumask_set_cpu(cpu, buffer->cpumask);
break;
case CPU_DOWN_PREPARE:
case CPU_DOWN_PREPARE_FROZEN:
--
1.6.3.1
--
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 2/7] tracing: fix undeclared PAGE_SIZE in include/linux/trace_seq.h
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
2009-06-15 15:42 ` [PATCH 1/7] cpumask: use new operators in kernel/trace Steven Rostedt
@ 2009-06-15 15:42 ` Steven Rostedt
2009-06-15 15:42 ` [PATCH 3/7] tracing: fix a typo in tracing_cpumask_write() Steven Rostedt
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2009-06-15 15:42 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Pekka Enberg,
Wu Zhangjin
[-- Attachment #1: 0002-tracing-fix-undeclared-PAGE_SIZE-in-include-linux-tr.patch --]
[-- Type: text/plain, Size: 1117 bytes --]
From: Wu Zhangjin <wuzj@lemote.com>
when compiling linux-mips with kmemtrace enabled, there will be an
error:
include/linux/trace_seq.h:12: error: 'PAGE_SIZE' undeclared here (not in
a function)
I checked the source code and found trace_seq.h used PAGE_SIZE but not
included the relative header file, so, fix it via adding the header file
<asm/page.h>
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Wu Zhangjin <wuzj@lemote.com>
LKML-Reference: <1244962350-28702-1-git-send-email-wuzhangjin@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/linux/trace_seq.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h
index c68bccb..c134dd1 100644
--- a/include/linux/trace_seq.h
+++ b/include/linux/trace_seq.h
@@ -3,6 +3,8 @@
#include <linux/fs.h>
+#include <asm/page.h>
+
/*
* Trace sequences are used to allow a function to call several other functions
* to create a string of data to use (up to a max of PAGE_SIZE.
--
1.6.3.1
--
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 3/7] tracing: fix a typo in tracing_cpumask_write()
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
2009-06-15 15:42 ` [PATCH 1/7] cpumask: use new operators in kernel/trace Steven Rostedt
2009-06-15 15:42 ` [PATCH 2/7] tracing: fix undeclared PAGE_SIZE in include/linux/trace_seq.h Steven Rostedt
@ 2009-06-15 15:42 ` Steven Rostedt
2009-06-15 15:42 ` [PATCH 4/7] tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation Steven Rostedt
` (4 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2009-06-15 15:42 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Li Zefan
[-- Attachment #1: 0003-tracing-fix-a-typo-in-tracing_cpumask_write.patch --]
[-- Type: text/plain, Size: 1572 bytes --]
From: Li Zefan <lizf@cn.fujitsu.com>
It's tracing_cpumask_new that should be kfree()ed.
This causes tracing_cpumask to be freed due to the typo:
# echo z > tracing_cpumask
bash: echo: write error: Invalid argument
And subsequent reads/writes to tracing_cpuamsk will access this
already-freed tracing_cpumask, thus may lead to crash.
[ Impact: fix leak and crash when writing invalid val to tracing_cpumask ]
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A35B86A.7070608@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8acd9b8..7355a38 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2191,11 +2191,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
return -ENOMEM;
- mutex_lock(&tracing_cpumask_update_lock);
err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
if (err)
goto err_unlock;
+ mutex_lock(&tracing_cpumask_update_lock);
+
local_irq_disable();
__raw_spin_lock(&ftrace_max_lock);
for_each_tracing_cpu(cpu) {
@@ -2223,8 +2224,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
return count;
err_unlock:
- mutex_unlock(&tracing_cpumask_update_lock);
- free_cpumask_var(tracing_cpumask);
+ free_cpumask_var(tracing_cpumask_new);
return err;
}
--
1.6.3.1
--
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 4/7] tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
` (2 preceding siblings ...)
2009-06-15 15:42 ` [PATCH 3/7] tracing: fix a typo in tracing_cpumask_write() Steven Rostedt
@ 2009-06-15 15:42 ` Steven Rostedt
2009-06-15 15:58 ` Ingo Molnar
2009-06-15 15:42 ` [PATCH 5/7] tracing/filters: operand can be negative Steven Rostedt
` (3 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Steven Rostedt @ 2009-06-15 15:42 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Li Zefan
[-- Attachment #1: 0004-tracing-replace-a-GFP_ATOMIC-with-GFP_KERNEL-allocat.patch --]
[-- Type: text/plain, Size: 801 bytes --]
From: Li Zefan <lizf@cn.fujitsu.com>
Atomic allocation is not needed here.
[ Impact: clean up of memory alloction type ]
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A35B898.2050607@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 7355a38..0f57f1b 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3627,7 +3627,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf,
struct trace_seq *s;
unsigned long cnt;
- s = kmalloc(sizeof(*s), GFP_ATOMIC);
+ s = kmalloc(sizeof(*s), GFP_KERNEL);
if (!s)
return ENOMEM;
--
1.6.3.1
--
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 5/7] tracing/filters: operand can be negative
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
` (3 preceding siblings ...)
2009-06-15 15:42 ` [PATCH 4/7] tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation Steven Rostedt
@ 2009-06-15 15:42 ` Steven Rostedt
2009-06-15 15:42 ` [PATCH 6/7] tracing/filters: strloc should be unsigned short Steven Rostedt
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2009-06-15 15:42 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Li Zefan
[-- Attachment #1: 0005-tracing-filters-operand-can-be-negative.patch --]
[-- Type: text/plain, Size: 1458 bytes --]
From: Li Zefan <lizf@cn.fujitsu.com>
This should be a bug:
# cat format
name: foo_bar
ID: 71
format:
...
field:int bar; offset:24; size:4;
# echo 'bar < 0' > filter
# echo 'bar < -1' > filter
bash: echo: write error: Invalid argument
[ Impact: fix to allow negative operand in filer expr ]
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A35B8DF.60400@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_events_filter.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index db6e54b..1d81923 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -546,6 +546,7 @@ static int filter_add_pred(struct filter_parse_state *ps,
filter_pred_fn_t fn;
unsigned long long val;
int string_type;
+ int ret;
pred->fn = filter_pred_none;
@@ -581,7 +582,11 @@ static int filter_add_pred(struct filter_parse_state *ps,
pred->not = 1;
return filter_add_pred_fn(ps, call, pred, fn);
} else {
- if (strict_strtoull(pred->str_val, 0, &val)) {
+ if (field->is_signed)
+ ret = strict_strtoll(pred->str_val, 0, &val);
+ else
+ ret = strict_strtoull(pred->str_val, 0, &val);
+ if (ret) {
parse_error(ps, FILT_ERR_ILLEGAL_INTVAL, 0);
return -EINVAL;
}
--
1.6.3.1
--
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 6/7] tracing/filters: strloc should be unsigned short
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
` (4 preceding siblings ...)
2009-06-15 15:42 ` [PATCH 5/7] tracing/filters: operand can be negative Steven Rostedt
@ 2009-06-15 15:42 ` Steven Rostedt
2009-06-15 15:42 ` [PATCH 7/7] ring-buffer: prevent adding write in discarded area Steven Rostedt
2009-06-15 15:56 ` [PATCH 0/7] [GIT PULL] updates for 2.6.31 Ingo Molnar
7 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2009-06-15 15:42 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker, Li Zefan
[-- Attachment #1: 0006-tracing-filters-strloc-should-be-unsigned-short.patch --]
[-- Type: text/plain, Size: 1303 bytes --]
From: Li Zefan <lizf@cn.fujitsu.com>
I forgot to update filter code accordingly in
"tracing/events: change the type of __str_loc_item to unsigned short"
(commt b0aae68cc5508f3c2fbf728988c954db4c8b8a53)
It can cause system crash:
# echo 1 > tracing/events/irq/irq_handler_entry/enable
# echo 'name == eth0' > tracing/events/irq/irq_handler_entry/filter
[ Impact: fix crash while filtering on __string() field ]
Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A35B905.3090500@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_events_filter.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 1d81923..b24ab0e 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -178,7 +178,7 @@ static int filter_pred_string(struct filter_pred *pred, void *event,
static int filter_pred_strloc(struct filter_pred *pred, void *event,
int val1, int val2)
{
- int str_loc = *(int *)(event + pred->offset);
+ unsigned short str_loc = *(unsigned short *)(event + pred->offset);
char *addr = (char *)(event + str_loc);
int cmp, match;
--
1.6.3.1
--
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH 7/7] ring-buffer: prevent adding write in discarded area
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
` (5 preceding siblings ...)
2009-06-15 15:42 ` [PATCH 6/7] tracing/filters: strloc should be unsigned short Steven Rostedt
@ 2009-06-15 15:42 ` Steven Rostedt
2009-06-15 15:56 ` [PATCH 0/7] [GIT PULL] updates for 2.6.31 Ingo Molnar
7 siblings, 0 replies; 10+ messages in thread
From: Steven Rostedt @ 2009-06-15 15:42 UTC (permalink / raw)
To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Frederic Weisbecker
[-- Attachment #1: 0007-ring-buffer-prevent-adding-write-in-discarded-area.patch --]
[-- Type: text/plain, Size: 3974 bytes --]
From: Steven Rostedt <srostedt@redhat.com>
This a very tight race where an interrupt could come in and not
have enough data to put into the end of a buffer page, and that
it would fail to write and need to go to the next page.
But if this happened when another writer was about to reserver
their data, and that writer has smaller data to reserve, then
it could succeed even though the interrupt moved the tail page.
To pervent that, if we fail to store data, and by subtracting the
amount we reserved we still have room for smaller data, we need
to fill that space with "discarded" data.
[ Impact: prevent race were buffer data may be lost ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ring_buffer.c | 68 ++++++++++++++++++++++++++++++++++++--------
1 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 9c31c9f..dbc0f93 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -205,6 +205,7 @@ EXPORT_SYMBOL_GPL(tracing_is_on);
#define RB_EVNT_HDR_SIZE (offsetof(struct ring_buffer_event, array))
#define RB_ALIGNMENT 4U
#define RB_MAX_SMALL_DATA (RB_ALIGNMENT * RINGBUF_TYPE_DATA_TYPE_LEN_MAX)
+#define RB_EVNT_MIN_SIZE 8U /* two 32bit words */
/* define RINGBUF_TYPE_DATA for 'case RINGBUF_TYPE_DATA:' */
#define RINGBUF_TYPE_DATA 0 ... RINGBUF_TYPE_DATA_TYPE_LEN_MAX
@@ -1170,6 +1171,59 @@ static unsigned rb_calculate_event_length(unsigned length)
return length;
}
+static inline void
+rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
+ struct buffer_page *tail_page,
+ unsigned long tail, unsigned long length)
+{
+ struct ring_buffer_event *event;
+
+ /*
+ * Only the event that crossed the page boundary
+ * must fill the old tail_page with padding.
+ */
+ if (tail >= BUF_PAGE_SIZE) {
+ local_sub(length, &tail_page->write);
+ return;
+ }
+
+ event = __rb_page_index(tail_page, tail);
+
+ /*
+ * If this event is bigger than the minimum size, then
+ * we need to be careful that we don't subtract the
+ * write counter enough to allow another writer to slip
+ * in on this page.
+ * We put in a discarded commit instead, to make sure
+ * that this space is not used again.
+ *
+ * If we are less than the minimum size, we don't need to
+ * worry about it.
+ */
+ if (tail > (BUF_PAGE_SIZE - RB_EVNT_MIN_SIZE)) {
+ /* No room for any events */
+
+ /* Mark the rest of the page with padding */
+ rb_event_set_padding(event);
+
+ /* Set the write back to the previous setting */
+ local_sub(length, &tail_page->write);
+ return;
+ }
+
+ /* Put in a discarded event */
+ event->array[0] = (BUF_PAGE_SIZE - tail) - RB_EVNT_HDR_SIZE;
+ event->type_len = RINGBUF_TYPE_PADDING;
+ /* time delta must be non zero */
+ event->time_delta = 1;
+ /* Account for this as an entry */
+ local_inc(&tail_page->entries);
+ local_inc(&cpu_buffer->entries);
+
+ /* Set write to end of buffer */
+ length = (tail + length) - BUF_PAGE_SIZE;
+ local_sub(length, &tail_page->write);
+}
static struct ring_buffer_event *
rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
@@ -1264,17 +1318,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
cpu_buffer->tail_page->page->time_stamp = *ts;
}
- /*
- * The actual tail page has moved forward.
- */
- if (tail < BUF_PAGE_SIZE) {
- /* Mark the rest of the page with padding */
- event = __rb_page_index(tail_page, tail);
- rb_event_set_padding(event);
- }
-
- /* Set the write back to the previous setting */
- local_sub(length, &tail_page->write);
+ rb_reset_tail(cpu_buffer, tail_page, tail, length);
/*
* If this was a commit entry that failed,
@@ -1293,7 +1337,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
out_reset:
/* reset write */
- local_sub(length, &tail_page->write);
+ rb_reset_tail(cpu_buffer, tail_page, tail, length);
if (likely(lock_taken))
__raw_spin_unlock(&cpu_buffer->lock);
--
1.6.3.1
--
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 0/7] [GIT PULL] updates for 2.6.31
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
` (6 preceding siblings ...)
2009-06-15 15:42 ` [PATCH 7/7] ring-buffer: prevent adding write in discarded area Steven Rostedt
@ 2009-06-15 15:56 ` Ingo Molnar
7 siblings, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2009-06-15 15:56 UTC (permalink / raw)
To: Steven Rostedt; +Cc: linux-kernel, Andrew Morton, Frederic Weisbecker
* Steven Rostedt <rostedt@goodmis.org> wrote:
> Hi Ingo,
>
> This patch series are fixes that should get into 2.6.31 (maybe some of
> them even into stable?).
>
> Please pull the latest tracing/ftrace tree, which can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tracing/ftrace
>
>
> Li Zefan (4):
> tracing: fix a typo in tracing_cpumask_write()
> tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation
> tracing/filters: operand can be negative
> tracing/filters: strloc should be unsigned short
>
> Rusty Russell (1):
> cpumask: use new operators in kernel/trace
>
> Steven Rostedt (1):
> ring-buffer: prevent adding write in discarded area
>
> Wu Zhangjin (1):
> tracing: fix undeclared 'PAGE_SIZE' in include/linux/trace_seq.h
>
> ----
> include/linux/trace_seq.h | 2 +
> kernel/trace/kmemtrace.c | 2 +-
> kernel/trace/ring_buffer.c | 72 +++++++++++++++++++++++++++++-------
> kernel/trace/trace.c | 8 ++--
> kernel/trace/trace_events_filter.c | 9 +++-
> 5 files changed, 72 insertions(+), 21 deletions(-)
Pulled into tracing/urgent - thanks Steve!
Ingo
^ permalink raw reply [flat|nested] 10+ messages in thread