Re: [PATCH 2/5] kernel/jump_label: implement generic support for relative references
From: Peter Zijlstra
Date: Thu Jun 28 2018 - 05:25:20 EST
On Thu, Jun 28, 2018 at 11:04:45AM +0200, Ard Biesheuvel wrote:
> On 28 June 2018 at 11:02, Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> wrote:
> >>> @@ -56,7 +72,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
> >>>
> >>> size = (((unsigned long)stop - (unsigned long)start)
> >>> / sizeof(struct jump_entry));
> >>> - sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
> >>> + sort(start, size, sizeof(struct jump_entry), jump_label_cmp,
> >>> + IS_ENABLED(CONFIG_HAVE_ARCH_JUMP_LABEL_RELATIVE) ? jump_label_swap
> >>> + : NULL);
> >>> }
> >>
> >> That will result in jump_label_swap being an unused symbol for some
> >> compile options.
> >
> > No, and isn't that the point of IS_ENABLED()? The compiler sees a
> > reference to jump_label_swap(), so it won't complain about it being
> > unused.
Ah, ok. I hadn't figured it was quite that smart about it.
> > Meh. I thought IS_ENABLED() was preferred over #ifdef, no?
Dunno, I just reacted to the proposed code's uglyness :-)
> ... and it means the sort() routine will unconditionally perform an
> indirect function call even if the arch does not require it.
Yeah, not sure I care about that here, this is a one time affair, very
far away from any fast paths.