Skip to contentSkip to conversation

csky: Improve abiv1 mem ops performance with glibc codes

PATCH In review [email protected] 2 participants 4 messages Jun 29, 2019 – Jul 1, 2019

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 csky: Improve abiv1 mem ops performance with glibc codes

From: Guo Ren <[email protected]>

These codes are copied from glibc/string directory, they are the generic implementation for string operations. We may further optimize them with assembly code in the future.

In fact these code isn't tested enough for kernel, but we've tested them on glibc and it seems good. We just trust them :)

Cc Arnd Bergmann <[email protected]>
---
 arch/csky/abiv1/Makefile         |   6 +
 arch/csky/abiv1/inc/abi/string.h |  15 ++
 arch/csky/abiv1/memcmp.c         | 310 ++++++++++++++++++++++++++++++
 arch/csky/abiv1/memcopy.h        | 179 ++++++++++++++++++
 arch/csky/abiv1/memmove.c        |  93 +++++++++
 arch/csky/abiv1/memset.c         |  71 +++++++
 arch/csky/abiv1/strcpy.c         |  17 ++
 arch/csky/abiv1/strksyms.c       |   5 +
 arch/csky/abiv1/strlen.c         |  89 +++++++++
 arch/csky/abiv1/wordcopy.c       | 397 +++++++++++++++++++++++++++++++++++++++
 10 files changed, 1182 insertions(+)
 create mode 100644 arch/csky/abiv1/memcmp.c
 create mode 100644 arch/csky/abiv1/memcopy.h
 create mode 100644 arch/csky/abiv1/memmove.c
 create mode 100644 arch/csky/abiv1/memset.c
 create mode 100644 arch/csky/abiv1/strcpy.c
 create mode 100644 arch/csky/abiv1/strlen.c
 create mode 100644 arch/csky/abiv1/wordcopy.c
arch/csky/abiv1/Makefile +6 -0
index b8a7c2a..60b60fe 100644
@@ -5,3 +5,9 @@ obj-y					+= cacheflush.o
 obj-y					+= mmap.o
 obj-y					+= memcpy.o
 obj-y					+= strksyms.o
+obj-y					+= memcmp.o
+obj-y					+= memset.o
+obj-y					+= memmove.o
+obj-y					+= strcpy.o
+obj-y					+= strlen.o
+obj-y					+= wordcopy.o
arch/csky/abiv1/inc/abi/string.h +15 -0
index 0cd4338..a62d7a0 100644
@@ -4,7 +4,22 @@
 #ifndef __ABI_CSKY_STRING_H
 #define __ABI_CSKY_STRING_H
 
+#define __HAVE_ARCH_MEMCMP
+extern int memcmp(const void *, const void *, __kernel_size_t);
+
 #define __HAVE_ARCH_MEMCPY
 extern void *memcpy(void *, const void *, __kernel_size_t);
 
+#define __HAVE_ARCH_MEMMOVE
+extern void *memmove(void *, const void *, __kernel_size_t);
+
+#define __HAVE_ARCH_MEMSET
+extern void *memset(void *, int,  __kernel_size_t);
+
+#define __HAVE_ARCH_STRCPY
+extern char *strcpy(char *, const char *);
+
+#define __HAVE_ARCH_STRLEN
+extern __kernel_size_t strlen(const char *);
+
 #endif /* __ABI_CSKY_STRING_H */
arch/csky/abiv1/memcmp.c new file +310 -0

310 lines not on this page · raw message

arch/csky/abiv1/memcopy.h new file +179 -0

179 lines not on this page · raw message

arch/csky/abiv1/memmove.c new file +93 -0

93 lines not on this page · raw message

arch/csky/abiv1/memset.c new file +71 -0

71 lines not on this page · raw message

arch/csky/abiv1/strcpy.c new file +17 -0
new file mode 100644
index 0000000..50ae10c
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 1991-2018 Free Software Foundation, Inc.
+
+#include "memcopy.h"
+
+#undef strcpy
+
+#ifndef STRCPY
+# define STRCPY strcpy
+#endif
+
+/* Copy SRC to DEST.  */
+char *
+STRCPY (char *dest, const char *src)
+{
+  return memcpy (dest, src, strlen (src) + 1);
+}
arch/csky/abiv1/strksyms.c +5 -0
index c7ccbb2..9c8fd9f 100644
@@ -4,3 +4,8 @@
 #include <linux/module.h>
 
 EXPORT_SYMBOL(memcpy);
+EXPORT_SYMBOL(memcmp);
+EXPORT_SYMBOL(memset);
+EXPORT_SYMBOL(memmove);
+EXPORT_SYMBOL(strcpy);
+EXPORT_SYMBOL(strlen);
arch/csky/abiv1/strlen.c new file +89 -0

89 lines not on this page · raw message

arch/csky/abiv1/wordcopy.c new file +397 -0

397 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 9 lines · On Sat, Jun 29, 2019 at 7:36 AM <[email protected]> wrote:

From: Guo Ren <[email protected]>

These codes are copied from glibc/string directory, they are the generic implementation for string operations. We may further optimize them with assembly code in the future.

In fact these code isn't tested enough for kernel, but we've tested them on glibc and it seems good. We just trust them :)

Are these files from the architecture independent portion of glibc or are they csky specific? If they are architecture independent, we might want to see if they make sense for other architectures as well, and add them to lib/ rather than arch/csky/lib/

Should the SPDX identifier list the original LGPL-2.1 license instead of GPL-2.0?

Arnd

author maintainer
#2 lore raw

Hi Arnd,

Quoted 9 lines · Arnd Bergmann
Quoted 7 lines · On Sat, Jun 29, 2019 at 7:36 AM <[email protected]> wrote:

From: Guo Ren <[email protected]>

These codes are copied from glibc/string directory, they are the generic implementation for string operations. We may further optimize them with assembly code in the future.

Quoted 7 lines
Quoted 2 lines

In fact these code isn't tested enough for kernel, but we've tested them on glibc and it seems good. We just trust them :)

Are these files from the architecture independent portion of glibc or are they csky specific? If they are architecture independent, we might want to see if they make sense for other architectures as well, and add them to lib/ rather than arch/csky/lib/

They are just copied from glibc-2.28/string/*.c and they are generic. OK, I'll try to add them to lib/.

Quoted 3 lines

Should the SPDX identifier list the original LGPL-2.1 license instead of GPL-2.0?

Yes, I removed full Licenses' description:
The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version

I'll change it to:
// SPDX-License-Identifier: LGPL-2.1

Signature · 4 lines
Best Regards
 Guo Ren

ML: https://lore.kernel.org/linux-csky/
maintainer
#3 lore raw
Quoted 13 lines · Guo Ren
Quoted 12 lines · Arnd Bergmann
Quoted 9 lines · On Sat, Jun 29, 2019 at 7:36 AM <[email protected]> wrote:

From: Guo Ren <[email protected]>

These codes are copied from glibc/string directory, they are the generic implementation for string operations. We may further optimize them with assembly code in the future.

In fact these code isn't tested enough for kernel, but we've tested them on glibc and it seems good. We just trust them :)

Quoted 6 lines
Quoted 4 lines

Are these files from the architecture independent portion of glibc or are they csky specific? If they are architecture independent, we might want to see if they make sense for other architectures as well, and add them to lib/ rather than arch/csky/lib/

They are just copied from glibc-2.28/string/*.c and they are generic. OK, I'll try to add them to lib/.

Ok. Note that lib/string.c contains very basic versions of these already, so please see which of the functions you have actually make a difference in practice over those (if you haven't done that already).

Otherwise you can probably follow the example of the libgcc functions in lib/ashldi3.c etc: add a Kconfig symbol like CONFIG_GENERIC_LIB_ASHLDI3 for each function you had, put the glibc version into a new file, and allow architectures to select them individually, which in turn should replace the version from lib/string.c.

Arnd