[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK1hOcO0f7h3RfSrMgL5ph_MKN19bt6ojYTag2x-TtCsnozrOA@mail.gmail.com>
Date: Mon, 15 Aug 2011 15:44:10 +0200
From: Denys Vlasenko <vda.linux@...glemail.com>
To: Borislav Petkov <bp@...en8.de>,
Denys Vlasenko <vda.linux@...glemail.com>,
Ingo Molnar <mingo@...e.hu>,
melwyn lobo <linux.melwyn@...il.com>,
linux-kernel@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
borislav.petkov@....com
Subject: Re: x86 memcpy performance
On Sun, Aug 14, 2011 at 2:40 PM, Borislav Petkov <bp@...en8.de> wrote:
>> > + if (__len >= 512) \
>> > + __ret = __sse_memcpy((dst), (src), __len); \
>> > + else \
>> > + __ret = __memcpy((dst), (src), __len); \
>> > + __ret; \
>> > +})
>>
>> Please, no. Do not inline every memcpy invocation.
>> This is pure bloat (comsidering how many memcpy calls there are)
>> and it doesn't even win anything in speed, since there will be
>> a fucntion call either way.
>> Put the __len >= 512 check inside your memcpy instead.
>
> In the __len < 512 case, this would actually cause two function calls,
> actually: once the __sse_memcpy and then the __memcpy one.
You didn't notice the "else".
>> You may do the check if you know that __len is constant:
>> if (__builtin_constant_p(__len) && __len >= 512) ...
>> because in this case gcc will evaluate it at compile-time.
>
> That could justify the bloat at least partially.
There will be no bloat in this case.
--
vda
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists