Date: Tue, 2 Oct 2018 13:51:11 +0200 From: Sebastian Huber <sebastian.huber@embedded-brains.de> To: FreeBSD <freebsd-hackers@freebsd.org> Subject: m_copydata() with overlapping data? Message-ID: <6c801b04-6e07-3122-868c-20810e795aa7@embedded-brains.de>
index | next in thread | raw e-mail
Hello,
I investigate currently a performance issue on a Microchip ATSAME70Q21
(ARM Cortex-M7). The Newlib C-library has specialized routines for
memcpy(), but not for memmove(). I noticed that m_copydata() uses
bcopy() internally. According to the man page bcopy() is capable to deal
with overlapping memory regions. Is this also a requirement for
m_copydata() or could we use memcpy() here? For example:
diff --git a/freebsd/sys/kern/uipc_mbuf.c b/freebsd/sys/kern/uipc_mbuf.c
index 185d14a0..00dcd975 100644
--- a/freebsd/sys/kern/uipc_mbuf.c
+++ b/freebsd/sys/kern/uipc_mbuf.c
@@ -593,7 +593,7 @@ m_copydata(const struct mbuf *m, int off, int len,
caddr_t cp)
while (len > 0) {
KASSERT(m != NULL, ("m_copydata, length > size of mbuf
chain"));
count = min(m->m_len - off, len);
- bcopy(mtod(m, caddr_t) + off, cp, count);
+ cp = memcpy(cp, mtod(m, caddr_t) + off, count);
len -= count;
cp += count;
off = 0;
Maybe this should be mentioned in the man page:
https://www.freebsd.org/cgi/man.cgi?query=m_copydata
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6c801b04-6e07-3122-868c-20810e795aa7>
