Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1672909
| Path | csiph.com!news.freedyn.net!open-news-network.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Linus Torvalds <torvalds@linux-foundation.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] x86/uaccess: use unrolled string copy for short strings |
| Date | Thu, 22 Jun 2017 19:40:02 +0200 |
| Message-ID | <tVefg-7PJ-9@gated-at.bofh.it> (permalink) |
| References | <tULPY-5nY-1@gated-at.bofh.it> |
| X-Original-To | Paolo Abeni <pabeni@redhat.com> |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=5fOqV/PziMYLPITo3y8XNZOp3NuqgdGPOYCW2LH7Oco=; b=nphfHG+5j8gCstjOdim8ujwDtLdH6930DJAl/c1bBeaSnYKizm1A6f4YYUroHFXx+v KQ6g+S0W44/AH+Z1EbPwEXfcPTW9dE1y09Cla/cRESfT9NJNYFixDjUgb7as31252uYb Y5hAnI2durYHdgksZ8gQFjmikQpzncR2saOycvXjctZq0p0jZWwJySMW7ER9ofdzVRbj oueSAMel3bCUR9uiWXKHpsHq0b/AXuVJRbKLB30zve50E9Atqw4aycscBs8GXwRb+HuT eXZTDvJsadEVz7OvF/R8S5DSWj5iWfuPC0s4rufW51mWZUBbpzInFOaPQ5Vwg3JBuHdn ZvsA== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=5fOqV/PziMYLPITo3y8XNZOp3NuqgdGPOYCW2LH7Oco=; b=h9RG082/Im1zEbsDjB2mwVHmiP3EG/Xv0339eJYPDR4RXvfqhOZre5QjuOq4PilD0O wCd90Nl2IY2FXOKbbkiBA9H+R7Ag0y4/xSdukfR/tYBal8S/BgzrllgPG8PURRksHM9p L2uErhFhAFoHCD1Kx+T/G+b/A37gWYsyJTSLE9IhCeOZsgcZpi8nNAPB9+lj/tvc57jw e4A7vZYcztnJhZu5/lX+AYKyEZ14rZCAW9kYKjWn/FEEkPCTx+wIalzlSS/C6Z63Q+KF E6N4DYcISIP1/d08KZMoWyzC7IRJqSyljEPEMddue8bSPDM3GhrJiMAAP4s6GknXwzW9 qgOg== |
| X-Gm-Message-State | AKS2vOyo/np0oswx2VymmUGjUSP/8n8iixkAzR7jGzMNTPgHOzOJI4Rn 5acEmiAhBUCiPhmVcanteazH2OLQuA== |
| X-Received | by 10.36.108.131 with SMTP id w125mr3125772itb.91.1498152607131; Thu, 22 Jun 2017 10:30:07 -0700 (PDT) |
| MIME-Version | 1.0 |
| X-Google-Sender-Auth | S4xm7u7rObXklNlD70KFLnz5NiY |
| Content-Type | text/plain; charset="UTF-8" |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 31 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | "the arch/x86 maintainers" <x86@kernel.org>, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>, Al Viro <viro@zeniv.linux.org.uk>, Kees Cook <keescook@chromium.org>, Hannes Frederic Sowa <hannes@stressinduktion.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> |
| X-Original-Date | Thu, 22 Jun 2017 10:30:06 -0700 |
| X-Original-Message-ID | <CA+55aFzLF6dvHS_N9-M-=6J83HZ3rp+JJ68NSpKc+D_yBA=o_w@mail.gmail.com> |
| X-Original-References | <63d913f28bc64bd4ea66a39a532f0b59ee015382.1498039056.git.pabeni@redhat.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1672909 |
Show key headers only | View raw
On Wed, Jun 21, 2017 at 4:09 AM, Paolo Abeni <pabeni@redhat.com> wrote:
>
> + if (len <= 64)
> + return copy_user_generic_unrolled(to, from, len);
> +
> /*
> * If CPU has ERMS feature, use copy_user_enhanced_fast_string.
> * Otherwise, if CPU has rep_good feature, use copy_user_generic_string.
NAK. Please do *not* do this. It puts the check in completely the
wrong place for several reasons:
(a) it puts it in the inlined caller case (which could be ok for
constant sizes, but not in general)
(b) it uses the copy_user_generic_unrolled() function that will then
just test the size *AGAIN* against small cases.
so it's both bigger than necessary, and stupid.
So if you want to do this optimization, I'd argue that you should just
do it inside the copy_user_enhanced_fast_string() function itself, the
same way we already handle the really small case specially in
copy_user_generic_string().
And do *not* use the unrolled code, which isn't used for small copies
anyway - rewrite the "copy_user_generic_unrolled" function in that
same asm file to have the non-unrolled cases (label "17" and forward)
accessible, so that you don't bother re-testing the size.
Linus
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] x86/uaccess: use unrolled string copy for short strings Paolo Abeni <pabeni@redhat.com> - 2017-06-21 13:20 +0200
Re: [PATCH] x86/uaccess: use unrolled string copy for short strings Kees Cook <keescook@chromium.org> - 2017-06-21 19:40 +0200
Re: [PATCH] x86/uaccess: use unrolled string copy for short strings Alan Cox <gnomes@lxorguk.ukuu.org.uk> - 2017-06-22 17:00 +0200
Re: [PATCH] x86/uaccess: use unrolled string copy for short strings Ingo Molnar <mingo@kernel.org> - 2017-06-22 10:50 +0200
Re: [PATCH] x86/uaccess: use unrolled string copy for short strings Paolo Abeni <pabeni@redhat.com> - 2017-06-22 19:10 +0200
Re: [PATCH] x86/uaccess: use unrolled string copy for short strings Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-22 19:40 +0200
Re: [PATCH] x86/uaccess: use unrolled string copy for short strings Paolo Abeni <pabeni@redhat.com> - 2017-06-22 20:00 +0200
[PATCH] x86/uaccess: optimize copy_user_enhanced_fast_string for short string Paolo Abeni <pabeni@redhat.com> - 2017-06-29 16:00 +0200
Re: [PATCH] x86/uaccess: optimize copy_user_enhanced_fast_string for short string Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-29 23:50 +0200
[tip:x86/asm] x86/uaccess: Optimize copy_user_enhanced_fast_string() for short strings tip-bot for Paolo Abeni <tipbot@zytor.com> - 2017-06-30 15:20 +0200
csiph-web