linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@sifive.com>
To: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	nickhu@andestech.com, alankao@andestech.com,
	aou@eecs.berkeley.edu, green.hu@gmail.com, deanbo422@gmail.com,
	tglx@linutronix.de, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org, aryabinin@virtuozzo.com,
	glider@google.com, dvyukov@google.com,
	Anup Patel <Anup.Patel@wdc.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	alexios.zavras@intel.com, Atish Patra <Atish.Patra@wdc.com>,
	zong@andestech.com, kasan-dev@googlegroups.com
Subject: Re: [PATCH 1/2] riscv: Add memmove string operation.
Date: Wed, 14 Aug 2019 11:33:13 -0700 (PDT)	[thread overview]
Message-ID: <mhng-22db5681-9fed-4bf6-83fe-180b3599c654@palmer-si-x1c4> (raw)
In-Reply-To: <alpine.DEB.2.21.9999.1908131921180.19217@viisi.sifive.com>

On Tue, 13 Aug 2019 19:22:15 PDT (-0700), Paul Walmsley wrote:
> On Tue, 13 Aug 2019, Palmer Dabbelt wrote:
>
>> On Mon, 12 Aug 2019 08:04:46 PDT (-0700), Christoph Hellwig wrote:
>> > On Wed, Aug 07, 2019 at 03:19:14PM +0800, Nick Hu wrote:
>> > > There are some features which need this string operation for compilation,
>> > > like KASAN. So the purpose of this porting is for the features like KASAN
>> > > which cannot be compiled without it.
>> > >
>> > > KASAN's string operations would replace the original string operations and
>> > > call for the architecture defined string operations. Since we don't have
>> > > this in current kernel, this patch provides the implementation.
>> > >
>> > > This porting refers to the 'arch/nds32/lib/memmove.S'.
>> >
>> > This looks sensible to me, although my stringop asm is rather rusty,
>> > so just an ack and not a real review-by:
>> >
>> > Acked-by: Christoph Hellwig <hch@lst.de>
>>
>> FWIW, we just write this in C everywhere else and rely on the compiler to
>> unroll the loops.  I always prefer C to assembly when possible, so I'd prefer
>> if we just adopt the string code from newlib.  We have a RISC-V-specific
>> memcpy in there, but just use the generic memmove.
>>
>> Maybe the best bet here would be to adopt the newlib memcpy/memmove as generic
>> Linux functions?  They're both in C so they should be fine, and they both look
>> faster than what's in lib/string.c.  Then everyone would benefit and we don't
>> need this tricky RISC-V assembly.  Also, from the look of it the newlib code
>> is faster because the inner loop is unrolled.
>
> There's a generic memmove implementation in the kernel already:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/string.h#n362

That ends up at __builtin_memcpy(), which ends up looking for memcpy() for 
large copies, which is in lib/string.c.  The code in there is just byte at a 
time memcpy()/memmove(), which is way slower than the newlib stuff.

>
> Nick, could you tell us more about why the generic memmove() isn't
> suitable?
>
>
> - Paul

  parent reply	other threads:[~2019-08-14 18:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-07  7:19 [PATCH 0/2] KASAN support for RISC-V Nick Hu
2019-08-07  7:19 ` [PATCH 1/2] riscv: Add memmove string operation Nick Hu
2019-08-12 15:04   ` Christoph Hellwig
2019-08-13 23:50     ` Palmer Dabbelt
2019-08-14  2:22       ` Paul Walmsley
2019-08-14  3:27         ` Nick Hu
     [not found]           ` <alpine.DEB.2.21.9999.1908141002500.18249@viisi.sifive.com>
2019-08-15  3:12             ` Nick Hu
     [not found]               ` <alpine.DEB.2.21.9999.1908151124450.18249@viisi.sifive.com>
2019-08-19  6:29                 ` Nick Hu
2019-08-14 18:33         ` Palmer Dabbelt [this message]
2019-08-22 15:59   ` Andrey Ryabinin
2019-08-27  9:07     ` Nick Hu
2019-08-27  9:33       ` Andrey Ryabinin
2019-08-28  3:06         ` Nick Hu
2019-08-07  7:19 ` [PATCH 2/2] riscv: Add KASAN support Nick Hu
2019-08-12 15:10   ` Christoph Hellwig
2019-08-14  7:44     ` Nick Hu
2019-08-22 17:08       ` Andrey Ryabinin
2019-09-03 15:08       ` Daniel Axtens
2019-09-04  2:24         ` Nick Hu

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=mhng-22db5681-9fed-4bf6-83fe-180b3599c654@palmer-si-x1c4 \
    --to=palmer@sifive.com \
    --cc=Anup.Patel@wdc.com \
    --cc=Atish.Patra@wdc.com \
    --cc=alankao@andestech.com \
    --cc=alexios.zavras@intel.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=aryabinin@virtuozzo.com \
    --cc=deanbo422@gmail.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=green.hu@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=nickhu@andestech.com \
    --cc=paul.walmsley@sifive.com \
    --cc=tglx@linutronix.de \
    --cc=zong@andestech.com \
    /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;
as well as URLs for NNTP newsgroup(s).