在CentOS5下編譯32核心的perf

2021-07-29 19:24:16 字數 3966 閱讀 2222

很多的公司,包括我們公司,還在使用centos5。但核心早已換成el6系列的2.6.32核心。perf工具是核心自帶的乙個效能評估工具,功能很強大,為了在centos5下進行效能優化,我們要在centos5下對2.6.32核心的perf原始碼進行編譯。我這裡使用了linux-2.6.32-358.el6的核心原始碼。

進入原始碼目錄,打上以下補丁:

1、004-150-perf-tools-fix-build-with-bison-2.3-and-older..patch

--- a/tools/perf/makefile

+++ b/tools/perf/makefile

@@ -276,13 +276,13 @@ $(output)util/parse-events-flex.c: util/

$(quiet_flex)$(flex) --header-file=$(output)util/parse-events-flex.h $(parser_debug_flex) -t util/parse-events.l > $(output)util/parse-events-flex.c

$(output)util/parse-events-bison.c: util/parse-events.y

- $(quiet_bison)$(bison) -v util/parse-events.y -d $(parser_debug_bison) -o $(output)util/parse-events-bison.c

+ $(quiet_bison)$(bison) -v util/parse-events.y -d $(parser_debug_bison) -o $(output)util/parse-events-bison.c -p parse_events_

$(output)util/pmu-flex.c: util/pmu.l $(output)util/pmu-bison.c

$(quiet_flex)$(flex) --header-file=$(output)util/pmu-flex.h -t util/pmu.l > $(output)util/pmu-flex.c

$(output)util/pmu-bison.c: util/pmu.y

- $(quiet_bison)$(bison) -v util/pmu.y -d -o $(output)util/pmu-bison.c

+ $(quiet_bison)$(bison) -v util/pmu.y -d -o $(output)util/pmu-bison.c -p perf_pmu_

$(output)util/parse-events.o: $(output)util/parse-events-flex.c $(output)util/parse-events-bison.c

$(output)util/pmu.o: $(output)util/pmu-flex.c $(output)util/pmu-bison.c

--- a/tools/perf/util/parse-events.y

+++ b/tools/perf/util/parse-events.y

@@ -1,5 +1,4 @@

%pure-parser

-%name-prefix "parse_events_"

%parse-param

%parse-param

%lex-param

--- a/tools/perf/util/pmu.y

+++ b/tools/perf/util/pmu.y

@@ -1,5 +1,4 @@

-%name-prefix "perf_pmu_"

%parse-param

%parse-param

2、10-13-perf-tools-replace-mkostemp-with-mkstemp.patch

diff --git a/tools/perf/util/dso-test-data.c b/tools/perf/util/dso-test-data.c

index 541cdc7..c6caede 100644

--- a/tools/perf/util/dso-test-data.c

+++ b/tools/perf/util/dso-test-data.c

@@ -23,7 +23,7 @@ static char *test_file(int size)

int fd, i;

unsigned char *buf;

- fd = mkostemp(templ, o_creat|o_wronly|o_trunc);

+ fd = mkstemp(templ);

buf = malloc(size);

if (!buf)

-static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t **maskp,

- size_t *sizep)

+static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp)

for (i = 0; i < nrcpus; i++) else

- cpu_clr_s(i, size, mask);

+ else

+ cpu_clr(i, maskp);}}

- if (cpu == -1)

- cpu_free(mask);

- return cpu; }

@@ -654,8 +643,8 @@ static int test__perf_record(void)

.freq = 10,

.mmap_pages = 256,

};- cpu_set_t *cpu_mask = null;

- size_t cpu_mask_size = 0;

+ cpu_set_t cpu_mask;

+ size_t cpu_mask_size = sizeof(cpu_mask);

struct perf_evlist *evlist = perf_evlist__new(null, null);

struct perf_evsel *evsel;

struct perf_sample sample;

@@ -719,8 +708,7 @@ static int test__perf_record(void)

evsel->attr.sample_type |= perf_sample_time;

perf_evlist__config_attrs(evlist, &opts);

- err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask,

- &cpu_mask_size);

+ err = sched__get_first_possible_cpu(evlist->workload.pid, &cpu_mask);

if (err < 0)

/*@@ -917,8 +905,6 @@ found_exit:

} out_err:

perf_evlist__munmap(evlist);

-out_free_cpu_mask:

- cpu_free(cpu_mask);

out_delete_evlist:

perf_evlist__delete(evlist);

out:

然後再安裝

binutils220-2.20.51.0.2-5.29.el5.x86_64.rpm

flex-2.5.35-0.8.el5.rfb.x86_64.rpm

libgomp-4.4.7-1.el5.x86_64.rpm

這幾個包。

進入tools/perf,make一下就可以了。

CentOS5下編譯安裝apache php

前段時間研究了下centos下的apache和php的編譯安裝,一下是我的編譯過程,前提是已經安裝 好了mysql了 用wget 2.解壓到 usr local src下,先編譯apache,在編譯php apache編譯引數 apache configure prefix usr local ap...

在centos5上編譯安裝nginx

這不是什麼複雜的工作,記在這裡做個備忘 2,公升級各種基礎庫和支援軟體 yum y install gcc openssl devel pcre devel zlib devel 3,解壓縮,tar zvxf nginx 1.0.3.tar.gz 4,進入解壓縮之後的nginx 1.0.3目錄,使用...

centos5核心公升級步驟

然後編譯核心 make dep make menuconfig make bzimage make modules make modules install make install 重啟,出現錯誤 insmod error inserting lib dm region hash.ko 1 fil...