Skip to content

Commit

Permalink
lib/dynamic_debug.c: use kstrdup_const
Browse files Browse the repository at this point in the history
Using kstrdup_const, thus reusing .rodata when possible, saves around 2 kB
of runtime memory on my laptop/.config combination.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Jason Baron <jbaron@akamai.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Villemoes authored and torvalds committed Nov 7, 2015
1 parent eac44a5 commit 3e406b1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/dynamic_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern struct _ddebug __stop___verbose[];

struct ddebug_table {
struct list_head link;
char *mod_name;
const char *mod_name;
unsigned int num_ddebugs;
struct _ddebug *ddebugs;
};
Expand Down Expand Up @@ -841,12 +841,12 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
const char *name)
{
struct ddebug_table *dt;
char *new_name;
const char *new_name;

dt = kzalloc(sizeof(*dt), GFP_KERNEL);
if (dt == NULL)
return -ENOMEM;
new_name = kstrdup(name, GFP_KERNEL);
new_name = kstrdup_const(name, GFP_KERNEL);
if (new_name == NULL) {
kfree(dt);
return -ENOMEM;
Expand Down Expand Up @@ -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)
{
list_del_init(&dt->link);
kfree(dt->mod_name);
kfree_const(dt->mod_name);
kfree(dt);
}

Expand Down

0 comments on commit 3e406b1

Please sign in to comment.