linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: torvalds@linux-foundation.org
Cc: James.Bottomley@hansenpartnership.com, geert@linux-m68k.org,
	linux-arch@vger.kernel.org
Subject: Re: Arch maintainers Ahoy!
Date: Wed, 23 May 2012 14:35:43 -0400 (EDT)	[thread overview]
Message-ID: <20120523.143543.366370918467441501.davem@davemloft.net> (raw)
In-Reply-To: <CA+55aFxcRc_zR9HtFAtrT1exGP2DspP0aA6T49Ph3kZEHHyQWw@mail.gmail.com>

From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Wed, 23 May 2012 11:27:00 -0700

> It's not faster to just do something like
> 
>    int byte = 4;
> 
> #if CONFIG_64BIT
>    byte = 8;
>    if (has_zero_32bit(value >> 32)) {
>        value >>= 32;
>        byte = 4;
>    }
> #endif
>    if (has_zero_16(value >> 16)) {
>       value >>= 16;
>       byte -= 2;
>    }
>    if (!value & 0xff00)
>       byte--;
>    return byte;
> 
> which looks like it might generate ok code?

It might be, I'll play around with it.

FWIW, when I code this end case in assembler on sparc64 I just go for
a bunch of conditional moves, so I'll try to come up with something
similar to the above that gcc will emit reasonably.

> Btw, when benchmarking, make sure that your branches do not predict
> well. Because in real life they won't predict well. So you can't
> benchmark the mask->byte function with some  well-behaved input that
> commonly returns the same value.

Indeed, and that's why I'd prefer it if gcc were to emit conditional
moves :-)

>> For reference here is the final version of the sparc commit, it works
>> and I've been running tests on it since last night.  I'm extrmely
>> confident the C code will work on any big-endian machine.
> 
> Umm. Except your "top of address space" thing is entirely sparc-specific.

Although a bit more expensive than what you can do on the x86 side
with these tests, I think my code should work.

Comparing get_fs() with USER_DS should be portable enough, as should
STACK_TOP, right?  Or does STACK_TOP have some weird semantics on some
architectures that I'm not aware of?

The only other thing is how we are using ~0UL as the limit for the
kernel, and for all practical purposes that ought to be fine too.

  reply	other threads:[~2012-05-23 18:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 16:50 Arch maintainers Ahoy! (was Re: x86: faster strncpy_from_user()) Linus Torvalds
2012-05-23  5:46 ` Arch maintainers Ahoy! David Miller
2012-05-23  8:02   ` Geert Uytterhoeven
2012-05-23  9:40     ` James Bottomley
2012-05-23 15:15       ` Linus Torvalds
2012-05-23 17:21         ` David Miller
2012-05-23 17:32           ` Linus Torvalds
2012-05-23 18:16             ` David Miller
2012-05-23 18:27               ` Linus Torvalds
2012-05-23 18:35                 ` David Miller [this message]
2012-05-23 18:44                   ` Linus Torvalds
2012-05-23 18:46                   ` Linus Torvalds
2012-05-23 20:36                     ` David Miller
2012-05-23 21:01                       ` Linus Torvalds
2012-05-24  2:11                         ` David Miller
2012-05-24  5:25                           ` Paul Mackerras
2012-05-24  5:56                             ` David Miller
2012-05-24  9:40               ` David Howells
2012-05-24 15:53                 ` Linus Torvalds
2012-06-13 11:08                   ` Michael Cree
2012-06-13 14:51                     ` Linus Torvalds
2012-05-24 16:45                 ` David Howells
2012-05-24 16:56                   ` Linus Torvalds
2012-05-24 17:16                   ` David Howells
2012-05-23 17:19       ` David Miller

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=20120523.143543.366370918467441501.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).