aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2010-02-02 22:53:14 -0500
committerIngo Molnar <mingo@elte.hu>2010-02-03 03:03:59 -0500
commitb8f46c5a34fa64fd456295388d18f50ae69d9f37 (patch)
treecba5da0bb3e4ca5c450df8aaa53fc74945c6fd28
parent59f411b62c9282891274e721fea29026b0eda3cc (diff)
perf tools: Use O_LARGEFILE to open perf data file
Open perf data file with O_LARGEFILE flag since its size is easily larger that 2G. For example: # rm -rf perf.data # ./perf kmem record sleep 300 [ perf record: Woken up 0 times to write data ] [ perf record: Captured and wrote 3142.147 MB perf.data (~137282513 samples) ] # ll -h perf.data -rw------- 1 root root 3.1G ..... Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> LKML-Reference: <4B68F32A.9040203@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--tools/perf/builtin-record.c5
-rw-r--r--tools/perf/util/header.c22
-rw-r--r--tools/perf/util/session.c5
-rw-r--r--tools/perf/util/trace-event-read.c4
4 files changed, 23 insertions, 13 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index eea56910b91c..949167efa1ed 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -5,6 +5,9 @@
5 * (or a CPU, or a PID) into the perf.data output file - for 5 * (or a CPU, or a PID) into the perf.data output file - for
6 * later analysis via perf report. 6 * later analysis via perf report.
7 */ 7 */
8#define _LARGEFILE64_SOURCE
9#define _FILE_OFFSET_BITS 64
10
8#include "builtin.h" 11#include "builtin.h"
9 12
10#include "perf.h" 13#include "perf.h"
@@ -451,7 +454,7 @@ static int __cmd_record(int argc, const char **argv)
451 append_file = 0; 454 append_file = 0;
452 } 455 }
453 456
454 flags = O_CREAT|O_RDWR; 457 flags = O_CREAT|O_RDWR|O_LARGEFILE;
455 if (append_file) 458 if (append_file)
456 file_new = 0; 459 file_new = 0;
457 else 460 else
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 2bb2bdb1f456..ed3efd728b41 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1,3 +1,6 @@
1#define _LARGEFILE64_SOURCE
2#define _FILE_OFFSET_BITS 64
3
1#include <sys/types.h> 4#include <sys/types.h>
2#include <byteswap.h> 5#include <byteswap.h>
3#include <unistd.h> 6#include <unistd.h>
@@ -382,7 +385,7 @@ static int perf_header__adds_write(struct perf_header *self, int fd)
382 sec_size = sizeof(*feat_sec) * nr_sections; 385 sec_size = sizeof(*feat_sec) * nr_sections;
383 386
384 sec_start = self->data_offset + self->data_size; 387 sec_start = self->data_offset + self->data_size;
385 lseek(fd, sec_start + sec_size, SEEK_SET); 388 lseek64(fd, sec_start + sec_size, SEEK_SET);
386 389
387 if (perf_header__has_feat(self, HEADER_TRACE_INFO)) { 390 if (perf_header__has_feat(self, HEADER_TRACE_INFO)) {
388 struct perf_file_section *trace_sec; 391 struct perf_file_section *trace_sec;
@@ -390,9 +393,9 @@ static int perf_header__adds_write(struct perf_header *self, int fd)
390 trace_sec = &feat_sec[idx++]; 393 trace_sec = &feat_sec[idx++];
391 394
392 /* Write trace info */ 395 /* Write trace info */
393 trace_sec->offset = lseek(fd, 0, SEEK_CUR); 396 trace_sec->offset = lseek64(fd, 0, SEEK_CUR);
394 read_tracing_data(fd, attrs, nr_counters); 397 read_tracing_data(fd, attrs, nr_counters);
395 trace_sec->size = lseek(fd, 0, SEEK_CUR) - trace_sec->offset; 398 trace_sec->size = lseek64(fd, 0, SEEK_CUR) - trace_sec->offset;
396 } 399 }
397 400
398 401
@@ -402,17 +405,18 @@ static int perf_header__adds_write(struct perf_header *self, int fd)
402 buildid_sec = &feat_sec[idx++]; 405 buildid_sec = &feat_sec[idx++];
403 406
404 /* Write build-ids */ 407 /* Write build-ids */
405 buildid_sec->offset = lseek(fd, 0, SEEK_CUR); 408 buildid_sec->offset = lseek64(fd, 0, SEEK_CUR);
406 err = dsos__write_buildid_table(fd); 409 err = dsos__write_buildid_table(fd);
407 if (err < 0) { 410 if (err < 0) {
408 pr_debug("failed to write buildid table\n"); 411 pr_debug("failed to write buildid table\n");
409 goto out_free; 412 goto out_free;
410 } 413 }
411 buildid_sec->size = lseek(fd, 0, SEEK_CUR) - buildid_sec->offset; 414 buildid_sec->size = lseek64(fd, 0, SEEK_CUR) -
415 buildid_sec->offset;
412 dsos__cache_build_ids(); 416 dsos__cache_build_ids();
413 } 417 }
414 418
415 lseek(fd, sec_start, SEEK_SET); 419 lseek64(fd, sec_start, SEEK_SET);
416 err = do_write(fd, feat_sec, sec_size); 420 err = do_write(fd, feat_sec, sec_size);
417 if (err < 0) 421 if (err < 0)
418 pr_debug("failed to write feature section\n"); 422 pr_debug("failed to write feature section\n");
@@ -506,7 +510,7 @@ int perf_header__write(struct perf_header *self, int fd, bool at_exit)
506 pr_debug("failed to write perf header\n"); 510 pr_debug("failed to write perf header\n");
507 return err; 511 return err;
508 } 512 }
509 lseek(fd, self->data_offset + self->data_size, SEEK_SET); 513 lseek64(fd, self->data_offset + self->data_size, SEEK_SET);
510 514
511 self->frozen = 1; 515 self->frozen = 1;
512 return 0; 516 return 0;
@@ -560,7 +564,7 @@ int perf_header__process_sections(struct perf_header *self, int fd,
560 564
561 sec_size = sizeof(*feat_sec) * nr_sections; 565 sec_size = sizeof(*feat_sec) * nr_sections;
562 566
563 lseek(fd, self->data_offset + self->data_size, SEEK_SET); 567 lseek64(fd, self->data_offset + self->data_size, SEEK_SET);
564 568
565 if (perf_header__getbuffer64(self, fd, feat_sec, sec_size)) 569 if (perf_header__getbuffer64(self, fd, feat_sec, sec_size))
566 goto out_free; 570 goto out_free;
@@ -634,7 +638,7 @@ static int perf_file_section__process(struct perf_file_section *self,
634 struct perf_header *ph, 638 struct perf_header *ph,
635 int feat, int fd) 639 int feat, int fd)
636{ 640{
637 if (lseek(fd, self->offset, SEEK_SET) < 0) { 641 if (lseek64(fd, self->offset, SEEK_SET) < 0) {
638 pr_debug("Failed to lseek to %Ld offset for feature %d, " 642 pr_debug("Failed to lseek to %Ld offset for feature %d, "
639 "continuing...\n", self->offset, feat); 643 "continuing...\n", self->offset, feat);
640 return 0; 644 return 0;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 8e7c1896eaa2..cf91d099f0aa 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1,3 +1,6 @@
1#define _LARGEFILE64_SOURCE
2#define _FILE_OFFSET_BITS 64
3
1#include <linux/kernel.h> 4#include <linux/kernel.h>
2 5
3#include <byteswap.h> 6#include <byteswap.h>
@@ -12,7 +15,7 @@ static int perf_session__open(struct perf_session *self, bool force)
12{ 15{
13 struct stat input_stat; 16 struct stat input_stat;
14 17
15 self->fd = open(self->filename, O_RDONLY); 18 self->fd = open(self->filename, O_RDONLY|O_LARGEFILE);
16 if (self->fd < 0) { 19 if (self->fd < 0) {
17 pr_err("failed to open file: %s", self->filename); 20 pr_err("failed to open file: %s", self->filename);
18 if (!strcmp(self->filename, "perf.data")) 21 if (!strcmp(self->filename, "perf.data"))
diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
index 1744422cafcb..ca3c26d466f3 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -83,7 +83,7 @@ static char *read_string(void)
83 char *str = NULL; 83 char *str = NULL;
84 int size = 0; 84 int size = 0;
85 int i; 85 int i;
86 int r; 86 s64 r;
87 87
88 for (;;) { 88 for (;;) {
89 r = read(input_fd, buf, BUFSIZ); 89 r = read(input_fd, buf, BUFSIZ);
@@ -117,7 +117,7 @@ static char *read_string(void)
117 i++; 117 i++;
118 118
119 /* move the file descriptor to the end of the string */ 119 /* move the file descriptor to the end of the string */
120 r = lseek(input_fd, -(r - i), SEEK_CUR); 120 r = lseek64(input_fd, -(r - i), SEEK_CUR);
121 if (r < 0) 121 if (r < 0)
122 die("lseek"); 122 die("lseek");
123 123