Skip to content

Commit b966794

Browse files
ahunter6acmel
authored andcommitted
kallsyms: Simplify update_iter_mod()
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 <adrian.hunter@intel.com> Tested-by: (ftrace changes only) Steven Rostedt (VMware) <rostedt@goodmis.org> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Joerg Roedel <joro@8bytes.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: x86@kernel.org Link: http://lkml.kernel.org/r/1528289651-4113-2-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 99cbbe5 commit b966794

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

kernel/kallsyms.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -506,27 +506,24 @@ static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
506506
}
507507
}
508508

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

513-
if (iter->pos_ftrace_mod_end > 0 &&
514-
iter->pos_ftrace_mod_end < iter->pos)
515-
return get_ksymbol_bpf(iter);
516-
517-
if (iter->pos_mod_end > 0 &&
518-
iter->pos_mod_end < iter->pos) {
519-
if (!get_ksymbol_ftrace_mod(iter))
520-
return get_ksymbol_bpf(iter);
518+
if ((!iter->pos_mod_end || iter->pos_mod_end > pos) &&
519+
get_ksymbol_mod(iter))
521520
return 1;
522-
}
523521

524-
if (!get_ksymbol_mod(iter)) {
525-
if (!get_ksymbol_ftrace_mod(iter))
526-
return get_ksymbol_bpf(iter);
527-
}
522+
if ((!iter->pos_ftrace_mod_end || iter->pos_ftrace_mod_end > pos) &&
523+
get_ksymbol_ftrace_mod(iter))
524+
return 1;
528525

529-
return 1;
526+
return get_ksymbol_bpf(iter);
530527
}
531528

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

0 commit comments

Comments
 (0)