From: Shinya Kuribayashi <shinya.kuribayashi@necel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH] mips: Bring over optimized memset() routine from Linux.
Date: Tue, 10 Jun 2008 19:51:09 +0900 [thread overview]
Message-ID: <484E5C9D.8000209@necel.com> (raw)
In-Reply-To: <20080604194815.A02FD6E7BD@mcmullan-linux.hq.netapp.com>
Hi Jason,
Jason McMullan wrote:
> This commit pulls over the memset() MIPS routine from Linux 2.6.26,
> which provides a 10x to 20x speedup over the generic byte-at-a-time
> routine. This is especially useful on platforms with manual ECC
> scrubbing, that require all of memory to be written at least once
> after a power cycle.
> ---
> include/asm-mips/string.h | 2 +-
> lib_mips/Makefile | 2 +-
> lib_mips/memset.S | 174 +++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 176 insertions(+), 2 deletions(-)
> create mode 100644 lib_mips/memset.S
IIRC, Linux's memset relies on AdEL/AdES exceptions. We have Status.EXL
enabled, but don't have proper exception handlers, yet. So my question
is does this code always works expectedly, or works with some alignment
restriction?
And some nitpickings. See below.
> diff --git a/lib_mips/memset.S b/lib_mips/memset.S
> new file mode 100644
> index 0000000..f1c07d7
> --- /dev/null
> +++ b/lib_mips/memset.S
> @@ -0,0 +1,174 @@
> +/*
> + * This file is subject to the terms and conditions of the GNU General Public
> + * License. See the file "COPYING" in the main directory of this archive
> + * for more details.
> + *
> + * Copyright (C) 1998, 1999, 2000 by Ralf Baechle
> + * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
> + * Copyright (C) 2007 Maciej W. Rozycki
> + */
> +#include <asm/asm.h>
> +//#include <asm/asm-offsets.h>
Please remove unused #include. Even '#if 0'-ing is not allowed in
U-Boot policy.
> +#include <asm/regdef.h>
> +
> +#if LONGSIZE == 4
> +#define LONG_S_L swl
> +#define LONG_S_R swr
> +#else
> +#define LONG_S_L sdl
> +#define LONG_S_R sdr
> +#endif
> +
> +#define EX(insn,reg,addr,handler) \
> +9: insn reg, addr; \
> + .section __ex_table,"a"; \
> + PTR 9b, handler; \
> + .previous
> +
> + .macro f_fill64 dst, offset, val, fixup
> + EX(LONG_S, \val, (\offset + 0 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 1 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 2 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 3 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 4 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 5 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 6 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 7 * LONGSIZE)(\dst), \fixup)
> +#if LONGSIZE == 4
> + EX(LONG_S, \val, (\offset + 8 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 9 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 10 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 11 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 12 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 13 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 14 * LONGSIZE)(\dst), \fixup)
> + EX(LONG_S, \val, (\offset + 15 * LONGSIZE)(\dst), \fixup)
> +#endif
> + .endm
> +
> +/*
> + * memset(void *s, int c, size_t n)
> + *
> + * a0: start of area to clear
> + * a1: char to fill with
> + * a2: size of area to clear
> + */
> + .set noreorder
> + .align 5
> +LEAF(memset)
> + beqz a1, 1f
> + move v0, a0 /* result */
^
> + andi a1, 0xff /* spread fillword */
> + LONG_SLL t1, a1, 8
> + or a1, t1
> + LONG_SLL t1, a1, 16
> +#if LONGSIZE == 8
> + or a1, t1
> + LONG_SLL t1, a1, 32
> +#endif
> + or a1, t1
> +1:
> +
> +FEXPORT(__bzero)
> + sltiu t0, a2, LONGSIZE /* very small region? */
> + bnez t0, .Lsmall_memset
> + andi t0, a0, LONGMASK /* aligned? */
^
[further part snipped]
Please fix wrong indentations with proper tabs. I know this is exactly
the same as Linux's memset, but we prefer to fix it correctly in U-Boot.
[ I used to do like you did, but changed my mind. Now I think this is
better practice. Incoherent indentations with Linux is not a big deal
IMO. Just diff -w option blows them away. ]
Thanks in advance,
--
Shinya Kuribayashi
NEC Electronics
next prev parent reply other threads:[~2008-06-10 10:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-04 19:44 [U-Boot-Users] [PATCH] mips: Bring over optimized memset() routine from Linux Jason McMullan
2008-06-10 10:51 ` Shinya Kuribayashi [this message]
2008-06-13 7:04 ` Shinya Kuribayashi
2008-06-13 7:13 ` Wolfgang Denk
2008-07-05 22:32 ` Wolfgang Denk
2008-07-07 13:50 ` [U-Boot-Users] [PATCH] mips: Bring over optimized memset()routine " McMullan, Jason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=484E5C9D.8000209@necel.com \
--to=shinya.kuribayashi@necel.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox