提交 3e406b1d 编写于 作者: R Rasmus Villemoes 提交者: Linus Torvalds

lib/dynamic_debug.c: use kstrdup_const

Using kstrdup_const, thus reusing .rodata when possible, saves around 2 kB
of runtime memory on my laptop/.config combination.
Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Jason Baron <jbaron@akamai.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 eac44a5e
...@@ -42,7 +42,7 @@ extern struct _ddebug __stop___verbose[]; ...@@ -42,7 +42,7 @@ extern struct _ddebug __stop___verbose[];
struct ddebug_table { struct ddebug_table {
struct list_head link; struct list_head link;
char *mod_name; const char *mod_name;
unsigned int num_ddebugs; unsigned int num_ddebugs;
struct _ddebug *ddebugs; struct _ddebug *ddebugs;
}; };
...@@ -841,12 +841,12 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, ...@@ -841,12 +841,12 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
const char *name) const char *name)
{ {
struct ddebug_table *dt; struct ddebug_table *dt;
char *new_name; const char *new_name;
dt = kzalloc(sizeof(*dt), GFP_KERNEL); dt = kzalloc(sizeof(*dt), GFP_KERNEL);
if (dt == NULL) if (dt == NULL)
return -ENOMEM; return -ENOMEM;
new_name = kstrdup(name, GFP_KERNEL); new_name = kstrdup_const(name, GFP_KERNEL);
if (new_name == NULL) { if (new_name == NULL) {
kfree(dt); kfree(dt);
return -ENOMEM; return -ENOMEM;
...@@ -907,7 +907,7 @@ int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module) ...@@ -907,7 +907,7 @@ int ddebug_dyndbg_module_param_cb(char *param, char *val, const char *module)
static void ddebug_table_free(struct ddebug_table *dt) static void ddebug_table_free(struct ddebug_table *dt)
{ {
list_del_init(&dt->link); list_del_init(&dt->link);
kfree(dt->mod_name); kfree_const(dt->mod_name);
kfree(dt); kfree(dt);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册