瀏覽代碼

Merge tag 'perf-urgent-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

  - Fix libtraceevent string handling in heterogeneous arch environments. (Kapileshwar Singh)

  - Avoid infinite loop at buildid processing with no samples in 'perf record'. (Mark Rutland)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Ingo Molnar 10 年之前
父節點
當前提交
d0d0313c2a
共有 2 個文件被更改,包括 24 次插入4 次删除
  1. 20 3
      tools/lib/traceevent/event-parse.c
  2. 4 1
      tools/perf/util/session.c

+ 20 - 3
tools/lib/traceevent/event-parse.c

@@ -3795,7 +3795,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 	struct format_field *field;
 	struct format_field *field;
 	struct printk_map *printk;
 	struct printk_map *printk;
 	long long val, fval;
 	long long val, fval;
-	unsigned long addr;
+	unsigned long long addr;
 	char *str;
 	char *str;
 	unsigned char *hex;
 	unsigned char *hex;
 	int print;
 	int print;
@@ -3828,13 +3828,30 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 		 */
 		 */
 		if (!(field->flags & FIELD_IS_ARRAY) &&
 		if (!(field->flags & FIELD_IS_ARRAY) &&
 		    field->size == pevent->long_size) {
 		    field->size == pevent->long_size) {
-			addr = *(unsigned long *)(data + field->offset);
+
+			/* Handle heterogeneous recording and processing
+			 * architectures
+			 *
+			 * CASE I:
+			 * Traces recorded on 32-bit devices (32-bit
+			 * addressing) and processed on 64-bit devices:
+			 * In this case, only 32 bits should be read.
+			 *
+			 * CASE II:
+			 * Traces recorded on 64 bit devices and processed
+			 * on 32-bit devices:
+			 * In this case, 64 bits must be read.
+			 */
+			addr = (pevent->long_size == 8) ?
+				*(unsigned long long *)(data + field->offset) :
+				(unsigned long long)*(unsigned int *)(data + field->offset);
+
 			/* Check if it matches a print format */
 			/* Check if it matches a print format */
 			printk = find_printk(pevent, addr);
 			printk = find_printk(pevent, addr);
 			if (printk)
 			if (printk)
 				trace_seq_puts(s, printk->printk);
 				trace_seq_puts(s, printk->printk);
 			else
 			else
-				trace_seq_printf(s, "%lx", addr);
+				trace_seq_printf(s, "%llx", addr);
 			break;
 			break;
 		}
 		}
 		str = malloc(len + 1);
 		str = malloc(len + 1);

+ 4 - 1
tools/perf/util/session.c

@@ -1580,7 +1580,10 @@ static int __perf_session__process_events(struct perf_session *session,
 	file_offset = page_offset;
 	file_offset = page_offset;
 	head = data_offset - page_offset;
 	head = data_offset - page_offset;
 
 
-	if (data_size && (data_offset + data_size < file_size))
+	if (data_size == 0)
+		goto out;
+
+	if (data_offset + data_size < file_size)
 		file_size = data_offset + data_size;
 		file_size = data_offset + data_size;
 
 
 	ui_progress__init(&prog, file_size, "Processing events...");
 	ui_progress__init(&prog, file_size, "Processing events...");