mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org, Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH v2] minmax: clamp more efficiently by avoiding extra comparison
Date: Fri, 23 Sep 2022 15:54:12 -0700	[thread overview]
Message-ID: <20220923155412.b0132fc62eca18817a023cd2@linux-foundation.org> (raw)
In-Reply-To: <20220923154001.4074849-1-Jason@zx2c4.com>

On Fri, 23 Sep 2022 17:40:01 +0200 "Jason A. Donenfeld" <Jason@zx2c4.com> wrote:

> Currently the clamp algorithm does:
> 
> 	if (val > hi)
> 		val = hi;
> 	if (val < lo)
> 		val = lo;
> 
> But since hi > lo by definition, this can be made more efficient with:
> 
> 	if (val > hi)
> 		val = hi;
> 	else if (val < lo)
> 		val = lo;
> 
> So fix up the clamp and clamp_t functions to do this, adding the same
> argument checking as for min and min_t.
> 

The patch adds 140 bytes of text to mm/memblock.o, for example. 
Presumably from the additional branch.  Larger text means larger cache
footprint means slower.

So where's the proof that this change gives us a more efficient kernel?

  parent reply	other threads:[~2022-09-23 22:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23 10:06 [PATCH] " Jason A. Donenfeld
2022-09-23 10:35 ` Andy Shevchenko
2022-09-23 10:40   ` Jason A. Donenfeld
2022-09-23 10:48     ` Jason A. Donenfeld
2022-09-23 15:12       ` Andy Shevchenko
2022-09-23 15:13         ` Jason A. Donenfeld
2022-09-23 15:40           ` [PATCH v2] " Jason A. Donenfeld
2022-09-23 16:41             ` Kees Cook
2022-09-23 16:42               ` Jason A. Donenfeld
2022-09-23 16:53               ` Andy Shevchenko
2022-09-23 16:54                 ` Jason A. Donenfeld
2022-09-23 19:47             ` Kees Cook
2022-09-23 22:54             ` Andrew Morton [this message]
2022-09-24  0:02               ` Kees Cook
2022-09-24 10:37               ` Jason A. Donenfeld
2022-09-25 16:29                 ` Andrew Morton
2022-09-26 10:00                 ` Andy Shevchenko
2022-09-26 12:23                   ` Jason A. Donenfeld
2022-09-26 13:34                     ` [PATCH v3 1/2] minmax: sanity check constant bounds when clamping Jason A. Donenfeld
2022-09-26 13:34                       ` [PATCH v3 2/2] minmax: clamp more efficiently by avoiding extra comparison Jason A. Donenfeld
2022-09-26 18:30                         ` Kees Cook
2022-09-26 21:33                           ` Jason A. Donenfeld
2022-09-26 13:46                       ` [PATCH v3 1/2] minmax: sanity check constant bounds when clamping Andy Shevchenko
2022-09-26 18:26                       ` Kees Cook
2022-10-04 13:41                         ` Jason A. Donenfeld
2022-10-04 14:39                           ` Kees Cook
2022-10-04 15:01                             ` Jason A. Donenfeld
2022-09-26 18:30                     ` [PATCH v2] minmax: clamp more efficiently by avoiding extra comparison Kees Cook
2022-09-23 15:10     ` [PATCH] " Andy Shevchenko
2022-09-23 15:11       ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220923155412.b0132fc62eca18817a023cd2@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=Jason@zx2c4.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome