Discussion:
m_copydata() with overlapping data?
(too old to reply)
Sebastian Huber
2018-10-02 11:51:11 UTC
Permalink
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 : ***@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
Loading...