Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-30 Thread Dmitry Vyukov
On Thu, Jan 25, 2018 at 8:13 PM, Andrey Ryabinin wrote: > On 01/25/2018 08:55 PM, Linus Torvalds wrote: >> On Thu, Jan 25, 2018 at 12:32 AM, Dmitry Vyukov wrote: >>> On Wed, Jan 24, 2018 at 6:52 PM, Linus Torvalds >>> wrote: So I'd *much* rather have some way to tell KASAN that word-at

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-25 Thread Andrey Ryabinin
On 01/25/2018 08:55 PM, Linus Torvalds wrote: > On Thu, Jan 25, 2018 at 12:32 AM, Dmitry Vyukov wrote: >> On Wed, Jan 24, 2018 at 6:52 PM, Linus Torvalds >> wrote: >>> >>> So I'd *much* rather have some way to tell KASAN that word-at-a-time >>> is going on. Because that approach definitely makes

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-25 Thread Linus Torvalds
On Thu, Jan 25, 2018 at 12:32 AM, Dmitry Vyukov wrote: > On Wed, Jan 24, 2018 at 6:52 PM, Linus Torvalds > wrote: >> >> So I'd *much* rather have some way to tell KASAN that word-at-a-time >> is going on. Because that approach definitely makes a difference in >> other places. > > The other option

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-25 Thread Dmitry Vyukov
On Thu, Jan 25, 2018 at 9:42 AM, David Laight wrote: > From: Dmitry Vyukov [mailto:dvyu...@google.com] >> Sent: 25 January 2018 08:33 >> >> On Wed, Jan 24, 2018 at 6:52 PM, Linus Torvalds >> wrote: >> > On Wed, Jan 24, 2018 at 12:54 AM, Rasmus Villemoes >> > wrote: >> >> >> >> I see something si

RE: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-25 Thread David Laight
From: Dmitry Vyukov [mailto:dvyu...@google.com] > Sent: 25 January 2018 08:33 > > On Wed, Jan 24, 2018 at 6:52 PM, Linus Torvalds > wrote: > > On Wed, Jan 24, 2018 at 12:54 AM, Rasmus Villemoes > > wrote: > >> > >> I see something similar, but at the 30->31 transition, and the > >> branch-misses

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-25 Thread Dmitry Vyukov
On Wed, Jan 24, 2018 at 6:52 PM, Linus Torvalds wrote: > On Wed, Jan 24, 2018 at 12:54 AM, Rasmus Villemoes > wrote: >> >> I see something similar, but at the 30->31 transition, and the >> branch-misses remain at 1-3% for higher values, until 42 where it drops >> back to 0%. Anyway, I highly doub

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-24 Thread Linus Torvalds
On Wed, Jan 24, 2018 at 12:54 AM, Rasmus Villemoes wrote: > > I see something similar, but at the 30->31 transition, and the > branch-misses remain at 1-3% for higher values, until 42 where it drops > back to 0%. Anyway, I highly doubt we do a lot of string copies of > strings longer then 32. So

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-24 Thread Andy Shevchenko
On Tue, Jan 9, 2018 at 6:37 PM, Andrey Ryabinin wrote: > strscpy() performs the word-at-a-time optimistic reads. So it may > may access the memory past the end of the object, which is perfectly fine > since strscpy() doesn't use that (past-the-end) data and makes sure the > optimistic read won't c

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-24 Thread Rasmus Villemoes
On 2018-01-09 17:47, Andrey Ryabinin wrote: > Attached user space program I used to see the difference. > Usage: > gcc -02 -o strscpy strscpy_test.c > ./strscpy {b|w} src_str_len count > > src_str_len - length of source string in between 1-4096 > count - how many strscpy() to execute.

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-24 Thread Rasmus Villemoes
On 2018-01-09 17:37, Andrey Ryabinin wrote: > strscpy() performs the word-at-a-time optimistic reads. So it may > may access the memory past the end of the object, which is perfectly fine > since strscpy() doesn't use that (past-the-end) data and makes sure the > optimistic read won't cross a page

Re: [PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-09 Thread Andrey Ryabinin
Attached user space program I used to see the difference. Usage: gcc -02 -o strscpy strscpy_test.c ./strscpy {b|w} src_str_len count src_str_len - length of source string in between 1-4096 count - how many strscpy() to execute. Also I've noticed something strange. I'm not sure w

[PATCH] lib/strscpy: remove word-at-a-time optimization.

2018-01-09 Thread Andrey Ryabinin
strscpy() performs the word-at-a-time optimistic reads. So it may may access the memory past the end of the object, which is perfectly fine since strscpy() doesn't use that (past-the-end) data and makes sure the optimistic read won't cross a page boundary. But KASAN doesn't know anything about tha