Skip to content

Commit

Permalink
kallsyms: Simplify update_iter_mod()
Browse files Browse the repository at this point in the history
The logic in update_iter_mod() is overcomplicated and gets worse every
time another get_ksymbol_* function is added.

In preparation for adding another get_ksymbol_* function, simplify logic
in update_iter_mod().

Signed-off-by: Adrian Hunter <[email protected]>
Tested-by: (ftrace changes only) Steven Rostedt (VMware) <[email protected]>
Acked-by: Andi Kleen <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Joerg Roedel <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
ahunter6 authored and acmel committed Aug 14, 2018
1 parent 99cbbe5 commit b966794
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions kernel/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,27 +506,24 @@ static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
}
}

/*
* The end position (last + 1) of each additional kallsyms section is recorded
* in iter->pos_..._end as each section is added, and so can be used to
* determine which get_ksymbol_...() function to call next.
*/
static int update_iter_mod(struct kallsym_iter *iter, loff_t pos)
{
iter->pos = pos;

if (iter->pos_ftrace_mod_end > 0 &&
iter->pos_ftrace_mod_end < iter->pos)
return get_ksymbol_bpf(iter);

if (iter->pos_mod_end > 0 &&
iter->pos_mod_end < iter->pos) {
if (!get_ksymbol_ftrace_mod(iter))
return get_ksymbol_bpf(iter);
if ((!iter->pos_mod_end || iter->pos_mod_end > pos) &&
get_ksymbol_mod(iter))
return 1;
}

if (!get_ksymbol_mod(iter)) {
if (!get_ksymbol_ftrace_mod(iter))
return get_ksymbol_bpf(iter);
}
if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) &&
get_ksymbol_ftrace_mod(iter))
return 1;

return 1;
return get_ksymbol_bpf(iter);
}

/* Returns false if pos at or past end of file. */
Expand Down

0 comments on commit b966794

Please sign in to comment.