From: Vitaly Mayatskikh <v.mayatskih@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Vitaly Mayatskikh <v.mayatskih@gmail.com>,
linux-kernel@vger.kernel.org, Andi Kleen <andi@firstfloor.org>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] x86: Optimize tail handling for copy_user
Date: Tue, 29 Jul 2008 17:24:09 +0200 [thread overview]
Message-ID: <m3vdyok92e.fsf@gravicappa.englab.brq.redhat.com> (raw)
In-Reply-To: <alpine.LFD.1.10.0807280846320.3486@nehalem.linux-foundation.org> (Linus Torvalds's message of "Mon, 28 Jul 2008 08:48:41 -0700 (PDT)")
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Mon, 28 Jul 2008, Vitaly Mayatskikh wrote:
>>
>> Reduce protection faults count in copy_user_handle_tail routine by
>> limiting clear length to the end of page as was suggested by Linus.
>
> No, you did it wrong.
>
> The page _clearing_ has to be to the end of the copy. Yes, in practice, I
> don't think the kernel actually very often does "copy_from_user()" calls
> that are page crossers in the kernel, but they do happen.
>
> It's the _copy_ part that needn't cross pages, because we know that
> something faulted, and we _know_ that it wasn't the clearing.
>
> Really: the clearing should be just a "memset()" with no limitations. It
> can never fault without it being a serious bug, and then we should not fix
> it up, but we should oops!
Right. I will take your code discussed previously. The only question is:
what will be a good place for *_IS_USERSPACE and CLEAR_REMAINDER flags
definitions and assembly macro ALIGN_DESTINATION (common for
copy_user_64.S and copy_user_nocache_64.S)? I have a new file
include/asm-x86/copy_user.h at the moment, but not sure if you will
think it's ok to put that stuff here:
include/asm-x86/copy_user.h:
#ifndef _COPY_USER_H
#define _COPY_USER_H
/* Flags for copy_user_handle_tail */
#define CLEAR_REMAINDER 1
#define DEST_IS_USERSPACE 2
#define SOURCE_IS_USERSPACE 4
/* Align destination */
#define FIX_ALIGNMENT 1
#define BYTES_LEFT_IN_PAGE(ptr) \
(unsigned long)((PAGE_MASK & ((long)(ptr) + PAGE_SIZE)) - (long)(ptr))
#ifdef __ASSEMBLY__
.macro ALIGN_DESTINATION
...
#endif /* FIX_ALIGNMENT */
.endm
#endif /* __ASSEMBLY__ */
#endif /* _COPY_USER_H */
--
wbr, Vitaly
next prev parent reply other threads:[~2008-07-29 15:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 14:10 Vitaly Mayatskikh
2008-07-28 15:48 ` Linus Torvalds
2008-07-29 15:24 ` Vitaly Mayatskikh [this message]
2008-07-30 12:02 ` Vitaly Mayatskikh
2008-07-30 17:29 ` Linus Torvalds
2008-07-31 14:27 ` Vitaly Mayatskikh
2008-08-01 20:10 ` Linus Torvalds
2008-08-01 22:04 ` Vitaly Mayatskikh
2008-08-01 22:30 ` Linus Torvalds
2008-08-01 22:53 ` Vitaly Mayatskikh
2008-07-30 12:07 ` Vitaly Mayatskikh
2008-07-30 12:13 ` Vitaly Mayatskikh
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=m3vdyok92e.fsf@gravicappa.englab.brq.redhat.com \
--to=v.mayatskih@gmail.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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
Powered by JetHome