Skip to content

Commit 92edca0

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Use direct field, type and system names
The names used to display the field and type in the event format files are copied, as well as the system name that is displayed. All these names are created by constant values passed in. If one of theses values were to be removed by a module, the module would also be required to remove any event it created. By using the strings directly, we can save over 100K of memory. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent d1a2914 commit 92edca0

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

kernel/trace/trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,8 @@ enum {
887887

888888
struct ftrace_event_field {
889889
struct list_head link;
890-
char *name;
891-
char *type;
890+
const char *name;
891+
const char *type;
892892
int filter_type;
893893
int offset;
894894
int size;

kernel/trace/trace_events.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,8 @@ static int __trace_define_field(struct list_head *head, const char *type,
7272
if (!field)
7373
goto err;
7474

75-
field->name = kstrdup(name, GFP_KERNEL);
76-
if (!field->name)
77-
goto err;
78-
79-
field->type = kstrdup(type, GFP_KERNEL);
80-
if (!field->type)
81-
goto err;
75+
field->name = name;
76+
field->type = type;
8277

8378
if (filter_type == FILTER_OTHER)
8479
field->filter_type = filter_assign_type(type);
@@ -94,8 +89,6 @@ static int __trace_define_field(struct list_head *head, const char *type,
9489
return 0;
9590

9691
err:
97-
if (field)
98-
kfree(field->name);
9992
kmem_cache_free(field_cachep, field);
10093

10194
return -ENOMEM;
@@ -146,8 +139,6 @@ void trace_destroy_fields(struct ftrace_event_call *call)
146139
head = trace_get_fields(call);
147140
list_for_each_entry_safe(field, next, head, link) {
148141
list_del(&field->link);
149-
kfree(field->type);
150-
kfree(field->name);
151142
kmem_cache_free(field_cachep, field);
152143
}
153144
}
@@ -286,7 +277,6 @@ static void __put_system(struct event_subsystem *system)
286277
kfree(filter->filter_string);
287278
kfree(filter);
288279
}
289-
kfree(system->name);
290280
kfree(system);
291281
}
292282

@@ -1202,10 +1192,7 @@ create_new_subsystem(const char *name)
12021192
return NULL;
12031193

12041194
system->ref_count = 1;
1205-
system->name = kstrdup(name, GFP_KERNEL);
1206-
1207-
if (!system->name)
1208-
goto out_free;
1195+
system->name = name;
12091196

12101197
system->filter = NULL;
12111198

@@ -1218,7 +1205,6 @@ create_new_subsystem(const char *name)
12181205
return system;
12191206

12201207
out_free:
1221-
kfree(system->name);
12221208
kfree(system);
12231209
return NULL;
12241210
}

0 commit comments

Comments
 (0)