Messages in this thread Patch in this message | | | From | Daniel Bristot de Oliveira <> | Subject | [PATCH V5 4/7] jump_label: Sort entries of the same key by the code | Date | Mon, 1 Apr 2019 10:58:16 +0200 |
| |
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 <bristot@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org> Cc: Chris von Recklinghausen <crecklin@redhat.com> Cc: Jason Baron <jbaron@akamai.com> Cc: Scott Wood <swood@redhat.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Clark Williams <williams@redhat.com> Cc: x86@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
| |