Commit-ID: 1ca3398278341e1db3568f2d9c015ee4f5ad0b56 Gitweb: https://git.kernel.org/tip/1ca3398278341e1db3568f2d9c015ee4f5ad0b56 Author: Daniel Bristot de Oliveira <[email protected]> AuthorDate: Fri, 21 Dec 2018 11:27:31 +0100 Committer: Ingo Molnar <[email protected]> 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 <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Chris von Recklinghausen <[email protected]> Cc: Clark Williams <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Jason Baron <[email protected]> Cc: Jiri Kosina <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Marcelo Tosatti <[email protected]> Cc: Masami Hiramatsu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Scott Wood <[email protected]> Cc: Steven Rostedt (VMware) <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/7006ec86c40e5ec5d546dcd76ccc42d46079a963.1545228276.git.bris...@redhat.com Signed-off-by: Ingo Molnar <[email protected]> --- 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; }

