2009-11-16 19:59:08

by Carsten Emde

[permalink] [raw]
Subject: [PATCH] ftrace: fix trace_marker output

When a string was written to <debugfs>/tracing/trace_marker, some
strange characters appeared in the trace output instead of the
string, since a vprint function erroneously called a vararg print
function with a va_list argument. This patch fixes the problem and
simplifies the related code.

Signed-off-by: Carsten Emde <[email protected]>

Index: linux-2.6.31.6-rt19/kernel/trace/trace.c
===================================================================
--- linux-2.6.31.6-rt19.orig/kernel/trace/trace.c
+++ linux-2.6.31.6-rt19/kernel/trace/trace.c
@@ -1376,10 +1376,11 @@ int trace_array_vprintk(struct trace_arr
pause_graph_tracing();
raw_local_irq_save(irq_flags);
__raw_spin_lock(&trace_buf_lock);
- len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
-
- len = min(len, TRACE_BUF_SIZE-1);
- trace_buf[len] = 0;
+ if (args == NULL) {
+ strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
+ len = strlen(trace_buf);
+ } else
+ len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);

size = sizeof(*entry) + len + 1;
buffer = tr->buffer;
@@ -1388,10 +1389,10 @@ int trace_array_vprintk(struct trace_arr
if (!event)
goto out_unlock;
entry = ring_buffer_event_data(event);
- entry->ip = ip;
+ entry->ip = ip;

memcpy(&entry->buf, trace_buf, len);
- entry->buf[len] = 0;
+ entry->buf[len] = '\0';
if (!filter_check_discard(call, entry, buffer, event))
ring_buffer_unlock_commit(buffer, event);

@@ -1408,7 +1409,7 @@ int trace_array_vprintk(struct trace_arr

int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
{
- return trace_array_printk(&global_trace, ip, fmt, args);
+ return trace_array_vprintk(&global_trace, ip, fmt, args);
}
EXPORT_SYMBOL_GPL(trace_vprintk);

@@ -3336,22 +3337,11 @@ tracing_entries_write(struct file *filp,
return cnt;
}

-static int mark_printk(const char *fmt, ...)
-{
- int ret;
- va_list args;
- va_start(args, fmt);
- ret = trace_vprintk(0, fmt, args);
- va_end(args);
- return ret;
-}
-
static ssize_t
tracing_mark_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *fpos)
{
char *buf;
- char *end;

if (tracing_disabled)
return -EINVAL;
@@ -3359,7 +3349,7 @@ tracing_mark_write(struct file *filp, co
if (cnt > TRACE_BUF_SIZE)
cnt = TRACE_BUF_SIZE;

- buf = kmalloc(cnt + 1, GFP_KERNEL);
+ buf = kmalloc(cnt + 2, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;

@@ -3367,14 +3357,13 @@ tracing_mark_write(struct file *filp, co
kfree(buf);
return -EFAULT;
}
+ if (buf[cnt-1] != '\n') {
+ buf[cnt] = '\n';
+ buf[cnt+1] = '\0';
+ } else
+ buf[cnt] = '\0';

- /* Cut from the first nil or newline. */
- buf[cnt] = '\0';
- end = strchr(buf, '\n');
- if (end)
- *end = '\0';
-
- cnt = mark_printk("%s\n", buf);
+ cnt = trace_vprintk(0, buf, NULL);
kfree(buf);
*fpos += cnt;


2009-11-16 22:15:55

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] ftrace: fix trace_marker output

On Mon, 2009-11-16 at 20:56 +0100, Carsten Emde wrote:
> When a string was written to <debugfs>/tracing/trace_marker, some
> strange characters appeared in the trace output instead of the
> string, since a vprint function erroneously called a vararg print
> function with a va_list argument. This patch fixes the problem and
> simplifies the related code.
>
> Signed-off-by: Carsten Emde <[email protected]>

Thanks Carsten! I'll pull this in. Perhaps this should go into 32.

-- Steve


2009-11-17 14:18:16

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] ftrace: fix trace_marker output

On Mon, 2009-11-16 at 20:56 +0100, Carsten Emde wrote:
>
> @@ -1408,7 +1409,7 @@ int trace_array_vprintk(struct trace_arr
>
> int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
> {
> - return trace_array_printk(&global_trace, ip, fmt, args);
> + return trace_array_vprintk(&global_trace, ip, fmt, args);
> }
> EXPORT_SYMBOL_GPL(trace_vprintk);

Applying the patch, I found that this part is already fixed upstream.
But I'll add the rest of your patch since it does have other fixes.

Thanks,

-- Steve

2009-11-17 15:20:19

by Steven Rostedt

[permalink] [raw]
Subject: [PATCH][GIT PULL][v2.6.32] tracing: Fix trace_marker output


Ingo,

Think we may be able to slip this into 32?

Please pull the latest tip/tracing/urgent tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/urgent


Carsten Emde (1):
tracing: Fix trace_marker output

----
kernel/trace/trace.c | 39 ++++++++++++++-------------------------
1 files changed, 14 insertions(+), 25 deletions(-)
---------------------------
commit c13d2f7c3231e873f30db92b96c8caa48f100f33
Author: Carsten Emde <[email protected]>
Date: Mon Nov 16 20:56:13 2009 +0100

tracing: Fix trace_marker output

When a string was written to <debugfs>/tracing/trace_marker, some
strange characters appeared in the trace output instead of the
string, since a vprint function erroneously called a vararg print
function with a va_list argument. This patch fixes the problem and
simplifies the related code.

Signed-off-by: Carsten Emde <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 03c7fd5..12b49ca 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1361,10 +1361,11 @@ int trace_array_vprintk(struct trace_array *tr,
pause_graph_tracing();
raw_local_irq_save(irq_flags);
__raw_spin_lock(&trace_buf_lock);
- len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
-
- len = min(len, TRACE_BUF_SIZE-1);
- trace_buf[len] = 0;
+ if (args == NULL) {
+ strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
+ len = strlen(trace_buf);
+ } else
+ len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);

size = sizeof(*entry) + len + 1;
buffer = tr->buffer;
@@ -1373,10 +1374,10 @@ int trace_array_vprintk(struct trace_array *tr,
if (!event)
goto out_unlock;
entry = ring_buffer_event_data(event);
- entry->ip = ip;
+ entry->ip = ip;

memcpy(&entry->buf, trace_buf, len);
- entry->buf[len] = 0;
+ entry->buf[len] = '\0';
if (!filter_check_discard(call, entry, buffer, event))
ring_buffer_unlock_commit(buffer, event);

@@ -3319,22 +3320,11 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
return cnt;
}

-static int mark_printk(const char *fmt, ...)
-{
- int ret;
- va_list args;
- va_start(args, fmt);
- ret = trace_vprintk(0, fmt, args);
- va_end(args);
- return ret;
-}
-
static ssize_t
tracing_mark_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *fpos)
{
char *buf;
- char *end;

if (tracing_disabled)
return -EINVAL;
@@ -3342,7 +3332,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
if (cnt > TRACE_BUF_SIZE)
cnt = TRACE_BUF_SIZE;

- buf = kmalloc(cnt + 1, GFP_KERNEL);
+ buf = kmalloc(cnt + 2, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;

@@ -3350,14 +3340,13 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
kfree(buf);
return -EFAULT;
}
+ if (buf[cnt-1] != '\n') {
+ buf[cnt] = '\n';
+ buf[cnt+1] = '\0';
+ } else
+ buf[cnt] = '\0';

- /* Cut from the first nil or newline. */
- buf[cnt] = '\0';
- end = strchr(buf, '\n');
- if (end)
- *end = '\0';
-
- cnt = mark_printk("%s\n", buf);
+ cnt = trace_vprintk(0, buf, NULL);
kfree(buf);
*fpos += cnt;


2009-11-22 10:25:21

by Carsten Emde

[permalink] [raw]
Subject: [tip:tracing/urgent] tracing: Fix trace_marker output

Commit-ID: c13d2f7c3231e873f30db92b96c8caa48f100f33
Gitweb: http://git.kernel.org/tip/c13d2f7c3231e873f30db92b96c8caa48f100f33
Author: Carsten Emde <[email protected]>
AuthorDate: Mon, 16 Nov 2009 20:56:13 +0100
Committer: Steven Rostedt <[email protected]>
CommitDate: Tue, 17 Nov 2009 09:19:06 -0500

tracing: Fix trace_marker output

When a string was written to <debugfs>/tracing/trace_marker, some
strange characters appeared in the trace output instead of the
string, since a vprint function erroneously called a vararg print
function with a va_list argument. This patch fixes the problem and
simplifies the related code.

Signed-off-by: Carsten Emde <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
kernel/trace/trace.c | 39 ++++++++++++++-------------------------
1 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 03c7fd5..12b49ca 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1361,10 +1361,11 @@ int trace_array_vprintk(struct trace_array *tr,
pause_graph_tracing();
raw_local_irq_save(irq_flags);
__raw_spin_lock(&trace_buf_lock);
- len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
-
- len = min(len, TRACE_BUF_SIZE-1);
- trace_buf[len] = 0;
+ if (args == NULL) {
+ strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
+ len = strlen(trace_buf);
+ } else
+ len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);

size = sizeof(*entry) + len + 1;
buffer = tr->buffer;
@@ -1373,10 +1374,10 @@ int trace_array_vprintk(struct trace_array *tr,
if (!event)
goto out_unlock;
entry = ring_buffer_event_data(event);
- entry->ip = ip;
+ entry->ip = ip;

memcpy(&entry->buf, trace_buf, len);
- entry->buf[len] = 0;
+ entry->buf[len] = '\0';
if (!filter_check_discard(call, entry, buffer, event))
ring_buffer_unlock_commit(buffer, event);

@@ -3319,22 +3320,11 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
return cnt;
}

-static int mark_printk(const char *fmt, ...)
-{
- int ret;
- va_list args;
- va_start(args, fmt);
- ret = trace_vprintk(0, fmt, args);
- va_end(args);
- return ret;
-}
-
static ssize_t
tracing_mark_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *fpos)
{
char *buf;
- char *end;

if (tracing_disabled)
return -EINVAL;
@@ -3342,7 +3332,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
if (cnt > TRACE_BUF_SIZE)
cnt = TRACE_BUF_SIZE;

- buf = kmalloc(cnt + 1, GFP_KERNEL);
+ buf = kmalloc(cnt + 2, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;

@@ -3350,14 +3340,13 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
kfree(buf);
return -EFAULT;
}
+ if (buf[cnt-1] != '\n') {
+ buf[cnt] = '\n';
+ buf[cnt+1] = '\0';
+ } else
+ buf[cnt] = '\0';

- /* Cut from the first nil or newline. */
- buf[cnt] = '\0';
- end = strchr(buf, '\n');
- if (end)
- *end = '\0';
-
- cnt = mark_printk("%s\n", buf);
+ cnt = trace_vprintk(0, buf, NULL);
kfree(buf);
*fpos += cnt;

2009-12-06 05:11:25

by Olof Johansson

[permalink] [raw]
Subject: Re: [tip:tracing/urgent] tracing: Fix trace_marker output

Hi,

On Sun, Nov 22, 2009 at 10:24:48AM +0000, tip-bot for Carsten Emde wrote:
> Commit-ID: c13d2f7c3231e873f30db92b96c8caa48f100f33
> Gitweb: http://git.kernel.org/tip/c13d2f7c3231e873f30db92b96c8caa48f100f33
> Author: Carsten Emde <[email protected]>
> AuthorDate: Mon, 16 Nov 2009 20:56:13 +0100
> Committer: Steven Rostedt <[email protected]>
> CommitDate: Tue, 17 Nov 2009 09:19:06 -0500
>
> tracing: Fix trace_marker output
>
> When a string was written to <debugfs>/tracing/trace_marker, some
> strange characters appeared in the trace output instead of the
> string, since a vprint function erroneously called a vararg print
> function with a va_list argument. This patch fixes the problem and
> simplifies the related code.

[...]

> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 03c7fd5..12b49ca 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -1361,10 +1361,11 @@ int trace_array_vprintk(struct trace_array *tr,
> pause_graph_tracing();
> raw_local_irq_save(irq_flags);
> __raw_spin_lock(&trace_buf_lock);
> - len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
> -
> - len = min(len, TRACE_BUF_SIZE-1);
> - trace_buf[len] = 0;
> + if (args == NULL) {
> + strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
> + len = strlen(trace_buf);
> + } else
> + len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);


Comparing a va_list with NULL is bogus. It's supposed to be treated like
an opaque type and only be manipulated with va_* accessors.

I wouldn't really care much, but it broke builds on some ARM platforms:

kernel/trace/trace.c: In function 'trace_array_vprintk':
kernel/trace/trace.c:1364: error: invalid operands to binary == (have 'va_list' and 'void *')
kernel/trace/trace.c: In function 'tracing_mark_write':
kernel/trace/trace.c:3349: error: incompatible type for argument 3 of 'trace_vprintk'

I see no real graceful way of solving this. What is really needed is a
trace_puts to output a string without applying format parsing to it.

I am going to do the lazy thing here, define a trace_puts() and call the
vprintk innards with it instead of duplicating code. It's probably not
the most graceful solution to the problem, but reporting a bug with a
bad patch tends to be better than reporting it without one at all. Better
suggestions are appreciated.

Oh, and I haven't had a chance to actually test and make sure it does
what is expected, since I don't have a testcase for it.


Signed-off-by: Olof Johansson <[email protected]>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 874f289..9b5bb4c 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1361,11 +1361,7 @@ int trace_array_vprintk(struct trace_array *tr,
pause_graph_tracing();
raw_local_irq_save(irq_flags);
__raw_spin_lock(&trace_buf_lock);
- if (args == NULL) {
- strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
- len = strlen(trace_buf);
- } else
- len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
+ len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);

size = sizeof(*entry) + len + 1;
buffer = tr->buffer;
@@ -1398,6 +1394,22 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args)
}
EXPORT_SYMBOL_GPL(trace_vprintk);

+static int __trace_puts(unsigned long ip, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, ip);
+ ret = trace_vprintk(ip, "%s", ap);
+ va_end(ap);
+ return ret;
+}
+
+static int trace_puts(unsigned long ip, const char *str)
+{
+ return __trace_puts(ip, str);
+}
+
enum trace_file_type {
TRACE_FILE_LAT_FMT = 1,
TRACE_FILE_ANNOTATE = 2,
@@ -3346,7 +3358,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
} else
buf[cnt] = '\0';

- cnt = trace_vprintk(0, buf, NULL);
+ cnt = trace_puts(0, buf);
kfree(buf);
*fpos += cnt;

2009-12-06 09:30:37

by Carsten Emde

[permalink] [raw]
Subject: Re: [tip:tracing/urgent] tracing: Fix trace_marker output

Olof,

> On Sun, Nov 22, 2009 at 10:24:48AM +0000, tip-bot for Carsten Emde wrote:
>> Commit-ID: c13d2f7c3231e873f30db92b96c8caa48f100f33
>> Gitweb: http://git.kernel.org/tip/c13d2f7c3231e873f30db92b96c8caa48f100f33
>> Author: Carsten Emde<[email protected]>
>> AuthorDate: Mon, 16 Nov 2009 20:56:13 +0100
>> Committer: Steven Rostedt<[email protected]>
>> CommitDate: Tue, 17 Nov 2009 09:19:06 -0500
>> tracing: Fix trace_marker output
>> When a string was written to<debugfs>/tracing/trace_marker, some
>> strange characters appeared in the trace output instead of the
>> string, since a vprint function erroneously called a vararg print
>> function with a va_list argument. This patch fixes the problem and
>> simplifies the related code.
>
> [...]
>
>> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
>> index 03c7fd5..12b49ca 100644
>> --- a/kernel/trace/trace.c
>> +++ b/kernel/trace/trace.c
>> @@ -1361,10 +1361,11 @@ int trace_array_vprintk(struct trace_array *tr,
>> pause_graph_tracing();
>> raw_local_irq_save(irq_flags);
>> __raw_spin_lock(&trace_buf_lock);
>> - len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
>> -
>> - len = min(len, TRACE_BUF_SIZE-1);
>> - trace_buf[len] = 0;
>> + if (args == NULL) {
>> + strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
>> + len = strlen(trace_buf);
>> + } else
>> + len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
> Comparing a va_list with NULL is bogus. It's supposed to be treated like
> an opaque type and only be manipulated with va_* accessors.
>
> I wouldn't really care much, but it broke builds on some ARM platforms:
>
> kernel/trace/trace.c: In function 'trace_array_vprintk':
> kernel/trace/trace.c:1364: error: invalid operands to binary == (have 'va_list' and 'void *')
> kernel/trace/trace.c: In function 'tracing_mark_write':
> kernel/trace/trace.c:3349: error: incompatible type for argument 3 of 'trace_vprintk'
Oops, sorry. Didn't know that the gcc warn/error level is so much
different across platforms.

>[..]
> Oh, and I haven't had a chance to actually test and make sure it does
> what is expected, since I don't have a testcase for it.
The testcase is:
# cd /sys/kernel/debug/tracing/
[root@deliv1 tracing]# echo "I am a marker" >trace_marker
[root@deliv1 tracing]# tail -1 trace
bash-6347 [002] 303160.793532: 0: I am a marker

> + ret = trace_vprintk(ip, "%s", ap);
This prevents the '%' character to be used in an output string. If used,
it may horribly crash the kernel.

I'll investigate the situation further and try to come back with a
better solution.

Carsten.

2009-12-06 13:10:28

by Carsten Emde

[permalink] [raw]
Subject: Re: [tip:tracing/urgent] tracing: Fix trace_marker output

Olof,

> On Sun, Nov 22, 2009 at 10:24:48AM +0000, tip-bot for Carsten Emde wrote:
>> Commit-ID: c13d2f7c3231e873f30db92b96c8caa48f100f33
>> Gitweb: http://git.kernel.org/tip/c13d2f7c3231e873f30db92b96c8caa48f100f33
>> Author: Carsten Emde <[email protected]>
>> AuthorDate: Mon, 16 Nov 2009 20:56:13 +0100
>> Committer: Steven Rostedt <[email protected]>
>> CommitDate: Tue, 17 Nov 2009 09:19:06 -0500
>>
>> tracing: Fix trace_marker output
>>
>> When a string was written to <debugfs>/tracing/trace_marker, some
>> strange characters appeared in the trace output instead of the
>> string, since a vprint function erroneously called a vararg print
>> function with a va_list argument. This patch fixes the problem and
>> simplifies the related code.
>
> [...]
>
>> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
>> index 03c7fd5..12b49ca 100644
>> --- a/kernel/trace/trace.c
>> +++ b/kernel/trace/trace.c
>> @@ -1361,10 +1361,11 @@ int trace_array_vprintk(struct trace_array *tr,
>> pause_graph_tracing();
>> raw_local_irq_save(irq_flags);
>> __raw_spin_lock(&trace_buf_lock);
>> - len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
>> -
>> - len = min(len, TRACE_BUF_SIZE-1);
>> - trace_buf[len] = 0;
>> + if (args == NULL) {
>> + strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
>> + len = strlen(trace_buf);
>> + } else
>> + len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
>
>
> Comparing a va_list with NULL is bogus. It's supposed to be treated like
> an opaque type and only be manipulated with va_* accessors.
>
> I wouldn't really care much, but it broke builds on some ARM platforms:
>
> kernel/trace/trace.c: In function 'trace_array_vprintk':
> kernel/trace/trace.c:1364: error: invalid operands to binary == (have 'va_list' and 'void *')
> kernel/trace/trace.c: In function 'tracing_mark_write':
> kernel/trace/trace.c:3349: error: incompatible type for argument 3 of 'trace_vprintk'
Having looked at other possible solutions, I find that the best thing to do
is to revert this part of the patch. Sorry that I didn't check it on ARM
platforms.

Carsten.

-=-

This patch partly reverts c13d2f7c3231e873f30db92b96c8caa48f100f33 and
re-installs Steven's original mark_printk() mechanism.

Signed-off-by: Carsten Emde <[email protected]>

Index: linux-2.6-tip/kernel/trace/trace.c
===================================================================
--- linux-2.6-tip.orig/kernel/trace/trace.c
+++ linux-2.6-tip/kernel/trace/trace.c
@@ -1361,11 +1361,7 @@ int trace_array_vprintk(struct trace_arr
pause_graph_tracing();
raw_local_irq_save(irq_flags);
__raw_spin_lock(&trace_buf_lock);
- if (args == NULL) {
- strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
- len = strlen(trace_buf);
- } else
- len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
+ len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);

size = sizeof(*entry) + len + 1;
buffer = tr->buffer;
@@ -3320,6 +3316,16 @@ tracing_entries_write(struct file *filp,
return cnt;
}

+static int mark_printk(const char *fmt, ...)
+{
+ int ret;
+ va_list args;
+ va_start(args, fmt);
+ ret = trace_vprintk(0, fmt, args);
+ va_end(args);
+ return ret;
+}
+
static ssize_t
tracing_mark_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *fpos)
@@ -3346,7 +3352,7 @@ tracing_mark_write(struct file *filp, co
} else
buf[cnt] = '\0';

- cnt = trace_vprintk(0, buf, NULL);
+ cnt = mark_printk("%s", buf);
kfree(buf);
*fpos += cnt;

2009-12-06 17:47:48

by Olof Johansson

[permalink] [raw]
Subject: Re: [tip:tracing/urgent] tracing: Fix trace_marker output

On Sun, Dec 06, 2009 at 02:02:44PM +0100, Carsten Emde wrote:
> Olof,
>
[...]
> Having looked at other possible solutions, I find that the best thing to do
> is to revert this part of the patch. Sorry that I didn't check it on ARM
> platforms.

Thanks, no worries. I figured there was a better way to fix it but
including a bad patch tends to be better than not including one :)


-Olof

2009-12-09 04:20:02

by Steven Rostedt

[permalink] [raw]
Subject: [PATCH][GIT PULL][v2.6.33] tracing: Remove comparing of NULL to va_list in trace_array_vprintk()


Hi Ingo,

This is an urgent fix that fixes a ARM build breakage. It is based on
the last pull request I had that fixes the function graph tracer output.


Ingo,

Please pull the latest tip/tracing/core2 tree, which can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/core2


Carsten Emde (1):
tracing: Remove comparing of NULL to va_list in trace_array_vprintk()

----
kernel/trace/trace.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
---------------------------
commit efcf61abeb355273bc8933faf426adc366b23153
Author: Carsten Emde <[email protected]>
Date: Sun Dec 6 14:02:44 2009 +0100

tracing: Remove comparing of NULL to va_list in trace_array_vprintk()

Olof Johansson stated the following:

Comparing a va_list with NULL is bogus. It's supposed to be treated like
an opaque type and only be manipulated with va_* accessors.

Olof noticed that this code broke the ARM builds:

kernel/trace/trace.c: In function 'trace_array_vprintk':
kernel/trace/trace.c:1364: error: invalid operands to binary == (have 'va_list' and 'void *')
kernel/trace/trace.c: In function 'tracing_mark_write':
kernel/trace/trace.c:3349: error: incompatible type for argument 3 of 'trace_vprintk'

This patch partly reverts c13d2f7c3231e873f30db92b96c8caa48f100f33 and
re-installs the original mark_printk() mechanism.

Reported-by: Olof Johansson <[email protected]>
Signed-off-by: Carsten Emde <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 596dcf2..bf84e1a 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1361,11 +1361,7 @@ int trace_array_vprintk(struct trace_array *tr,
pause_graph_tracing();
raw_local_irq_save(irq_flags);
__raw_spin_lock(&trace_buf_lock);
- if (args == NULL) {
- strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
- len = strlen(trace_buf);
- } else
- len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
+ len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);

size = sizeof(*entry) + len + 1;
buffer = tr->buffer;
@@ -3353,6 +3349,16 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
return cnt;
}

+static int mark_printk(const char *fmt, ...)
+{
+ int ret;
+ va_list args;
+ va_start(args, fmt);
+ ret = trace_vprintk(0, fmt, args);
+ va_end(args);
+ return ret;
+}
+
static ssize_t
tracing_mark_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *fpos)
@@ -3379,7 +3385,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
} else
buf[cnt] = '\0';

- cnt = trace_vprintk(0, buf, NULL);
+ cnt = mark_printk("%s", buf);
kfree(buf);
*fpos += cnt;


2009-12-09 05:57:00

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH][GIT PULL][v2.6.33] tracing: Remove comparing of NULL to va_list in trace_array_vprintk()


* Steven Rostedt <[email protected]> wrote:

> Hi Ingo,
>
> This is an urgent fix that fixes a ARM build breakage. It is based on
> the last pull request I had that fixes the function graph tracer output.
>
>
> Ingo,
>
> Please pull the latest tip/tracing/core2 tree, which can be found at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
> tip/tracing/core2
>
>
> Carsten Emde (1):
> tracing: Remove comparing of NULL to va_list in trace_array_vprintk()
>
> ----
> kernel/trace/trace.c | 18 ++++++++++++------
> 1 files changed, 12 insertions(+), 6 deletions(-)

Pulled, thanks Steve!

Ingo

2009-12-09 06:12:14

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH][GIT PULL][v2.6.33] tracing: Remove comparing of NULL to va_list in trace_array_vprintk()


-tip testing found that the Alpha defconfig fails to build. (error log
attached below)

To fix this bug i have unpulled this commit for now:

efcf61a: tracing: Remove comparing of NULL to va_list in trace_array_vprintk()

Thanks,

Ingo

---------------->
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/init/noinitramfs.c:23:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/init/main.c:16:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
cc1: warnings being treated as errors
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/arch/alpha/kernel/osf_sys.c:20:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: error: no return statement in function returning non-void
cc1: warnings being treated as errors
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/arch/alpha/kernel/alpha_ksyms.c:15:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: error: no return statement in function returning non-void
make[2]: *** [arch/alpha/kernel/alpha_ksyms.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1: warnings being treated as errors
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/arch/alpha/kernel/signal.c:22:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: error: no return statement in function returning non-void
make[2]: *** [arch/alpha/kernel/osf_sys.o] Error 1
make[2]: *** [arch/alpha/kernel/signal.o] Error 1
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/init/do_mounts.h:4,
from /home/mingo/tip/init/do_mounts.c:23:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/exec_domain.c:18:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/sched.c:62:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/fork.c:38:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/printk.c:34:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/itimer.c:11:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/fadvise.c:19:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
make[1]: *** [arch/alpha/kernel] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/exit.c:36:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/capability.c:15:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/filemap.c:32:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/sysctl.c:45:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/ptrace.c:23:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/timer.c:36:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/page-writeback.c:34:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/signal.c:21:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/kmod.c:23:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/open.c:28:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/sysctl_binary.c:7:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/read_write.c:16:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/pid.c:38:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/super.c:33:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/stat.c:15:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/posix-timers.c:45:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/fcntl.c:7:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/exec.c:49:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/pipe.c:20:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/ioctl.c:7:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/namei.c:28:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/select.c:19:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/readdir.c:17:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/fremap.c:17:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/hrtimer.c:39:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/madvise.c:10:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/mincore.c:14:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/dcache.c:17:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/mmap.c:16:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/mlock.c:15:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/mremap.c:21:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/mprotect.c:21:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/msync.c:14:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/namespace.c:11:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/groups.c:8:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/filesystems.c:9:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/futex.c:56:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
/home/mingo/tip/kernel/irq/handle.c:437:3: warning: #warning __do_IRQ is deprecated. Please convert to proper flow handlers
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/xattr.c:17:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/kernel/module.c:21:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/mm/swapfile.c:30:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/splice.c:30:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/sync.c:11:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/utimes.c:10:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/kernel/time.c:35:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/buffer.c:22:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/ioprio.c:26:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/notify/inotify/inotify_user.c:38:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/eventpoll.c:28:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/signalfd.c:30:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/timerfd.c:23:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/eventfd.c:17:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/locks.c:126:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/aio.c:17:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
from /home/mingo/tip/include/trace/syscall.h:6,
from /home/mingo/tip/include/linux/syscalls.h:71,
from /home/mingo/tip/fs/nfsctl.c:18:
/home/mingo/tip/include/linux/trace_seq.h: In function 'trace_print_seq':
/home/mingo/tip/include/linux/trace_seq.h:62: warning: no return statement in function returning non-void
make[1]: *** wait: No child processes. Stop.
make: *** [sub-make] Error 2

2009-12-09 06:15:42

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH][GIT PULL][v2.6.33] tracing: Remove comparing of NULL to va_list in trace_array_vprintk()


* Ingo Molnar <[email protected]> wrote:

> efcf61a: tracing: Remove comparing of NULL to va_list in trace_array_vprintk()

the real culprit was:

6e0573f: tracing: Buffer the output of seq_file in case of filled buffer

so i kept this commit:

c521efd: tracing: Add pipe_close interface

and skipped the rest for now - please resend if this is fixed.

Ingo

2009-12-09 14:06:38

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH][GIT PULL][v2.6.33] tracing: Remove comparing of NULL to va_list in trace_array_vprintk()

On Wed, 2009-12-09 at 07:15 +0100, Ingo Molnar wrote:
> * Ingo Molnar <[email protected]> wrote:
>
> > efcf61a: tracing: Remove comparing of NULL to va_list in trace_array_vprintk()
>
> the real culprit was:
>
> 6e0573f: tracing: Buffer the output of seq_file in case of filled buffer
>
> so i kept this commit:
>
> c521efd: tracing: Add pipe_close interface
>
> and skipped the rest for now - please resend if this is fixed.
>

I'll get this fixed today.

Thanks!

-- Steve

2009-12-09 18:05:32

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH][GIT PULL][v2.6.33] tracing: Remove comparing of NULL to va_list in trace_array_vprintk()

On Wed, 2009-12-09 at 07:11 +0100, Ingo Molnar wrote:
> -tip testing found that the Alpha defconfig fails to build. (error log
> attached below)
>
> To fix this bug i have unpulled this commit for now:
>
> efcf61a: tracing: Remove comparing of NULL to va_list in trace_array_vprintk()
>
> Thanks,
>
> Ingo
>
> ---------------->
> In file included from /home/mingo/tip/include/linux/ftrace_event.h:5,
> from /home/mingo/tip/include/trace/syscall.h:6,
> from /home/mingo/tip/include/linux/syscalls.h:71,
> from /home/mingo/tip/init/noinitramfs.c:23:

Ah, this was caused by the !CONFIG_TRACING path:

-static inline void trace_print_seq(struct seq_file *m, struct trace_seq *s)
+static inline int trace_print_seq(struct seq_file *m, struct trace_seq *s)
{
}

Will fix.

Thanks,

-- Steve

2009-12-10 07:50:19

by Carsten Emde

[permalink] [raw]
Subject: [tip:tracing/core] tracing: Remove comparing of NULL to va_list in trace_array_vprintk()

Commit-ID: f2942487ffb0c0a80b2312f667ea30dd55a24bb0
Gitweb: http://git.kernel.org/tip/f2942487ffb0c0a80b2312f667ea30dd55a24bb0
Author: Carsten Emde <[email protected]>
AuthorDate: Sun, 6 Dec 2009 14:02:44 +0100
Committer: Steven Rostedt <[email protected]>
CommitDate: Wed, 9 Dec 2009 14:20:08 -0500

tracing: Remove comparing of NULL to va_list in trace_array_vprintk()

Olof Johansson stated the following:

Comparing a va_list with NULL is bogus. It's supposed to be treated like
an opaque type and only be manipulated with va_* accessors.

Olof noticed that this code broke the ARM builds:

kernel/trace/trace.c: In function 'trace_array_vprintk':
kernel/trace/trace.c:1364: error: invalid operands to binary == (have 'va_list' and 'void *')
kernel/trace/trace.c: In function 'tracing_mark_write':
kernel/trace/trace.c:3349: error: incompatible type for argument 3 of 'trace_vprintk'

This patch partly reverts c13d2f7c3231e873f30db92b96c8caa48f100f33 and
re-installs the original mark_printk() mechanism.

Reported-by: Olof Johansson <[email protected]>
Signed-off-by: Carsten Emde <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
kernel/trace/trace.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 484114d..88bd9ae 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1361,11 +1361,7 @@ int trace_array_vprintk(struct trace_array *tr,
pause_graph_tracing();
raw_local_irq_save(irq_flags);
__raw_spin_lock(&trace_buf_lock);
- if (args == NULL) {
- strncpy(trace_buf, fmt, TRACE_BUF_SIZE);
- len = strlen(trace_buf);
- } else
- len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);
+ len = vsnprintf(trace_buf, TRACE_BUF_SIZE, fmt, args);

size = sizeof(*entry) + len + 1;
buffer = tr->buffer;
@@ -3353,6 +3349,16 @@ tracing_entries_write(struct file *filp, const char __user *ubuf,
return cnt;
}

+static int mark_printk(const char *fmt, ...)
+{
+ int ret;
+ va_list args;
+ va_start(args, fmt);
+ ret = trace_vprintk(0, fmt, args);
+ va_end(args);
+ return ret;
+}
+
static ssize_t
tracing_mark_write(struct file *filp, const char __user *ubuf,
size_t cnt, loff_t *fpos)
@@ -3379,7 +3385,7 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
} else
buf[cnt] = '\0';

- cnt = trace_vprintk(0, buf, NULL);
+ cnt = mark_printk("%s", buf);
kfree(buf);
*fpos += cnt;