svn commit: r323329 - head/sys/sys
Mateusz Guzik
mjg at FreeBSD.org
Fri Sep 8 20:09:16 UTC 2017
Author: mjg
Date: Fri Sep 8 20:09:14 2017
New Revision: 323329
URL: https://svnweb.freebsd.org/changeset/base/323329
Log:
Allow __builtin_memset instead of bzero for small buffers of known size
In particular this eliminates function calls and related register save/restore
when only few writes would suffice.
Example speed up can be seen in a fstat microbenchmark on AMD Ryzen cpus, where
the throughput went up by ~4.5%.
Thanks to cem@ for benchmarking and reviewing the patch.
MFC after: 1 week
Modified:
head/sys/sys/systm.h
Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h Fri Sep 8 20:07:53 2017 (r323328)
+++ head/sys/sys/systm.h Fri Sep 8 20:09:14 2017 (r323329)
@@ -258,6 +258,12 @@ void hexdump(const void *ptr, int length, const char *
#define ovbcopy(f, t, l) bcopy((f), (t), (l))
void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len);
void bzero(void * _Nonnull buf, size_t len);
+#define bzero(buf, len) ({ \
+ if (__builtin_constant_p(len) && (len) <= 64) \
+ __builtin_memset((buf), 0, (len)); \
+ else \
+ bzero((buf), (len)); \
+})
void explicit_bzero(void * _Nonnull, size_t);
void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len);
More information about the svn-src-head
mailing list