* [to-be-updated] lib-string-optimized-memmove.patch removed from -mm tree
@ 2021-09-09 20:56 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2021-09-09 20:56 UTC (permalink / raw)
To: David.Laight, drew, guoren, hch, kernel, mcroce, mick,
mm-commits, ndesaulniers, palmer
The patch titled
Subject: lib/string: optimized memmove
has been removed from the -mm tree. Its filename was
lib-string-optimized-memmove.patch
This patch was dropped because an updated version will be merged
------------------------------------------------------
From: Matteo Croce <mcroce@microsoft.com>
Subject: lib/string: optimized memmove
When the destination buffer is before the source one, or when the buffers
doesn't overlap, it's safe to use memcpy() instead, which is optimized to
use a bigger data size possible.
This "optimization" only covers a common case. In future, proper code
which does the same thing as memcpy() does but backwards can be done.
Link: https://lkml.kernel.org/r/20210702123153.14093-3-mcroce@linux.microsoft.com
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: David Laight <David.Laight@aculab.com>
Cc: Drew Fustini <drew@beagleboard.org>
Cc: Emil Renner Berthing <kernel@esmil.dk>
Cc: Guo Ren <guoren@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Nick Kossifidis <mick@ics.forth.gr>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/string.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
--- a/lib/string.c~lib-string-optimized-memmove
+++ a/lib/string.c
@@ -975,19 +975,13 @@ EXPORT_SYMBOL(memcpy);
*/
void *memmove(void *dest, const void *src, size_t count)
{
- char *tmp;
- const char *s;
+ if (dest < src || src + count <= dest)
+ return memcpy(dest, src, count);
+
+ if (dest > src) {
+ const char *s = src + count;
+ char *tmp = dest + count;
- if (dest <= src) {
- tmp = dest;
- s = src;
- while (count--)
- *tmp++ = *s++;
- } else {
- tmp = dest;
- tmp += count;
- s = src;
- s += count;
while (count--)
*--tmp = *--s;
}
_
Patches currently in -mm which might be from mcroce@microsoft.com are
lib-string-optimized-memset.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-09 20:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09 20:56 [to-be-updated] lib-string-optimized-memmove.patch removed from -mm tree akpm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).