mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
livepatch: Use kallsyms_on_each_match_symbol() to improve performance
Based on the test results of kallsyms_on_each_match_symbol() and kallsyms_on_each_symbol(), the average performance can be improved by more than 1500 times. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
This commit is contained in:
committed by
Luis Chamberlain
parent
4dc533e0f2
commit
9cb37357df
@@ -153,6 +153,24 @@ static int klp_find_callback(void *data, const char *name,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int klp_match_callback(void *data, unsigned long addr)
|
||||||
|
{
|
||||||
|
struct klp_find_arg *args = data;
|
||||||
|
|
||||||
|
args->addr = addr;
|
||||||
|
args->count++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Finish the search when the symbol is found for the desired position
|
||||||
|
* or the position is not defined for a non-unique symbol.
|
||||||
|
*/
|
||||||
|
if ((args->pos && (args->count == args->pos)) ||
|
||||||
|
(!args->pos && (args->count > 1)))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int klp_find_object_symbol(const char *objname, const char *name,
|
static int klp_find_object_symbol(const char *objname, const char *name,
|
||||||
unsigned long sympos, unsigned long *addr)
|
unsigned long sympos, unsigned long *addr)
|
||||||
{
|
{
|
||||||
@@ -167,7 +185,7 @@ static int klp_find_object_symbol(const char *objname, const char *name,
|
|||||||
if (objname)
|
if (objname)
|
||||||
module_kallsyms_on_each_symbol(klp_find_callback, &args);
|
module_kallsyms_on_each_symbol(klp_find_callback, &args);
|
||||||
else
|
else
|
||||||
kallsyms_on_each_symbol(klp_find_callback, &args);
|
kallsyms_on_each_match_symbol(klp_match_callback, name, &args);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure an address was found. If sympos is 0, ensure symbol is unique;
|
* Ensure an address was found. If sympos is 0, ensure symbol is unique;
|
||||||
|
Reference in New Issue
Block a user