Commit ee000b7f9fe429d2470c674ccec8d344f6789e0d
Committed by
Ingo Molnar
1 parent
cc59c9e8d0
Exists in
master
and in
7 other branches
tracing: use union for multi-usages field
Impact: cleanup struct dyn_ftrace::ip has different usages in his lifecycle, we use union for it. And also for struct dyn_ftrace::flags. Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Steven Rostedt <srostedt@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <49C871BE.3080405@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Showing 2 changed files with 13 additions and 7 deletions Side-by-side Diff
include/linux/ftrace.h
... | ... | @@ -145,9 +145,15 @@ |
145 | 145 | }; |
146 | 146 | |
147 | 147 | struct dyn_ftrace { |
148 | - unsigned long ip; /* address of mcount call-site */ | |
149 | - unsigned long flags; | |
150 | - struct dyn_arch_ftrace arch; | |
148 | + union { | |
149 | + unsigned long ip; /* address of mcount call-site */ | |
150 | + struct dyn_ftrace *freelist; | |
151 | + }; | |
152 | + union { | |
153 | + unsigned long flags; | |
154 | + struct dyn_ftrace *newlist; | |
155 | + }; | |
156 | + struct dyn_arch_ftrace arch; | |
151 | 157 | }; |
152 | 158 | |
153 | 159 | int ftrace_force_update(void); |
kernel/trace/ftrace.c
... | ... | @@ -341,7 +341,7 @@ |
341 | 341 | |
342 | 342 | static void ftrace_free_rec(struct dyn_ftrace *rec) |
343 | 343 | { |
344 | - rec->ip = (unsigned long)ftrace_free_records; | |
344 | + rec->freelist = ftrace_free_records; | |
345 | 345 | ftrace_free_records = rec; |
346 | 346 | rec->flags |= FTRACE_FL_FREE; |
347 | 347 | } |
... | ... | @@ -379,7 +379,7 @@ |
379 | 379 | return NULL; |
380 | 380 | } |
381 | 381 | |
382 | - ftrace_free_records = (void *)rec->ip; | |
382 | + ftrace_free_records = rec->freelist; | |
383 | 383 | memset(rec, 0, sizeof(*rec)); |
384 | 384 | return rec; |
385 | 385 | } |
... | ... | @@ -411,7 +411,7 @@ |
411 | 411 | return NULL; |
412 | 412 | |
413 | 413 | rec->ip = ip; |
414 | - rec->flags = (unsigned long)ftrace_new_addrs; | |
414 | + rec->newlist = ftrace_new_addrs; | |
415 | 415 | ftrace_new_addrs = rec; |
416 | 416 | |
417 | 417 | return rec; |
... | ... | @@ -731,7 +731,7 @@ |
731 | 731 | return -1; |
732 | 732 | |
733 | 733 | p = ftrace_new_addrs; |
734 | - ftrace_new_addrs = (struct dyn_ftrace *)p->flags; | |
734 | + ftrace_new_addrs = p->newlist; | |
735 | 735 | p->flags = 0L; |
736 | 736 | |
737 | 737 | /* convert record (i.e, patch mcount-call with NOP) */ |