All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf timechart: Fix SIBGUS error on sparc64
@ 2015-03-24 20:14 David Ahern
  2015-03-24 21:15 ` Arnaldo Carvalho de Melo
  2015-03-27  7:39 ` [tip:perf/core] " tip-bot for David Ahern
  0 siblings, 2 replies; 4+ messages in thread
From: David Ahern @ 2015-03-24 20:14 UTC (permalink / raw)
  To: acme; +Cc: linux-kernel, David Ahern

perf timechart -T on sparc64 is terminating due to SIGBUS. Backtrace:

Program received signal SIGBUS, Bus error.
0x0000000000173d7c in perf_evsel__intval (evsel=<value optimized out>, sample=0x7feffffda28, name=0x289b28 "prev_state")
    at util/evsel.c:1918
1918	util/evsel.c: No such file or directory.
	in util/evsel.c
Missing separate debuginfos, use: debuginfo-install audit-libs-2.3.7-1.0.1.el6.sparc64 bzip2-libs-1.0.5-7.el6_0.sparc64 elfutils-libelf-0.155-2.0.3.el6.sparc64 elfutils-libs-0.155-2.0.3.el6.sparc64 glibc-2.12-1.132.0.8.el6_5.sparc64 numactl-2.0.7-8.el6.sparc64 python-libs-2.6.6-52.0.2.el6.sparc64 slang-2.2.1-1.el6.sparc64 xz-libs-4.999.9-0.3.beta.20091007git.el6.sparc64 zlib-1.2.3-29.el6.sparc64
(gdb) bt
0  0x0000000000173d7c in perf_evsel__intval (evsel=<value optimized out>, sample=0x7feffffda28,
    name=0x289b28 "prev_state") at util/evsel.c:1918
1  0x0000000000123b94 in process_sample_sched_switch (tchart=0x7feffffe040, evsel=0x4ca850, sample=0x7feffffda28,
    backtrace=0xc39010 "") at builtin-timechart.c:627
2  0x0000000000122828 in process_sample_event (tool=0x7feffffe040, event=<value optimized out>, sample=0x7feffffda28,
    evsel=0x4ca850, machine=0x4c9c88) at builtin-timechart.c:569

Another extended load on unaligned pointer. As before fix by copying to
a temporary variable using memcpy.

Signed-off-by: David Ahern <david.ahern@oracle.com>
---
 tools/perf/util/evsel.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index daa053d..ef20371 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1925,7 +1925,7 @@ u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
 		value = *(u32 *)ptr;
 		break;
 	case 8:
-		value = *(u64 *)ptr;
+		memcpy(&value, ptr, sizeof(u64));
 		break;
 	default:
 		return 0;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf timechart: Fix SIBGUS error on sparc64
  2015-03-24 20:14 [PATCH] perf timechart: Fix SIBGUS error on sparc64 David Ahern
@ 2015-03-24 21:15 ` Arnaldo Carvalho de Melo
  2015-03-24 21:28   ` David Ahern
  2015-03-27  7:39 ` [tip:perf/core] " tip-bot for David Ahern
  1 sibling, 1 reply; 4+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-03-24 21:15 UTC (permalink / raw)
  To: David Ahern; +Cc: linux-kernel

Em Tue, Mar 24, 2015 at 04:14:09PM -0400, David Ahern escreveu:
> perf timechart -T on sparc64 is terminating due to SIGBUS. Backtrace:
> 
> Program received signal SIGBUS, Bus error.
> 0x0000000000173d7c in perf_evsel__intval (evsel=<value optimized out>, sample=0x7feffffda28, name=0x289b28 "prev_state")
>     at util/evsel.c:1918
> 1918	util/evsel.c: No such file or directory.
> 	in util/evsel.c
> Missing separate debuginfos, use: debuginfo-install audit-libs-2.3.7-1.0.1.el6.sparc64 bzip2-libs-1.0.5-7.el6_0.sparc64 elfutils-libelf-0.155-2.0.3.el6.sparc64 elfutils-libs-0.155-2.0.3.el6.sparc64 glibc-2.12-1.132.0.8.el6_5.sparc64 numactl-2.0.7-8.el6.sparc64 python-libs-2.6.6-52.0.2.el6.sparc64 slang-2.2.1-1.el6.sparc64 xz-libs-4.999.9-0.3.beta.20091007git.el6.sparc64 zlib-1.2.3-29.el6.sparc64
> (gdb) bt
> 0  0x0000000000173d7c in perf_evsel__intval (evsel=<value optimized out>, sample=0x7feffffda28,
>     name=0x289b28 "prev_state") at util/evsel.c:1918
> 1  0x0000000000123b94 in process_sample_sched_switch (tchart=0x7feffffe040, evsel=0x4ca850, sample=0x7feffffda28,
>     backtrace=0xc39010 "") at builtin-timechart.c:627
> 2  0x0000000000122828 in process_sample_event (tool=0x7feffffe040, event=<value optimized out>, sample=0x7feffffda28,
>     evsel=0x4ca850, machine=0x4c9c88) at builtin-timechart.c:569
> 
> Another extended load on unaligned pointer. As before fix by copying to

Humm, so this is being put that way by the tracepoint in the kernel?
Lemme see...

It is this one, right?

[root@ssdandy ~]# cat /t/events/sched/sched_switch/format
name: sched_switch
ID: 228
format:
	field:unsigned short common_type;	offset:0;	size:2;	signed:0;
	field:unsigned char common_flags;	offset:2;	size:1;	signed:0;
	field:unsigned char common_preempt_count;	offset:3;	size:1;	signed:0;
	field:int common_pid;	offset:4;	size:4;	signed:1;

	field:char prev_comm[16];	offset:8;	size:16;	signed:1;
	field:pid_t prev_pid;	offset:24;	size:4;	signed:1;
	field:int prev_prio;	offset:28;	size:4;	signed:1;
	field:long prev_state;	offset:32;	size:8;	signed:1;
	field:char next_comm[16];	offset:40;	size:16;	signed:1;
	field:pid_t next_pid;	offset:56;	size:4;	signed:1;
	field:int next_prio;	offset:60;	size:4;	signed:1;

print fmt: "prev_comm=%s prev_pid=%d prev_prio=%d prev_state=%s%s ==> next_comm=%s next_pid=%d next_prio=%d", REC->prev_comm, REC->prev_pid, REC->prev_prio, REC->prev_state & (1024-1) ? __print_flags(REC->prev_state & (1024-1), "|", { 1, "S"} , { 2, "D" }, { 4, "T" }, { 8, "t" }, { 16, "Z" }, { 32, "X" }, { 64, "x" }, { 128, "K" }, { 256, "W" }, { 512, "P" }) : "R", REC->prev_state & 1024 ? "+" : "", REC->next_comm, REC->next_pid, REC->next_prio
[root@ssdandy ~]#

---------------------------------------------

I.e. this should be reading from the ring buffer, where this info was put, all aligned, by the kernel,
except when we need to use struct perf_mmap->event_copy, that is...

struct perf_mmap {
        void             *base;
        int              mask; 
        int              refcnt;
        unsigned int     prev;
        char             event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
};

sizeof(u64) aligned, no?

/me scratches head, should be missing something embarassingly simple :-/

- Arnaldo


> a temporary variable using memcpy.
> 
> Signed-off-by: David Ahern <david.ahern@oracle.com>
> ---
>  tools/perf/util/evsel.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index daa053d..ef20371 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -1925,7 +1925,7 @@ u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
>  		value = *(u32 *)ptr;
>  		break;
>  	case 8:
> -		value = *(u64 *)ptr;
> +		memcpy(&value, ptr, sizeof(u64));
>  		break;
>  	default:
>  		return 0;
> -- 
> 1.7.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] perf timechart: Fix SIBGUS error on sparc64
  2015-03-24 21:15 ` Arnaldo Carvalho de Melo
@ 2015-03-24 21:28   ` David Ahern
  0 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2015-03-24 21:28 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: linux-kernel

On 3/24/15 3:15 PM, Arnaldo Carvalho de Melo wrote:
> /me scratches head, should be missing something embarassingly simple :-/
>

ptr = sample->raw_data + field->offset;

raw_data is *guaranteed* to be misaligned. From kernel/events/core.c:

                         struct {
                                 u32     size;
                                 u32     data;
                         } raw = {
                                 .size = sizeof(u32),
                                 .data = 0,
                         };

Raw data starts at 64-bit alignment, but that u32 means data is NOT 
8-byte aligned. :-(

David


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip:perf/core] perf timechart: Fix SIBGUS error on sparc64
  2015-03-24 20:14 [PATCH] perf timechart: Fix SIBGUS error on sparc64 David Ahern
  2015-03-24 21:15 ` Arnaldo Carvalho de Melo
@ 2015-03-27  7:39 ` tip-bot for David Ahern
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for David Ahern @ 2015-03-27  7:39 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: mingo, tglx, linux-kernel, hpa, acme, david.ahern

Commit-ID:  e94eedab3ab8201fd41480171b2fabbf3c5b1ae0
Gitweb:     http://git.kernel.org/tip/e94eedab3ab8201fd41480171b2fabbf3c5b1ae0
Author:     David Ahern <david.ahern@oracle.com>
AuthorDate: Tue, 24 Mar 2015 16:14:09 -0400
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 26 Mar 2015 10:52:28 -0300

perf timechart: Fix SIBGUS error on sparc64

perf timechart -T on sparc64 is terminating due to SIGBUS. Backtrace:

Program received signal SIGBUS, Bus error.
0x0000000000173d7c in perf_evsel__intval (evsel=<value optimized out>, sample=0x7feffffda28, name=0x289b28 "prev_state")
    at util/evsel.c:1918
1918	util/evsel.c: No such file or directory.
	in util/evsel.c
Missing separate debuginfos, use: debuginfo-install audit-libs-2.3.7-1.0.1.el6.sparc64 bzip2-libs-1.0.5-7.el6_0.sparc64 elfutils-libelf-0.155-2.0.3.el6.sparc64 elfutils-libs-0.155-2.0.3.el6.sparc64 glibc-2.12-1.132.0.8.el6_5.sparc64 numactl-2.0.7-8.el6.sparc64 python-libs-2.6.6-52.0.2.el6.sparc64 slang-2.2.1-1.el6.sparc64 xz-libs-4.999.9-0.3.beta.20091007git.el6.sparc64 zlib-1.2.3-29.el6.sparc64
(gdb) bt
0  0x0000000000173d7c in perf_evsel__intval (evsel=<value optimized out>, sample=0x7feffffda28,
    name=0x289b28 "prev_state") at util/evsel.c:1918
1  0x0000000000123b94 in process_sample_sched_switch (tchart=0x7feffffe040, evsel=0x4ca850, sample=0x7feffffda28,
    backtrace=0xc39010 "") at builtin-timechart.c:627
2  0x0000000000122828 in process_sample_event (tool=0x7feffffe040, event=<value optimized out>, sample=0x7feffffda28,
    evsel=0x4ca850, machine=0x4c9c88) at builtin-timechart.c:569

Another extended load on unaligned pointer. As before fix by copying to
a temporary variable using memcpy.

Signed-off-by: David Ahern <david.ahern@oracle.com>
Link: http://lkml.kernel.org/r/1427228049-51893-1-git-send-email-david.ahern@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bb4eff2..358e595 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1915,7 +1915,7 @@ u64 perf_evsel__intval(struct perf_evsel *evsel, struct perf_sample *sample,
 		value = *(u32 *)ptr;
 		break;
 	case 8:
-		value = *(u64 *)ptr;
+		memcpy(&value, ptr, sizeof(u64));
 		break;
 	default:
 		return 0;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-27  7:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-24 20:14 [PATCH] perf timechart: Fix SIBGUS error on sparc64 David Ahern
2015-03-24 21:15 ` Arnaldo Carvalho de Melo
2015-03-24 21:28   ` David Ahern
2015-03-27  7:39 ` [tip:perf/core] " tip-bot for David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.