On Wed, Aug 3, 2022 at 9:11 AM Joanne Koong <joannelkoong@xxxxxxxxx> wrote: > > > > __builtin_memcpy() is best. When we write just "memcpy()" we still > > rely on compiler to actually optimizing that to __builtin_memcpy(), > > because there is no memcpy() (we'd get unrecognized extern error if > > compiler actually emitted call to memcpy()). > > Ohh I see, thanks for the explanation! > > I am going to do some selftests cleanup this week, so I'll change the > other usages of memcpy() to __builtin_memcpy() as part of that clean > up. builtin_memcpy might be doing single byte copy when alignment is not known which is often the case when working with packets. If we do this cleanup, let's copy-paste cilium's memcpy helper that does 8 byte copy. It's much better than builtin_memcpy. https://github.com/cilium/cilium/blob/master/bpf/include/bpf/builtins.h