From: "H. Peter Anvin" <hpa@zytor.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Nick Piggin <npiggin@gmail.com>, Jana Saout <jana@saout.de>,
Joel Becker <jlbec@evilplan.org>,
linux-kernel@vger.kernel.org
Subject: Re: Oops with DCACHE_WORD_ACCESS and ocfs2, autofs4
Date: Thu, 03 May 2012 11:13:45 -0700 [thread overview]
Message-ID: <4FA2CAD9.6010808@zytor.com> (raw)
In-Reply-To: <CA+55aFxeBHSB6iBpP55kV2bLQGg8ZC9Ve5mvCmZN0ARH9dVwKg@mail.gmail.com>
On 05/03/2012 10:30 AM, Linus Torvalds wrote:
> On Thu, May 3, 2012 at 9:15 AM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
>>
>> So I guess I need to do the exception handling that I was hoping I
>> wouldn't have to. Give me a jiffy.
>
> Ok, that took longer than a jiffy, the asm was just nasty to get right
> with all the proper suffixes for 32-bit vs 64-bit, and the fact that
> gas apparently really needs %cl for the shift count, and doesn't like
> %rcx. Silly assembler.
>
Yes, although it's a fixed register you can also just write as %%cl.
> Also, the asm would have been much simpler if I didn't care so much
> about the regular fast-path. I wanted the fast-path for the asm to be
> a single load, with no downside, and everything fixed up in the
> exception case.
>
> And it's close. It's a single load, and the only downside is that
> register '%rcx' is marked as used, because *if* the exception happens,
> we want to use %rcx do the alignment fixup.
>
> Peter, in particular, can you double (and triple-) check my asm, to
> see if I missed anything? It does that "lea" of the address into %rcx
> twice, because that way we don't need any other register temporaries.
Just from a cleanliness point of view, I don't think you need the
__WORDSUFFIX for any of these instructions (it is only required if it
would be ambiguous, but the register names should deal with it.)
> - fast-path single-instruction unaligned load (with gcc free to pick
> registers and addressing modes):
>
> movl (%edi,%edx),%eax
>
> - with the exception fixup code becoming:
>
> leal (%edi,%edx),%ecx
> andl $-4,%ecx
> movl (%ecx),%eax
> leal (%edi,%edx),%ecx
> andl $3,%ecx
> shll $3,%ecx
> shll %cl,%eax
> shrl %cl,%eax
> jmp 2b
I think you want to drop the shl instruction. You're loading what
should end up at the LSB end of the register into the MSB end of the
register, so shr is all you should need.
Let's say %edi+%edx points to 0xcccccffd with the values 66 77 88 99
starting at 0xcccccffc. If the next page is present and zero, you'd end
up with %eax = 0x00998877, and so you would expect the same.
lea (%edi,%edx),%ecx -> %ecx = 0xcccccffd
and $-4,%ecx -> %ecx = 0xcccccffc
mov (%ecx),%eax -> %eax = 0x99887766
lea (%edi,%edx),%ecx -> %ecx = 0xcccccffd
and $3,%ecx -> %ecx = 1
shl $3,%ecx -> %ecx = 8
shr %cl,%eax -> %eax = 0x00998877
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
next prev parent reply other threads:[~2012-05-03 18:14 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-30 12:27 Oops with DCACHE_WORD_ACCESS and ocfs2, autofs4 Jana Saout
2012-05-01 11:00 ` Joel Becker
2012-05-01 12:28 ` Jana Saout
2012-05-03 5:02 ` Nick Piggin
2012-05-03 5:57 ` Linus Torvalds
2012-05-03 5:57 ` Linus Torvalds
2012-05-03 6:23 ` Nick Piggin
2012-05-03 6:26 ` Nick Piggin
2012-05-03 6:38 ` H. Peter Anvin
2012-05-03 6:40 ` H. Peter Anvin
2012-05-03 6:54 ` David Miller
2012-05-03 6:57 ` H. Peter Anvin
2012-05-03 7:02 ` David Miller
2012-05-03 6:47 ` Al Viro
2012-05-03 16:15 ` Linus Torvalds
2012-05-03 17:30 ` Al Viro
2012-05-03 17:30 ` Linus Torvalds
2012-05-03 18:13 ` H. Peter Anvin [this message]
2012-05-03 18:23 ` Linus Torvalds
2012-05-03 18:27 ` H. Peter Anvin
2012-05-03 18:28 ` H. Peter Anvin
2012-05-03 18:48 ` David Miller
2012-05-03 21:23 ` H. Peter Anvin
2012-05-03 19:06 ` Linus Torvalds
2012-05-03 20:30 ` Jana Saout
2012-05-03 21:01 ` Linus Torvalds
2012-05-03 21:03 ` Jana Saout
2012-05-03 21:20 ` Linus Torvalds
2012-05-03 21:47 ` Jana Saout
2012-05-04 11:21 ` Jana Saout
2012-05-03 8:01 ` Jana Saout
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=4FA2CAD9.6010808@zytor.com \
--to=hpa@zytor.com \
--cc=jana@saout.de \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@gmail.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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