diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-03-18 04:03:19 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-03-18 05:10:17 -0400 |
commit | 2c7eea4c62ba090b7f4583c3d7337ea0019be900 (patch) | |
tree | 2a85739caeef13035316d47f61cab11f3a91660f /kernel | |
parent | 18aecd362a1c991fbf5f7919ae051a77532ba2f8 (diff) |
tracing: replace the crude (unsigned) -1 hackery
Impact: cleanup
The command line recorder uses (unsigned) -1 to mark non mapped
entries in the pid to command line maps. The validity check is
completely unintuitive: idx >= SAVED_CMDLINES
There is no need for such casting games. Use a constant to mark
unmapped entries and check for that constant to make the code readable
and understandable.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/trace/trace.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 7b6043ea256e..ca673c475687 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -633,6 +633,7 @@ void tracing_reset_online_cpus(struct trace_array *tr) | |||
633 | } | 633 | } |
634 | 634 | ||
635 | #define SAVED_CMDLINES 128 | 635 | #define SAVED_CMDLINES 128 |
636 | #define NO_CMDLINE_MAP UINT_MAX | ||
636 | static unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1]; | 637 | static unsigned map_pid_to_cmdline[PID_MAX_DEFAULT+1]; |
637 | static unsigned map_cmdline_to_pid[SAVED_CMDLINES]; | 638 | static unsigned map_cmdline_to_pid[SAVED_CMDLINES]; |
638 | static char saved_cmdlines[SAVED_CMDLINES][TASK_COMM_LEN]; | 639 | static char saved_cmdlines[SAVED_CMDLINES][TASK_COMM_LEN]; |
@@ -644,8 +645,8 @@ static atomic_t trace_record_cmdline_disabled __read_mostly; | |||
644 | 645 | ||
645 | static void trace_init_cmdlines(void) | 646 | static void trace_init_cmdlines(void) |
646 | { | 647 | { |
647 | memset(&map_pid_to_cmdline, -1, sizeof(map_pid_to_cmdline)); | 648 | memset(&map_pid_to_cmdline, NO_CMDLINE_MAP, sizeof(map_pid_to_cmdline)); |
648 | memset(&map_cmdline_to_pid, -1, sizeof(map_cmdline_to_pid)); | 649 | memset(&map_cmdline_to_pid, NO_CMDLINE_MAP, sizeof(map_cmdline_to_pid)); |
649 | cmdline_idx = 0; | 650 | cmdline_idx = 0; |
650 | } | 651 | } |
651 | 652 | ||
@@ -753,12 +754,12 @@ static void trace_save_cmdline(struct task_struct *tsk) | |||
753 | return; | 754 | return; |
754 | 755 | ||
755 | idx = map_pid_to_cmdline[tsk->pid]; | 756 | idx = map_pid_to_cmdline[tsk->pid]; |
756 | if (idx >= SAVED_CMDLINES) { | 757 | if (idx == NO_CMDLINE_MAP) { |
757 | idx = (cmdline_idx + 1) % SAVED_CMDLINES; | 758 | idx = (cmdline_idx + 1) % SAVED_CMDLINES; |
758 | 759 | ||
759 | map = map_cmdline_to_pid[idx]; | 760 | map = map_cmdline_to_pid[idx]; |
760 | if (map <= PID_MAX_DEFAULT) | 761 | if (map != NO_CMDLINE_MAP) |
761 | map_pid_to_cmdline[map] = (unsigned)-1; | 762 | map_pid_to_cmdline[map] = NO_CMDLINE_MAP; |
762 | 763 | ||
763 | map_pid_to_cmdline[tsk->pid] = idx; | 764 | map_pid_to_cmdline[tsk->pid] = idx; |
764 | 765 | ||
@@ -786,7 +787,7 @@ void trace_find_cmdline(int pid, char comm[]) | |||
786 | 787 | ||
787 | __raw_spin_lock(&trace_cmdline_lock); | 788 | __raw_spin_lock(&trace_cmdline_lock); |
788 | map = map_pid_to_cmdline[pid]; | 789 | map = map_pid_to_cmdline[pid]; |
789 | if (map >= SAVED_CMDLINES) | 790 | if (map == NO_CMDLINE_MAP) |
790 | goto out; | 791 | goto out; |
791 | 792 | ||
792 | strcpy(comm, saved_cmdlines[map]); | 793 | strcpy(comm, saved_cmdlines[map]); |