2010-01-14 17:43:56

by Ulrich Drepper

[permalink] [raw]
Subject: perf: don't use obsolete getpagesize

perf uses the obsolete getpagesize function. Let's do better and use the
correct POSIX interface to get the information: sysconf.


Signed-off-by: Ulrich Drepper <[email protected]>

diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index b557b83..cc8b396 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -153,7 +153,7 @@ int perf_session__process_events(struct perf_session *self,

perf_event_ops__fill_defaults(ops);

- page_size = getpagesize();
+ page_size = sysconf(_SC_PAGESIZE);

head = self->header.data_offset;
self->sample_type = perf_header__sample_type(&self->header);
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index cace355..948dc9e 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -533,7 +533,7 @@ int read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events)
write_or_die(buf, 1);

/* save page_size */
- page_size = getpagesize();
+ page_size = sysconf(_SC_PAGESIZE);
write_or_die(&page_size, 4);

read_header_files();


2010-01-14 17:49:07

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: perf: don't use obsolete getpagesize

Em Thu, Jan 14, 2010 at 12:43:20PM -0500, Ulrich Drepper escreveu:
> perf uses the obsolete getpagesize function. Let's do better and use the
> correct POSIX interface to get the information: sysconf.
>
>
> Signed-off-by: Ulrich Drepper <[email protected]>

I have this already in my queue, thanks!

acme@parisc:~/git/linux-2.6-tip$ git show 578bb387c17692896a2a7c6b8bcba2c3945c33f4
commit 578bb387c17692896a2a7c6b8bcba2c3945c33f4
Author: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu Jan 14 14:10:35 2010 -0200

perf tools: Convert getpagesize() uses to sysconf(_SC_GETPAGESIZE)

Using the more portable and equivalent sysconf call.

Reported-by: Aristeu Rozanski <[email protected]>
Cc: Aristeu Rozanski <[email protected]>
Cc: Fr?d?ric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 604e14f..1951e33 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -384,7 +384,7 @@ int perf_session__process_events(struct perf_session *self,

perf_event_ops__fill_defaults(ops);

- page_size = getpagesize();
+ page_size = sysconf(_SC_PAGESIZE);

head = self->header.data_offset;

diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 407fd65..5ea8973 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -515,7 +515,7 @@ int read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events)
write_or_die(buf, 1);

/* save page_size */
- page_size = getpagesize();
+ page_size = sysconf(_SC_PAGESIZE);
write_or_die(&page_size, 4);

read_header_files();
acme@parisc:~/git/linux-2.6-tip$