aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2010-02-04 03:46:42 -0500
committerIngo Molnar <mingo@elte.hu>2010-02-04 04:03:03 -0500
commitf887f3019e56389a73617f4e70f512e82cc89adb (patch)
tree176b13e6d9713715d1b4eef75e702b47e6923606 /tools/perf
parent447a194b393f32699607fd99617a40abd6a95114 (diff)
perf tools: Clean up O_LARGEFILE et al usage
Setting _FILE_OFFSET_BITS and using O_LARGEFILE, lseek64, etc, is redundant. Thanks H. Peter Anvin for pointing it out. So, this patch removes O_LARGEFILE, lseek64, etc. Suggested-by: "H. Peter Anvin" <hpa@zytor.com> 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: <4B6A8972.3070605@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-record.c3
-rw-r--r--tools/perf/util/header.c21
-rw-r--r--tools/perf/util/session.c3
-rw-r--r--tools/perf/util/trace-event-read.c20
4 files changed, 22 insertions, 25 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 706f00196b87..3ad599b12c91 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -5,7 +5,6 @@
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 8#define _FILE_OFFSET_BITS 64
10 9
11#include "builtin.h" 10#include "builtin.h"
@@ -451,7 +450,7 @@ static int __cmd_record(int argc, const char **argv)
451 append_file = 0; 450 append_file = 0;
452 } 451 }
453 452
454 flags = O_CREAT|O_RDWR|O_LARGEFILE; 453 flags = O_CREAT|O_RDWR;
455 if (append_file) 454 if (append_file)
456 file_new = 0; 455 file_new = 0;
457 else 456 else
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index d5facd5ab1f7..6c9aa16ee51f 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1,4 +1,3 @@
1#define _LARGEFILE64_SOURCE
2#define _FILE_OFFSET_BITS 64 1#define _FILE_OFFSET_BITS 64
3 2
4#include <sys/types.h> 3#include <sys/types.h>
@@ -388,7 +387,7 @@ static int perf_header__adds_write(struct perf_header *self, int fd)
388 sec_size = sizeof(*feat_sec) * nr_sections; 387 sec_size = sizeof(*feat_sec) * nr_sections;
389 388
390 sec_start = self->data_offset + self->data_size; 389 sec_start = self->data_offset + self->data_size;
391 lseek64(fd, sec_start + sec_size, SEEK_SET); 390 lseek(fd, sec_start + sec_size, SEEK_SET);
392 391
393 if (perf_header__has_feat(self, HEADER_TRACE_INFO)) { 392 if (perf_header__has_feat(self, HEADER_TRACE_INFO)) {
394 struct perf_file_section *trace_sec; 393 struct perf_file_section *trace_sec;
@@ -396,9 +395,9 @@ static int perf_header__adds_write(struct perf_header *self, int fd)
396 trace_sec = &feat_sec[idx++]; 395 trace_sec = &feat_sec[idx++];
397 396
398 /* Write trace info */ 397 /* Write trace info */
399 trace_sec->offset = lseek64(fd, 0, SEEK_CUR); 398 trace_sec->offset = lseek(fd, 0, SEEK_CUR);
400 read_tracing_data(fd, attrs, nr_counters); 399 read_tracing_data(fd, attrs, nr_counters);
401 trace_sec->size = lseek64(fd, 0, SEEK_CUR) - trace_sec->offset; 400 trace_sec->size = lseek(fd, 0, SEEK_CUR) - trace_sec->offset;
402 } 401 }
403 402
404 403
@@ -408,18 +407,18 @@ static int perf_header__adds_write(struct perf_header *self, int fd)
408 buildid_sec = &feat_sec[idx++]; 407 buildid_sec = &feat_sec[idx++];
409 408
410 /* Write build-ids */ 409 /* Write build-ids */
411 buildid_sec->offset = lseek64(fd, 0, SEEK_CUR); 410 buildid_sec->offset = lseek(fd, 0, SEEK_CUR);
412 err = dsos__write_buildid_table(fd); 411 err = dsos__write_buildid_table(fd);
413 if (err < 0) { 412 if (err < 0) {
414 pr_debug("failed to write buildid table\n"); 413 pr_debug("failed to write buildid table\n");
415 goto out_free; 414 goto out_free;
416 } 415 }
417 buildid_sec->size = lseek64(fd, 0, SEEK_CUR) - 416 buildid_sec->size = lseek(fd, 0, SEEK_CUR) -
418 buildid_sec->offset; 417 buildid_sec->offset;
419 dsos__cache_build_ids(); 418 dsos__cache_build_ids();
420 } 419 }
421 420
422 lseek64(fd, sec_start, SEEK_SET); 421 lseek(fd, sec_start, SEEK_SET);
423 err = do_write(fd, feat_sec, sec_size); 422 err = do_write(fd, feat_sec, sec_size);
424 if (err < 0) 423 if (err < 0)
425 pr_debug("failed to write feature section\n"); 424 pr_debug("failed to write feature section\n");
@@ -513,7 +512,7 @@ int perf_header__write(struct perf_header *self, int fd, bool at_exit)
513 pr_debug("failed to write perf header\n"); 512 pr_debug("failed to write perf header\n");
514 return err; 513 return err;
515 } 514 }
516 lseek64(fd, self->data_offset + self->data_size, SEEK_SET); 515 lseek(fd, self->data_offset + self->data_size, SEEK_SET);
517 516
518 self->frozen = 1; 517 self->frozen = 1;
519 return 0; 518 return 0;
@@ -567,7 +566,7 @@ int perf_header__process_sections(struct perf_header *self, int fd,
567 566
568 sec_size = sizeof(*feat_sec) * nr_sections; 567 sec_size = sizeof(*feat_sec) * nr_sections;
569 568
570 lseek64(fd, self->data_offset + self->data_size, SEEK_SET); 569 lseek(fd, self->data_offset + self->data_size, SEEK_SET);
571 570
572 if (perf_header__getbuffer64(self, fd, feat_sec, sec_size)) 571 if (perf_header__getbuffer64(self, fd, feat_sec, sec_size))
573 goto out_free; 572 goto out_free;
@@ -641,7 +640,7 @@ static int perf_file_section__process(struct perf_file_section *self,
641 struct perf_header *ph, 640 struct perf_header *ph,
642 int feat, int fd) 641 int feat, int fd)
643{ 642{
644 if (lseek64(fd, self->offset, SEEK_SET) < 0) { 643 if (lseek(fd, self->offset, SEEK_SET) == (off_t)-1) {
645 pr_debug("Failed to lseek to %Ld offset for feature %d, " 644 pr_debug("Failed to lseek to %Ld offset for feature %d, "
646 "continuing...\n", self->offset, feat); 645 "continuing...\n", self->offset, feat);
647 return 0; 646 return 0;
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 74cbc64a3a3c..0de7258e70a5 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1,4 +1,3 @@
1#define _LARGEFILE64_SOURCE
2#define _FILE_OFFSET_BITS 64 1#define _FILE_OFFSET_BITS 64
3 2
4#include <linux/kernel.h> 3#include <linux/kernel.h>
@@ -15,7 +14,7 @@ static int perf_session__open(struct perf_session *self, bool force)
15{ 14{
16 struct stat input_stat; 15 struct stat input_stat;
17 16
18 self->fd = open(self->filename, O_RDONLY|O_LARGEFILE); 17 self->fd = open(self->filename, O_RDONLY);
19 if (self->fd < 0) { 18 if (self->fd < 0) {
20 pr_err("failed to open file: %s", self->filename); 19 pr_err("failed to open file: %s", self->filename);
21 if (!strcmp(self->filename, "perf.data")) 20 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 ca3c26d466f3..7cd1193918c7 100644
--- a/tools/perf/util/trace-event-read.c
+++ b/tools/perf/util/trace-event-read.c
@@ -18,7 +18,7 @@
18 * 18 *
19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 19 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 */ 20 */
21#define _LARGEFILE64_SOURCE 21#define _FILE_OFFSET_BITS 64
22 22
23#include <dirent.h> 23#include <dirent.h>
24#include <stdio.h> 24#include <stdio.h>
@@ -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 s64 r; 86 off_t r;
87 87
88 for (;;) { 88 for (;;) {
89 r = read(input_fd, buf, BUFSIZ); 89 r = read(input_fd, buf, BUFSIZ);
@@ -117,8 +117,8 @@ 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 = lseek64(input_fd, -(r - i), SEEK_CUR); 120 r = lseek(input_fd, -(r - i), SEEK_CUR);
121 if (r < 0) 121 if (r == (off_t)-1)
122 die("lseek"); 122 die("lseek");
123 123
124 if (str) { 124 if (str) {
@@ -282,8 +282,8 @@ static void update_cpu_data_index(int cpu)
282 282
283static void get_next_page(int cpu) 283static void get_next_page(int cpu)
284{ 284{
285 off64_t save_seek; 285 off_t save_seek;
286 off64_t ret; 286 off_t ret;
287 287
288 if (!cpu_data[cpu].page) 288 if (!cpu_data[cpu].page)
289 return; 289 return;
@@ -298,17 +298,17 @@ static void get_next_page(int cpu)
298 update_cpu_data_index(cpu); 298 update_cpu_data_index(cpu);
299 299
300 /* other parts of the code may expect the pointer to not move */ 300 /* other parts of the code may expect the pointer to not move */
301 save_seek = lseek64(input_fd, 0, SEEK_CUR); 301 save_seek = lseek(input_fd, 0, SEEK_CUR);
302 302
303 ret = lseek64(input_fd, cpu_data[cpu].offset, SEEK_SET); 303 ret = lseek(input_fd, cpu_data[cpu].offset, SEEK_SET);
304 if (ret < 0) 304 if (ret == (off_t)-1)
305 die("failed to lseek"); 305 die("failed to lseek");
306 ret = read(input_fd, cpu_data[cpu].page, page_size); 306 ret = read(input_fd, cpu_data[cpu].page, page_size);
307 if (ret < 0) 307 if (ret < 0)
308 die("failed to read page"); 308 die("failed to read page");
309 309
310 /* reset the file pointer back */ 310 /* reset the file pointer back */
311 lseek64(input_fd, save_seek, SEEK_SET); 311 lseek(input_fd, save_seek, SEEK_SET);
312 312
313 return; 313 return;
314 } 314 }