public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Andrew Fish <afish@apple.com>
Cc: Eugene Cohen <eugene@hp.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	 "liming.gao@intel.com" <liming.gao@intel.com>,
	 "leif.lindholm@linaro.org" <leif.lindholm@linaro.org>
Subject: Re: [PATCH 1/3] ArmPkg/CompilerIntrinsicsLib: replace memcpy and memset with C code
Date: Fri, 12 Aug 2016 10:09:27 +0200	[thread overview]
Message-ID: <CAKv+Gu9brQ4AYznV0TbA-GKNUdehU=gdyLZRce4epyJ+KsWQqg@mail.gmail.com> (raw)
In-Reply-To: <93CB1B8B-8788-49FD-8FBE-9DF24F838FA6@apple.com>

On 12 August 2016 at 01:04, Andrew Fish <afish@apple.com> wrote:
>
>> On Aug 11, 2016, at 2:50 PM, Cohen, Eugene <eugene@hp.com> wrote:
>>
>>>> Why does memcpy performance matter?  In addition to the overall
>>> memcpy stuff scattered around C code we have an instance that is
>>> particularly sensitive to memcpy performance.  For DMA operations
>>> when invoking double-buffering or access to portions of a buffer that
>>> is common mapped (i.e. uncached on non-coherent DMA systems) the
>>> impact of a non-optimized memcpy is enormous compared to the
>>> optimized ones because the penalty is amplified by orders of
>>> magnitude due to uncached memory access latency.
>>>>
>>>
>>> That code would be using CopyMem(), no? This only serves the
>>> compiler
>>> generated calls, which are few since Tianocore does not allow
>>> initialized locals.
>>
>> I see and agree that should minimize the impact.   I guess I'll ask the naive question.  Could the BaseMemoryLib and CompilerIntrinsicsLib share the same stuff?
>>
>
> Eugene,
>
> I think if a CompilerIntrinsicsLib implementation consumes the BaseMemoryLib class (lists it in the INF) then I think it should just work.
>

Adding this

"""
--- a/ArmPkg/Library/BaseMemoryLibStm/AArch64/CopyMem.c
+++ b/ArmPkg/Library/BaseMemoryLibStm/AArch64/CopyMem.c
@@ -144,3 +144,10 @@ InternalMemCopyMem (
   }
   return DestinationBuffer;
 }
+
+//
+// Make this implementation satisfy references to the intrinsic memcpy() that
+// may be emitted by the compiler.
+//
+__attribute__((__weak__, __alias__("InternalMemCopyMem")))
+void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n);
"""

(and something similar for memset()) will make the AArch64 platforms I
usually test with build happily without the compilerintrinsicslib.
Since no other changes are required, this means that BaseMemoryLib is
already pulled into all modules one way or the other, and so it would
seem like an improvement not to have both implementations, since they
do exactly the same.

For ARM, this is obviously different given the RT abi and its __aeabi_
prefixed entry points. I suppose the memcpy and memset intrinsincs are
more a GCC thing than an ARM thing.


  reply	other threads:[~2016-08-12  8:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11 18:20 [PATCH 1/3] ArmPkg/CompilerIntrinsicsLib: replace memcpy and memset with C code Ard Biesheuvel
2016-08-11 18:20 ` [PATCH 2/3] BaseTools RVCT: ignore various RVC diagnostics Ard Biesheuvel
2016-08-12  3:04   ` Gao, Liming
2016-08-11 18:20 ` [PATCH 3/3] MdePkg RVCT: add definition of UNREACHABLE Ard Biesheuvel
2016-08-12  3:04   ` Gao, Liming
2016-08-11 21:34 ` [PATCH 1/3] ArmPkg/CompilerIntrinsicsLib: replace memcpy and memset with C code Cohen, Eugene
2016-08-11 21:45   ` Ard Biesheuvel
2016-08-11 21:50     ` Cohen, Eugene
2016-08-11 21:53       ` Ard Biesheuvel
2016-08-11 23:04       ` Andrew Fish
2016-08-12  8:09         ` Ard Biesheuvel [this message]
2016-09-01 13:11 ` Leif Lindholm

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-list 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='CAKv+Gu9brQ4AYznV0TbA-GKNUdehU=gdyLZRce4epyJ+KsWQqg@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /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