在CentOS5下编译32内核的perf

前端之家收集整理的这篇文章主要介绍了在CentOS5下编译32内核的perf前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
很多的公司,包括我们公司,还在使用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
  1. --- a/tools/perf/Makefile
  2. +++ b/tools/perf/Makefile
  3. @@ -276,13 +276,13 @@ $(OUTPUT)util/parse-events-flex.c: util/
  4. $(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
  5. $(OUTPUT)util/parse-events-bison.c: util/parse-events.y
  6. - $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c
  7. + $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c -p parse_events_
  8. $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
  9. $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c
  10. $(OUTPUT)util/pmu-bison.c: util/pmu.y
  11. - $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c
  12. + $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c -p perf_pmu_
  13. $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
  14. $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
  15. --- a/tools/perf/util/parse-events.y
  16. +++ b/tools/perf/util/parse-events.y
  17. @@ -1,5 +1,4 @@
  18. %pure-parser
  19. -%name-prefix "parse_events_"
  20. %parse-param {void *_data}
  21. %parse-param {void *scanner}
  22. %lex-param {void* scanner}
  23. --- a/tools/perf/util/pmu.y
  24. +++ b/tools/perf/util/pmu.y
  25. @@ -1,4 @@
  26. -%name-prefix "perf_pmu_"
  27. %parse-param {struct list_head *format}
  28. %parse-param {char *name}
2、10-13-perf-tools-replace-mkostemp-with-mkstemp.patch
  1. diff --git a/tools/perf/util/dso-test-data.c b/tools/perf/util/dso-test-data.c
  2. index 541cdc7..c6caede 100644
  3. --- a/tools/perf/util/dso-test-data.c
  4. +++ b/tools/perf/util/dso-test-data.c
  5. @@ -23,7 +23,7 @@ static char *test_file(int size)
  6. int fd,i;
  7. unsigned char *buf;
  8. - fd = mkostemp(templ,O_CREAT|O_WRONLY|O_TRUNC);
  9. + fd = mkstemp(templ);
  10. buf = malloc(size);
  11. if (!buf) {

3、tip-perf-core-perf-test-fix-a-build-error-on-builtin-test.patch
  1. diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c
  2. index b5a544d..5d4354e 100644
  3. --- a/tools/perf/builtin-test.c
  4. +++ b/tools/perf/builtin-test.c
  5. @@ -605,19 +605,13 @@ out_free_threads:
  6. #undef nsyscalls
  7. }
  8. -static int sched__get_first_possible_cpu(pid_t pid,cpu_set_t **maskp,- size_t *sizep)
  9. +static int sched__get_first_possible_cpu(pid_t pid,cpu_set_t *maskp)
  10. {
  11. - cpu_set_t *mask;
  12. - size_t size;
  13. int i,cpu = -1,nrcpus = 1024;
  14. realloc:
  15. - mask = cpu_ALLOC(nrcpus);
  16. - size = cpu_ALLOC_SIZE(nrcpus);
  17. - cpu_ZERO_S(size,mask);
  18. + cpu_ZERO(maskp);
  19. - if (sched_getaffinity(pid,size,mask) == -1) {
  20. - cpu_FREE(mask);
  21. + if (sched_getaffinity(pid,sizeof(*maskp),maskp) == -1) {
  22. if (errno == EINVAL && nrcpus < (1024 << 8)) {
  23. nrcpus = nrcpus << 2;
  24. goto realloc;
  25. @@ -627,19 +621,14 @@ realloc:
  26. }
  27. for (i = 0; i < nrcpus; i++) {
  28. - if (cpu_ISSET_S(i,mask)) {
  29. - if (cpu == -1) {
  30. + if (cpu_ISSET(i,maskp)) {
  31. + if (cpu == -1)
  32. cpu = i;
  33. - *maskp = mask;
  34. - *sizep = size;
  35. - } else
  36. - cpu_CLR_S(i,mask);
  37. + else
  38. + cpu_CLR(i,maskp);
  39. }
  40. }
  41. - if (cpu == -1)
  42. - cpu_FREE(mask);
  43. -
  44. return cpu;
  45. }
  46. @@ -654,8 +643,8 @@ static int test__PERF_RECORD(void)
  47. .freq = 10,.mmap_pages = 256,};
  48. - cpu_set_t *cpu_mask = NULL;
  49. - size_t cpu_mask_size = 0;
  50. + cpu_set_t cpu_mask;
  51. + size_t cpu_mask_size = sizeof(cpu_mask);
  52. struct perf_evlist *evlist = perf_evlist__new(NULL,NULL);
  53. struct perf_evsel *evsel;
  54. struct perf_sample sample;
  55. @@ -719,8 +708,7 @@ static int test__PERF_RECORD(void)
  56. evsel->attr.sample_type |= PERF_SAMPLE_TIME;
  57. perf_evlist__config_attrs(evlist,&opts);
  58. - err = sched__get_first_possible_cpu(evlist->workload.pid,&cpu_mask,- &cpu_mask_size);
  59. + err = sched__get_first_possible_cpu(evlist->workload.pid,&cpu_mask);
  60. if (err < 0) {
  61. pr_debug("sched__get_first_possible_cpu: %s\n",strerror(errno));
  62. goto out_delete_evlist;
  63. @@ -731,9 +719,9 @@ static int test__PERF_RECORD(void)
  64. /*
  65. * So that we can check perf_sample.cpu on all the samples.
  66. */
  67. - if (sched_setaffinity(evlist->workload.pid,cpu_mask_size,cpu_mask) < 0) {
  68. + if (sched_setaffinity(evlist->workload.pid,&cpu_mask) < 0) {
  69. pr_debug("sched_setaffinity: %s\n",strerror(errno));
  70. - goto out_free_cpu_mask;
  71. + goto out_delete_evlist;
  72. }
  73. /*
  74. @@ -917,8 +905,6 @@ found_exit:
  75. }
  76. out_err:
  77. perf_evlist__munmap(evlist);
  78. -out_free_cpu_mask:
  79. - cpu_FREE(cpu_mask);
  80. out_delete_evlist:
  81. perf_evlist__delete(evlist);
  82. 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一下就可以了。

这几个包和patch,以及我编译出来的用于CentOS5下的32内核的perf静态文件在这可以下载:

http://download.csdn.net/detail/abigwc/9799082

猜你在找的CentOS相关文章