mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
9412b23450
The generic implementation of strlen() reads strings byte per byte. This patch implements strlen() in assembly based on a read of entire words, in the same spirit as what some other arches and glibc do. On a 8xx the time spent in strlen is reduced by 3/4 for long strings. strlen() selftest on an 8xx provides the following values: Before the patch (ie with the generic strlen() in lib/string.c): len 256 : time = 1.195055 len 016 : time = 0.083745 len 008 : time = 0.046828 len 004 : time = 0.028390 After the patch: len 256 : time = 0.272185 ==> 78% improvment len 016 : time = 0.040632 ==> 51% improvment len 008 : time = 0.033060 ==> 29% improvment len 004 : time = 0.029149 ==> 2% degradation On a 832x: Before the patch: len 256 : time = 0.236125 len 016 : time = 0.018136 len 008 : time = 0.011000 len 004 : time = 0.007229 After the patch: len 256 : time = 0.094950 ==> 60% improvment len 016 : time = 0.013357 ==> 26% improvment len 008 : time = 0.010586 ==> 4% improvment len 004 : time = 0.008784 Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
60 lines
1.8 KiB
C
60 lines
1.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_POWERPC_STRING_H
|
|
#define _ASM_POWERPC_STRING_H
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
#define __HAVE_ARCH_STRNCPY
|
|
#define __HAVE_ARCH_STRNCMP
|
|
#define __HAVE_ARCH_MEMSET
|
|
#define __HAVE_ARCH_MEMCPY
|
|
#define __HAVE_ARCH_MEMMOVE
|
|
#define __HAVE_ARCH_MEMCMP
|
|
#define __HAVE_ARCH_MEMCHR
|
|
#define __HAVE_ARCH_MEMSET16
|
|
#define __HAVE_ARCH_MEMCPY_FLUSHCACHE
|
|
|
|
extern char * strcpy(char *,const char *);
|
|
extern char * strncpy(char *,const char *, __kernel_size_t);
|
|
extern __kernel_size_t strlen(const char *);
|
|
extern int strcmp(const char *,const char *);
|
|
extern int strncmp(const char *, const char *, __kernel_size_t);
|
|
extern char * strcat(char *, const char *);
|
|
extern void * memset(void *,int,__kernel_size_t);
|
|
extern void * memcpy(void *,const void *,__kernel_size_t);
|
|
extern void * memmove(void *,const void *,__kernel_size_t);
|
|
extern int memcmp(const void *,const void *,__kernel_size_t);
|
|
extern void * memchr(const void *,int,__kernel_size_t);
|
|
extern void * memcpy_flushcache(void *,const void *,__kernel_size_t);
|
|
|
|
#ifdef CONFIG_PPC64
|
|
#define __HAVE_ARCH_MEMSET32
|
|
#define __HAVE_ARCH_MEMSET64
|
|
|
|
extern void *__memset16(uint16_t *, uint16_t v, __kernel_size_t);
|
|
extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
|
|
extern void *__memset64(uint64_t *, uint64_t v, __kernel_size_t);
|
|
|
|
static inline void *memset16(uint16_t *p, uint16_t v, __kernel_size_t n)
|
|
{
|
|
return __memset16(p, v, n * 2);
|
|
}
|
|
|
|
static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
|
|
{
|
|
return __memset32(p, v, n * 4);
|
|
}
|
|
|
|
static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
|
|
{
|
|
return __memset64(p, v, n * 8);
|
|
}
|
|
#else
|
|
#define __HAVE_ARCH_STRLEN
|
|
|
|
extern void *memset16(uint16_t *, uint16_t, __kernel_size_t);
|
|
#endif
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* _ASM_POWERPC_STRING_H */
|