[PATCH 2/5] kernel/jump_label: implement generic support for relative references
From: Ard Biesheuvel <hidden>
Date: 2018-06-28 09:29:45
Also in:
lkml
On 28 June 2018 at 11:25, Peter Zijlstra [off-list ref] wrote:
On Thu, Jun 28, 2018 at 11:04:45AM +0200, Ard Biesheuvel wrote:quoted
On 28 June 2018 at 11:02, Ard Biesheuvel [off-list ref] wrote:quoted
quoted
quoted
@@ -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.
Yeah. I could use a temp variable to make the indentation less obnoxious, but since this is an opt-in feature, I'd like to preserve the NULL (*swap)() argument for the existing users.
quoted
quoted
Meh. I thought IS_ENABLED() was preferred over #ifdef, no?Dunno, I just reacted to the proposed code's uglyness :-)
I will try to come up with something that rhymes, ok? :-)
quoted
... 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.
Fair enough.