perf probe: Add fastpath to do lookup by function name
PATCH 1/1 perf probe: Add fastpath to do lookup by function name
The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs.
--- tools/perf/util/probe-finder.c | 38 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-finder.h | 1 + 2 files changed, 39 insertions(+), 0 deletions(-)
tools/perf/util/probe-finder.c +38 -0
@@ -1876,6 +1876,30 @@ static int find_line_range_by_func(struct line_finder *lf)return param.retval; } +static int pubname_search_cb (Dwarf *dbg,Dwarf_Global *gl,void *data) +{ +struct line_finder *lf = data; +struct line_range *lr = lf->lr; + +if (dwarf_offdie (dbg, gl->die_offset, &lf->sp_die)) { +if (dwarf_tag (&lf->sp_die) != DW_TAG_subprogram) +return DWARF_CB_OK ; + +if (die_compare_name (&lf->sp_die, lr->function)) { +if (!dwarf_offdie (dbg, gl->cu_offset, &lf->cu_die)) +return DWARF_CB_OK ; + +if (lr->file && !cu_find_realpath (&lf->cu_die, lr->file)) +return DWARF_CB_OK ; + + lf->found =1 ; +return DWARF_CB_ABORT ; + } + } + +return DWARF_CB_OK ; +} +int find_line_range (int fd,struct line_range *lr) {struct line_finder lf = {.lr = lr, .found =0 };
@@ -1895,6 +1919,19 @@ int find_line_range(int fd, struct line_range *lr)return -EBADF ; } +/* Fastpath: lookup by function name from .debug_pubnames section */ +if (lr->function) { +struct dwarf_callback_param param = {.data = (void *)&lf, .retval =0 }; + +dwarf_getpubnames (dbg, pubname_search_cb, &lf,0 ); +if (lf.found) { + lf.found =0 ; +line_range_search_cb (&lf.sp_die, ¶m); +if (lf.found) + goto found; + } + } +/* Loop on CUs (Compilation Unit) */ while (!lf.found && ret >=0 ) {if (dwarf_nextcu (dbg, off, &noff, &cuhl,NULL ,NULL ,NULL ) !=0 )
@@ -1923,6 +1960,7 @@ int find_line_range(int fd, struct line_range *lr) off = noff; } +found:/* Store comp_dir */ if (lf.found) { comp_dir =cu_get_comp_dir (&lf.cu_die);
tools/perf/util/probe-finder.h +1 -0
@@ -83,6 +83,7 @@ struct line_finder {int lno_s;/* Start line number */ int lno_e;/* End line number */ Dwarf_Die cu_die;/* Current CU */ +Dwarf_Die sp_die;int found; };
Signature · 1 line
1.7.2.3
Quoted 3 lines · Lin Ming
The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs.
Mind including before/after perf stat --repeat 10 results in the changelog, of an affected command which got faster?
Thanks,
Ingo
Quoted 11 lines · Ingo Molnar
Quoted 3 lines · Lin Ming
The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs.Mind including before/after perf stat --repeat 10 results in the changelog, of an affected command which got faster?
From
611a823a34e655d47a80f92994b004391e2b244cMon Sep 17 00:00:00 2001
From: Lin Ming <[email protected]>
Date: Thu, 24 Mar 2011 23:22:24 +0800
Subject: [PATCH] perf probe: Add fastpath to do lookup by function name
The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs.
./perf stat -r 10 -- ./perf probe -k /home/mlin/vmlinux \
-s /home/mlin/linux-2.6 \
--line csum_partial_copy_to_user > tmp.log
before patch applied
=====================
364.535892 task-clock-msecs # 0.997 CPUs
0 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
29,993 page-faults # 0.082 M/sec
865,862,109 cycles # 2375.245 M/sec
1,255,259,630 instructions # 1.450 IPC
252,400,884 branches # 692.390 M/sec
3,429,376 branch-misses # 1.359 %
1,386,990 cache-references # 3.805 M/sec
687,188 cache-misses # 1.885 M/sec 0.365792170 seconds time elapsed
after patch applied
=====================
89.896405 task-clock-msecs # 0.991 CPUs
1 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
10,145 page-faults # 0.113 M/sec
214,553,875 cycles # 2386.679 M/sec
226,915,559 instructions # 1.058 IPC
44,536,614 branches # 495.422 M/sec
613,074 branch-misses # 1.377 %
860,787 cache-references # 9.575 M/sec
442,380 cache-misses # 4.921 M/sec0.090716032 seconds time elapsed
--- tools/perf/util/probe-finder.c | 38 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-finder.h | 1 + 2 files changed, 39 insertions(+), 0 deletions(-)
tools/perf/util/probe-finder.c +38 -0
@@ -1876,6 +1876,30 @@ static int find_line_range_by_func(struct line_finder *lf)return param.retval; } +static int pubname_search_cb (Dwarf *dbg,Dwarf_Global *gl,void *data) +{ +struct line_finder *lf = data; +struct line_range *lr = lf->lr; + +if (dwarf_offdie (dbg, gl->die_offset, &lf->sp_die)) { +if (dwarf_tag (&lf->sp_die) != DW_TAG_subprogram) +return DWARF_CB_OK ; + +if (die_compare_name (&lf->sp_die, lr->function)) { +if (!dwarf_offdie (dbg, gl->cu_offset, &lf->cu_die)) +return DWARF_CB_OK ; + +if (lr->file && !cu_find_realpath (&lf->cu_die, lr->file)) +return DWARF_CB_OK ; + + lf->found =1 ; +return DWARF_CB_ABORT ; + } + } + +return DWARF_CB_OK ; +} +int find_line_range (int fd,struct line_range *lr) {struct line_finder lf = {.lr = lr, .found =0 };
@@ -1895,6 +1919,19 @@ int find_line_range(int fd, struct line_range *lr)return -EBADF ; } +/* Fastpath: lookup by function name from .debug_pubnames section */ +if (lr->function) { +struct dwarf_callback_param param = {.data = (void *)&lf, .retval =0 }; + +dwarf_getpubnames (dbg, pubname_search_cb, &lf,0 ); +if (lf.found) { + lf.found =0 ; +line_range_search_cb (&lf.sp_die, ¶m); +if (lf.found) + goto found; + } + } +/* Loop on CUs (Compilation Unit) */ while (!lf.found && ret >=0 ) {if (dwarf_nextcu (dbg, off, &noff, &cuhl,NULL ,NULL ,NULL ) !=0 )
@@ -1923,6 +1960,7 @@ int find_line_range(int fd, struct line_range *lr) off = noff; } +found:/* Store comp_dir */ if (lf.found) { comp_dir =cu_get_comp_dir (&lf.cu_die);
tools/perf/util/probe-finder.h +1 -0
@@ -83,6 +83,7 @@ struct line_finder {int lno_s;/* Start line number */ int lno_e;/* End line number */ Dwarf_Die cu_die;/* Current CU */ +Dwarf_Die sp_die;int found; };
Signature · 1 line
1.7.2.3
Quoted 10 lines · Lin Ming
./perf stat -r 10 -- ./perf probe -k
/home/mlin/vmlinux\
-s/home/mlin/linux-2.6\
--linecsum_partial_copy_to_user> tmp.logbefore patch applied
=====================364.535892 task-clock-msecs # 0.997 CPUs 865,862,109 cycles # 2375.245 M/sec 1,255,259,630 instructions # 1.450 IPC
Quoted 5 lines
after patch applied
=====================89.896405 task-clock-msecs # 0.991 CPUs 214,553,875 cycles # 2386.679 M/sec 226,915,559 instructions # 1.058 IPC
That's a very nice speedup :-)
Thanks,
Ingo
Quoted 21 lines · Lin Ming
The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs.Signed-off-by Lin Ming <[email protected]>--- tools/perf/util/probe-finder.c | 38 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-finder.h | 1 + 2 files changed, 39 insertions(+), 0 deletions(-)tools/perf/util/probe-finder.c +3
-0@@ -1876,6 +1876,30 @@ static int find_line_range_by_func(struct line_finder *lf)return param.retval; } +static int pubname_search_cb (Dwarf *dbg,Dwarf_Global *gl,void *data) +{ +struct line_finder *lf = data;
tools/perf/util/probe-finder.c static int find_line_range_by_func(struct line_finder *lf) · line 1891
Quoted 10 lines
tools/perf/util/probe-finder.c +10
-0+struct line_range *lr = lf->lr; + +if (dwarf_offdie (dbg, gl->die_offset, &lf->sp_die)) { +if (dwarf_tag (&lf->sp_die) != DW_TAG_subprogram) +return DWARF_CB_OK ; + +if (die_compare_name (&lf->sp_die, lr->function)) { +if (!dwarf_offdie (dbg, gl->cu_offset, &lf->cu_die)) +return DWARF_CB_OK ; +
Just one comment.
Could you ensure that the decl_file of sp_die matches lr->file (by strtailcmp) here?
Other parts look good to me:)
Thanks!
Quoted 54 lines
tools/perf/util/probe-finder.c +25
-0+if (lr->file && !cu_find_realpath (&lf->cu_die, lr->file)) +return DWARF_CB_OK ; + + lf->found =1 ; +return DWARF_CB_ABORT ; + } + } + +return DWARF_CB_OK ; +} +int find_line_range (int fd,struct line_range *lr) {struct line_finder lf = {.lr = lr, .found =0 };@@ -1895,6 +1919,19 @@ int find_line_range(int fd, struct line_range *lr)return -EBADF ; } +/* Fastpath: lookup by function name from .debug_pubnames section */ +if (lr->function) { +struct dwarf_callback_param param = {.data = (void *)&lf, .retval =0 }; + +dwarf_getpubnames (dbg, pubname_search_cb, &lf,0 ); +if (lf.found) { + lf.found =0 ; +line_range_search_cb (&lf.sp_die, ¶m); +if (lf.found) + goto found; + } + } +/* Loop on CUs (Compilation Unit) */ while (!lf.found && ret >=0 ) {if (dwarf_nextcu (dbg, off, &noff, &cuhl,NULL ,NULL ,NULL ) !=0 )@@ -1923,6 +1960,7 @@ int find_line_range(int fd, struct line_range *lr) off = noff; } +found:/* Store comp_dir */ if (lf.found) { comp_dir =cu_get_comp_dir (&lf.cu_die);tools/perf/util/probe-finder.h +1
-0@@ -83,6 +83,7 @@ struct line_finder {int lno_s;/* Start line number */ int lno_e;/* End line number */ Dwarf_Die cu_die;/* Current CU */ +Dwarf_Die sp_die;int found; };
Signature · 4 lines
Masami HIRAMATSU 2nd Dept. Linux Technology Center Hitachi, Ltd., Systems Development Laboratory E-mail: [email protected]
Quoted 19 lines · Masami Hiramatsu
Quoted 18 lines · Lin Ming
The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs.Signed-off-by Lin Ming <[email protected]>--- tools/perf/util/probe-finder.c | 38 ++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-finder.h | 1 + 2 files changed, 39 insertions(+), 0 deletions(-)tools/perf/util/probe-finder.c +0
-0@@ -1876,6 +1876,30 @@ static int find_line_range_by_func(struct line_finder *lf)return param.retval; }
Quoted 16 lines
tools/perf/util/probe-finder.c static int find_line_range_by_func(struct line_finder *lf) · line 1891
Quoted 13 lines
tools/perf/util/probe-finder.c +13
-0+static int pubname_search_cb (Dwarf *dbg,Dwarf_Global *gl,void *data) +{ +struct line_finder *lf = data; +struct line_range *lr = lf->lr; + +if (dwarf_offdie (dbg, gl->die_offset, &lf->sp_die)) { +if (dwarf_tag (&lf->sp_die) != DW_TAG_subprogram) +return DWARF_CB_OK ; + +if (die_compare_name (&lf->sp_die, lr->function)) { +if (!dwarf_offdie (dbg, gl->cu_offset, &lf->cu_die)) +return DWARF_CB_OK ; +Just one comment.
Could you ensure that thedecl_fileofsp_diematcheslr->file(by strtailcmp) here?
OK, so the file name compare with cu_find_realpath(..) can be removed, as below.
This makes the lookup a bit more faster again.
Thanks, I'll post a new version with below changes.
tools/perf/util/probe-finder.c +7 -2
@@ -1880,6 +1880,7 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data) {struct line_finder *lf = data;struct line_range *lr = lf->lr; +const char *file;if (dwarf_offdie (dbg, gl->die_offset, &lf->sp_die)) {if (dwarf_tag (&lf->sp_die) != DW_TAG_subprogram)
@@ -1889,8 +1890,12 @@ static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data)if (!dwarf_offdie (dbg, gl->cu_offset, &lf->cu_die))return DWARF_CB_OK ; -if (lr->file && !cu_find_realpath (&lf->cu_die, lr->file)) -return DWARF_CB_OK ; +if (lr->file) { + file =dwarf_decl_file (&lf->sp_die); + +if (file &&strtailcmp (file, lr->file)) +return DWARF_CB_OK ; + } lf->found =1 ;return DWARF_CB_ABORT ;
PATCH v2 1/1 perf probe: Add fastpath to do lookup by function name
v2 -> v1:
- Don't compare file names with cu_find_realpath(...), instead, compare them with the name returned by dwarf_decl_file(sp_die)
The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs.
./perf stat -r 10 -- ./perf probe -k /home/mlin/vmlinux \
-s /home/mlin/linux-2.6 \
--line csum_partial_copy_to_user > tmp.log
before patch applied
=====================
364.535892 task-clock-msecs # 0.997 CPUs
0 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
29,993 page-faults # 0.082 M/sec
865,862,109 cycles # 2375.245 M/sec
1,255,259,630 instructions # 1.450 IPC
252,400,884 branches # 692.390 M/sec
3,429,376 branch-misses # 1.359 %
1,386,990 cache-references # 3.805 M/sec
687,188 cache-misses # 1.885 M/sec0.365792170 seconds time elapsed
after patch applied
=====================
89.896405 task-clock-msecs # 0.991 CPUs
1 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
10,145 page-faults # 0.113 M/sec
214,553,875 cycles # 2386.679 M/sec
226,915,559 instructions # 1.058 IPC
44,536,614 branches # 495.422 M/sec
613,074 branch-misses # 1.377 %
860,787 cache-references # 9.575 M/sec
442,380 cache-misses # 4.921 M/sec0.090716032 seconds time elapsed
--- tools/perf/util/probe-finder.c | 39 +++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-finder.h | 1 + 2 files changed, 40 insertions(+), 0 deletions(-)
tools/perf/util/probe-finder.c +39 -0
@@ -1876,6 +1876,31 @@ static int find_line_range_by_func(struct line_finder *lf)return param.retval; } +static int pubname_search_cb (Dwarf *dbg,Dwarf_Global *gl,void *data) +{ +struct line_finder *lf = data; +struct line_range *lr = lf->lr; + +if (dwarf_offdie (dbg, gl->die_offset, &lf->sp_die)) { +if (dwarf_tag (&lf->sp_die) != DW_TAG_subprogram) +return DWARF_CB_OK ; + +if (die_compare_name (&lf->sp_die, lr->function)) { +if (!dwarf_offdie (dbg, gl->cu_offset, &lf->cu_die)) +return DWARF_CB_OK ; + +if (lr->file && +strtailcmp (lr->file,dwarf_decl_file (&lf->sp_die))) +return DWARF_CB_OK ; + + lf->found =1 ; +return DWARF_CB_ABORT ; + } + } + +return DWARF_CB_OK ; +} +int find_line_range (int fd,struct line_range *lr) {struct line_finder lf = {.lr = lr, .found =0 };
@@ -1895,6 +1920,19 @@ int find_line_range(int fd, struct line_range *lr)return -EBADF ; } +/* Fastpath: lookup by function name from .debug_pubnames section */ +if (lr->function) { +struct dwarf_callback_param param = {.data = (void *)&lf, .retval =0 }; + +dwarf_getpubnames (dbg, pubname_search_cb, &lf,0 ); +if (lf.found) { + lf.found =0 ; +line_range_search_cb (&lf.sp_die, ¶m); +if (lf.found) + goto found; + } + } +/* Loop on CUs (Compilation Unit) */ while (!lf.found && ret >=0 ) {if (dwarf_nextcu (dbg, off, &noff, &cuhl,NULL ,NULL ,NULL ) !=0 )
@@ -1923,6 +1961,7 @@ int find_line_range(int fd, struct line_range *lr) off = noff; } +found:/* Store comp_dir */ if (lf.found) { comp_dir =cu_get_comp_dir (&lf.cu_die);
tools/perf/util/probe-finder.h +1 -0
@@ -83,6 +83,7 @@ struct line_finder {int lno_s;/* Start line number */ int lno_e;/* End line number */ Dwarf_Die cu_die;/* Current CU */ +Dwarf_Die sp_die;int found; };
Signature · 1 line
1.7.2.3
Quoted 40 lines · Lin Ming
v2 -> v1:
- Don't compare file names withcu_find_realpath(...), instead, compare them with the name returned bydwarf_decl_file(sp_die)The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs../perf stat -r 10 -- ./perf probe -k
/home/mlin/vmlinux\
-s/home/mlin/linux-2.6\
--linecsum_partial_copy_to_user> tmp.logbefore patch applied
=====================364.535892 task-clock-msecs # 0.997 CPUs 0 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 29,993 page-faults # 0.082 M/sec 865,862,109 cycles # 2375.245 M/sec 1,255,259,630 instructions # 1.450 IPC 252,400,884 branches # 692.390 M/sec 3,429,376 branch-misses # 1.359 % 1,386,990 cache-references # 3.805 M/sec 687,188 cache-misses # 1.885 M/sec0.365792170 seconds time elapsedafter patch applied
=====================89.896405 task-clock-msecs # 0.991 CPUs 1 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 10,145 page-faults # 0.113 M/sec 214,553,875 cycles # 2386.679 M/sec 226,915,559 instructions # 1.058 IPC 44,536,614 branches # 495.422 M/sec 613,074 branch-misses # 1.377 % 860,787 cache-references # 9.575 M/sec 442,380 cache-misses # 4.921 M/sec
Quoted 1 line
0.090716032 seconds time elapsed
Thanks! Looks very good :)
Quoted 83 lines
Signed-off-by Lin Ming <[email protected]>--- tools/perf/util/probe-finder.c | 39 +++++++++++++++++++++++++++++++++++++++ tools/perf/util/probe-finder.h | 1 + 2 files changed, 40 insertions(+), 0 deletions(-)tools/perf/util/probe-finder.c +39
-0@@ -1876,6 +1876,31 @@ static int find_line_range_by_func(struct line_finder *lf)return param.retval; } +static int pubname_search_cb (Dwarf *dbg,Dwarf_Global *gl,void *data) +{ +struct line_finder *lf = data; +struct line_range *lr = lf->lr; + +if (dwarf_offdie (dbg, gl->die_offset, &lf->sp_die)) { +if (dwarf_tag (&lf->sp_die) != DW_TAG_subprogram) +return DWARF_CB_OK ; + +if (die_compare_name (&lf->sp_die, lr->function)) { +if (!dwarf_offdie (dbg, gl->cu_offset, &lf->cu_die)) +return DWARF_CB_OK ; + +if (lr->file && +strtailcmp (lr->file,dwarf_decl_file (&lf->sp_die))) +return DWARF_CB_OK ; + + lf->found =1 ; +return DWARF_CB_ABORT ; + } + } + +return DWARF_CB_OK ; +} +int find_line_range (int fd,struct line_range *lr) {struct line_finder lf = {.lr = lr, .found =0 };@@ -1895,6 +1920,19 @@ int find_line_range(int fd, struct line_range *lr)return -EBADF ; } +/* Fastpath: lookup by function name from .debug_pubnames section */ +if (lr->function) { +struct dwarf_callback_param param = {.data = (void *)&lf, .retval =0 }; + +dwarf_getpubnames (dbg, pubname_search_cb, &lf,0 ); +if (lf.found) { + lf.found =0 ; +line_range_search_cb (&lf.sp_die, ¶m); +if (lf.found) + goto found; + } + } +/* Loop on CUs (Compilation Unit) */ while (!lf.found && ret >=0 ) {if (dwarf_nextcu (dbg, off, &noff, &cuhl,NULL ,NULL ,NULL ) !=0 )@@ -1923,6 +1961,7 @@ int find_line_range(int fd, struct line_range *lr) off = noff; } +found:/* Store comp_dir */ if (lf.found) { comp_dir =cu_get_comp_dir (&lf.cu_die);tools/perf/util/probe-finder.h +1
-0@@ -83,6 +83,7 @@ struct line_finder {int lno_s;/* Start line number */ int lno_e;/* End line number */ Dwarf_Die cu_die;/* Current CU */ +Dwarf_Die sp_die;int found; };
Signature · 4 lines
Masami HIRAMATSU 2nd Dept. Linux Technology Center Hitachi, Ltd., Systems Development Laboratory E-mail: [email protected]
Em Fri, Mar 25, 2011 at 10:14:25AM +0900, Masami Hiramatsu escreveu:
Quoted 41 lines
Quoted 40 lines · Lin Ming
v2 -> v1:
- Don't compare file names withcu_find_realpath(...), instead, compare them with the name returned bydwarf_decl_file(sp_die)The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs../perf stat -r 10 -- ./perf probe -k
/home/mlin/vmlinux\
-s/home/mlin/linux-2.6\
--linecsum_partial_copy_to_user> tmp.logbefore patch applied
=====================364.535892 task-clock-msecs # 0.997 CPUs 0 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 29,993 page-faults # 0.082 M/sec 865,862,109 cycles # 2375.245 M/sec 1,255,259,630 instructions # 1.450 IPC 252,400,884 branches # 692.390 M/sec 3,429,376 branch-misses # 1.359 % 1,386,990 cache-references # 3.805 M/sec 687,188 cache-misses # 1.885 M/sec0.365792170 seconds time elapsedafter patch applied
=====================89.896405 task-clock-msecs # 0.991 CPUs 1 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 10,145 page-faults # 0.113 M/sec 214,553,875 cycles # 2386.679 M/sec 226,915,559 instructions # 1.058 IPC 44,536,614 branches # 495.422 M/sec 613,074 branch-misses # 1.377 % 860,787 cache-references # 9.575 M/sec 442,380 cache-misses # 4.921 M/sec
Quoted 5 lines
Quoted 1 line
0.090716032 seconds time elapsedThanks! Looks very good :)
Acked-by Masami Hiramatsu <[email protected]>
Indeed, I'll try and process this one tomorrow,
Thanks a lot!
- Arnaldo
Quoted 42 lines · 在 2011-03-25五的 10:57 +0800,Arnaldo Carvalho de Melo写道:
Em Fri, Mar 25, 2011 at 10:14:25AM +0900, Masami Hiramatsu escreveu:
Quoted 41 lines
Quoted 40 lines · Lin Ming
v2 -> v1:
- Don't compare file names withcu_find_realpath(...), instead, compare them with the name returned bydwarf_decl_file(sp_die)The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs../perf stat -r 10 -- ./perf probe -k
/home/mlin/vmlinux\
-s/home/mlin/linux-2.6\
--linecsum_partial_copy_to_user> tmp.logbefore patch applied
=====================364.535892 task-clock-msecs # 0.997 CPUs 0 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 29,993 page-faults # 0.082 M/sec 865,862,109 cycles # 2375.245 M/sec 1,255,259,630 instructions # 1.450 IPC 252,400,884 branches # 692.390 M/sec 3,429,376 branch-misses # 1.359 % 1,386,990 cache-references # 3.805 M/sec 687,188 cache-misses # 1.885 M/sec0.365792170 seconds time elapsedafter patch applied
=====================89.896405 task-clock-msecs # 0.991 CPUs 1 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 10,145 page-faults # 0.113 M/sec 214,553,875 cycles # 2386.679 M/sec 226,915,559 instructions # 1.058 IPC 44,536,614 branches # 495.422 M/sec 613,074 branch-misses # 1.377 % 860,787 cache-references # 9.575 M/sec 442,380 cache-misses # 4.921 M/sec
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
0.090716032 seconds time elapsedThanks! Looks very good :)
Acked-by Masami Hiramatsu <[email protected]>Indeed, I'll try and process this one tomorrow,
Except find_line_range, I just realized that the same optimization maybe added for find_probes.
Thanks,
Lin Ming
Quoted 4 lines
Thanks a lot!
- Arnaldo
Quoted 45 lines · Lin Ming
Quoted 44 lines · 在 2011-03-25五的 10:57 +0800,Arnaldo Carvalho de Melo写道:
Em Fri, Mar 25, 2011 at 10:14:25AM +0900, Masami Hiramatsu escreveu:
Quoted 43 lines
Quoted 41 lines · Lin Ming
v2 -> v1:
- Don't compare file names withcu_find_realpath(...), instead, compare them with the name returned bydwarf_decl_file(sp_die)The vmlinux file may have thousands of CUs.
We can lookup function name from .debug_pubnames section to avoid the slow loop on CUs../perf stat -r 10 -- ./perf probe -k
/home/mlin/vmlinux\
-s/home/mlin/linux-2.6\
--linecsum_partial_copy_to_user> tmp.logbefore patch applied
=====================364.535892 task-clock-msecs # 0.997 CPUs 0 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 29,993 page-faults # 0.082 M/sec 865,862,109 cycles # 2375.245 M/sec 1,255,259,630 instructions # 1.450 IPC 252,400,884 branches # 692.390 M/sec 3,429,376 branch-misses # 1.359 % 1,386,990 cache-references # 3.805 M/sec 687,188 cache-misses # 1.885 M/sec0.365792170 seconds time elapsedafter patch applied
=====================89.896405 task-clock-msecs # 0.991 CPUs 1 context-switches # 0.000 M/sec 0 CPU-migrations # 0.000 M/sec 10,145 page-faults # 0.113 M/sec 214,553,875 cycles # 2386.679 M/sec 226,915,559 instructions # 1.058 IPC 44,536,614 branches # 495.422 M/sec 613,074 branch-misses # 1.377 % 860,787 cache-references # 9.575 M/sec 442,380 cache-misses # 4.921 M/sec0.090716032 seconds time elapsed
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Thanks! Looks very good :)
Acked-by Masami Hiramatsu <[email protected]>Indeed, I'll try and process this one tomorrow,
Except
find_line_range, I just realized that the same optimization maybe added forfind_probes.
I have send out a v3 patch to add fastpath for find_probes.
Thanks,
Lin Ming
Quoted 9 lines
Thanks,
Lin MingQuoted 4 lines
Thanks a lot!
- Arnaldo