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>
next in thread | raw e-mail | index | archive | help
Hello, I investigate currently a performance issue on a Microchip ATSAME70Q21=20 (ARM Cortex-M7). The Newlib C-library has specialized routines for=20 memcpy(), but not for memmove(). I noticed that m_copydata() uses=20 bcopy() internally. According to the man page bcopy() is capable to deal=20 with overlapping memory regions. Is this also a requirement for=20 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,=20 caddr_t cp) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 while (len > 0) { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 KASSERT(m !=3D NULL, ("m_copydata, length > size of mb= uf=20 chain")); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 count =3D min(m->m_len - off, len); -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 bcopy(mtod(m, caddr_t) + off, cp, count); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 cp =3D memcpy(cp, mtod(m, caddr_t) + off, count); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 len -=3D count; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 cp +=3D count; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 off =3D 0; Maybe this should be mentioned in the man page: https://www.freebsd.org/cgi/man.cgi?query=3Dm_copydata --=20 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=C3=A4ftliche Mitteilung im Sinne des EHUG= .
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6c801b04-6e07-3122-868c-20810e795aa7>