Commit-ID: 1ca3398278341e1db3568f2d9c015ee4f5ad0b56 Gitweb: https://git.kernel.org/tip/1ca3398278341e1db3568f2d9c015ee4f5ad0b56 Author: Daniel Bristot de Oliveira <bris...@redhat.com> AuthorDate: Fri, 21 Dec 2018 11:27:31 +0100 Committer: Ingo Molnar <mi...@kernel.org> CommitDate: Fri, 19 Apr 2019 19:37:34 +0200
jump_label: Sort entries of the same key by the code In the batching mode, entries with the same key should also be sorted by the code, enabling a bsearch() of a code/addr when updating a key. Signed-off-by: Daniel Bristot de Oliveira <bris...@redhat.com> Cc: Alexander Shishkin <alexander.shish...@linux.intel.com> Cc: Andy Lutomirski <l...@kernel.org> Cc: Arnaldo Carvalho de Melo <a...@redhat.com> Cc: Borislav Petkov <b...@alien8.de> Cc: Brian Gerst <brge...@gmail.com> Cc: Chris von Recklinghausen <creck...@redhat.com> Cc: Clark Williams <willi...@redhat.com> Cc: Denys Vlasenko <dvlas...@redhat.com> Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org> Cc: H. Peter Anvin <h...@zytor.com> Cc: Jason Baron <jba...@akamai.com> Cc: Jiri Kosina <jkos...@suse.cz> Cc: Jiri Olsa <jo...@redhat.com> Cc: Josh Poimboeuf <jpoim...@redhat.com> Cc: Linus Torvalds <torva...@linux-foundation.org> Cc: Marcelo Tosatti <mtosa...@redhat.com> Cc: Masami Hiramatsu <mhira...@kernel.org> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Scott Wood <sw...@redhat.com> Cc: Steven Rostedt (VMware) <rost...@goodmis.org> Cc: Thomas Gleixner <t...@linutronix.de> Link: http://lkml.kernel.org/r/7006ec86c40e5ec5d546dcd76ccc42d46079a963.1545228276.git.bris...@redhat.com Signed-off-by: Ingo Molnar <mi...@kernel.org> --- kernel/jump_label.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index 456c0d7cbb5b..53b7c85c0b09 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -36,12 +36,28 @@ static int jump_label_cmp(const void *a, const void *b) const struct jump_entry *jea = a; const struct jump_entry *jeb = b; + /* + * Entrires are sorted by key. + */ if (jump_entry_key(jea) < jump_entry_key(jeb)) return -1; if (jump_entry_key(jea) > jump_entry_key(jeb)) return 1; +#ifdef HAVE_JUMP_LABEL_BATCH + /* + * In the batching mode, entries should also be sorted by the code + * inside the already sorted list of entries, enabling a bsearch in + * the vector. + */ + if (jump_entry_code(jea) < jump_entry_code(jeb)) + return -1; + + if (jump_entry_code(jea) > jump_entry_code(jeb)) + return 1; +#endif + return 0; }