Commit 93af5a5
livepatch: Improve the search performance of module_kallsyms_on_each_symbol()
Currently we traverse all symbols of all modules to find the specified
function for the specified module. But in reality, we just need to find
the given module and then traverse all the symbols in it.
Let's add a new parameter 'const char *modname' to function
module_kallsyms_on_each_symbol(), then we can compare the module names
directly in this function and call hook 'fn' after matching. If 'modname'
is NULL, the symbols of all modules are still traversed for compatibility
with other usage cases.
Phase1: mod1-->mod2..(subsequent modules do not need to be compared)
|
Phase2: -->f1-->f2-->f3
Assuming that there are m modules, each module has n symbols on average,
then the time complexity is reduced from O(m * n) to O(m) + O(n).
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>1 parent 97f9f94 commit 93af5a5
File tree
5 files changed
+19
-14
lines changed- include/linux
- kernel
- livepatch
- module
- trace
5 files changed
+19
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
879 | 879 | | |
880 | 880 | | |
881 | 881 | | |
882 | | - | |
| 882 | + | |
| 883 | + | |
883 | 884 | | |
884 | 885 | | |
885 | 886 | | |
886 | | - | |
| 887 | + | |
| 888 | + | |
887 | 889 | | |
888 | 890 | | |
889 | 891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
122 | 121 | | |
123 | 122 | | |
124 | 123 | | |
| |||
148 | 147 | | |
149 | 148 | | |
150 | 149 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | 150 | | |
155 | 151 | | |
156 | 152 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | 153 | | |
161 | 154 | | |
162 | 155 | | |
163 | 156 | | |
164 | 157 | | |
165 | 158 | | |
166 | 159 | | |
167 | | - | |
168 | 160 | | |
169 | 161 | | |
170 | 162 | | |
171 | 163 | | |
172 | 164 | | |
173 | 165 | | |
174 | 166 | | |
175 | | - | |
| 167 | + | |
176 | 168 | | |
177 | 169 | | |
178 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | | - | |
| 497 | + | |
| 498 | + | |
498 | 499 | | |
499 | 500 | | |
500 | 501 | | |
| |||
509 | 510 | | |
510 | 511 | | |
511 | 512 | | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
512 | 516 | | |
513 | 517 | | |
514 | 518 | | |
| |||
525 | 529 | | |
526 | 530 | | |
527 | 531 | | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
528 | 539 | | |
529 | 540 | | |
530 | 541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2735 | 2735 | | |
2736 | 2736 | | |
2737 | 2737 | | |
2738 | | - | |
| 2738 | + | |
2739 | 2739 | | |
2740 | 2740 | | |
2741 | 2741 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8324 | 8324 | | |
8325 | 8325 | | |
8326 | 8326 | | |
8327 | | - | |
| 8327 | + | |
8328 | 8328 | | |
8329 | 8329 | | |
8330 | 8330 | | |
| |||
0 commit comments