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: Thomas Gleixner <t...@linutronix.de>
Cc: Ingo Molnar <mi...@redhat.com>
Cc: Borislav Petkov <b...@alien8.de>
Cc: "H. Peter Anvin" <h...@zytor.com>
Cc: Greg Kroah-Hartman <gre...@linuxfoundation.org>
Cc: Masami Hiramatsu <mhira...@kernel.org>
Cc: "Steven Rostedt (VMware)" <rost...@goodmis.org>
Cc: Jiri Kosina <jkos...@suse.cz>
Cc: Josh Poimboeuf <jpoim...@redhat.com>
Cc: "Peter Zijlstra (Intel)" <pet...@infradead.org>
Cc: Chris von Recklinghausen <creck...@redhat.com>
Cc: Jason Baron <jba...@akamai.com>
Cc: Scott Wood <sw...@redhat.com>
Cc: Marcelo Tosatti <mtosa...@redhat.com>
Cc: Clark Williams <willi...@redhat.com>
Cc: x...@kernel.org
Cc: linux-kernel@vger.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 e666a4d6642a..8b7bfbba4cef 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;
 }
 
-- 
2.20.1

Reply via email to