lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 15 Apr 2019 12:55:29 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Daniel Bristot de Oliveira <bristot@...hat.com>
Cc:     linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        "Steven Rostedt (VMware)" <rostedt@...dmis.org>,
        Jiri Kosina <jkosina@...e.cz>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Chris von Recklinghausen <crecklin@...hat.com>,
        Jason Baron <jbaron@...mai.com>, Scott Wood <swood@...hat.com>,
        Marcelo Tosatti <mtosatti@...hat.com>,
        Clark Williams <williams@...hat.com>, x86@...nel.org
Subject: Re: [PATCH V5 4/7] jump_label: Sort entries of the same key by the
 code

On Mon, Apr 01, 2019 at 10:58:16AM +0200, Daniel Bristot de Oliveira wrote:
> 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.

Might be good to explain *why*.

We can see what the code does, explaining why we do things is what we
have Changelogs for.

> Signed-off-by: Daniel Bristot de Oliveira <bristot@...hat.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Ingo Molnar <mingo@...hat.com>
> Cc: Borislav Petkov <bp@...en8.de>
> Cc: "H. Peter Anvin" <hpa@...or.com>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: Masami Hiramatsu <mhiramat@...nel.org>
> Cc: "Steven Rostedt (VMware)" <rostedt@...dmis.org>
> Cc: Jiri Kosina <jkosina@...e.cz>
> Cc: Josh Poimboeuf <jpoimboe@...hat.com>
> Cc: "Peter Zijlstra (Intel)" <peterz@...radead.org>
> Cc: Chris von Recklinghausen <crecklin@...hat.com>
> Cc: Jason Baron <jbaron@...mai.com>
> Cc: Scott Wood <swood@...hat.com>
> Cc: Marcelo Tosatti <mtosatti@...hat.com>
> Cc: Clark Williams <williams@...hat.com>
> Cc: x86@...nel.org
> Cc: linux-kernel@...r.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;
>  }

The secondary sort order doesn't hurt, so we could leave the #ifdef out,
not sure.

Powered by blists - more mailing lists