On Tue, Aug 21, 2012 at 12:26:30PM +0200, Marius Strobl wrote: ... > > Why we are use bcopy(), to copy only 6 bytes? > > Answer - in some architectures we are can not directly copy unaligned data. > > > > I propose this solution. > > > > In file /usr/src/include/net/ethernet.h add this lines: > > > > static inline void ether_addr_copy(ether_addr* src, ether_addr* dst) { > > #if defined(__i386__) || defined(__amd64__) > > *dst = *src; > > #else > > bcopy(src, dst, ETHER_ADDR_LEN); > > #endif > > } ... > > All this variants are much faster, than bcopy() > > > > A bit orthogonal to this but also related to the performance > impact of these bcopy() calls, for !__NO_STRICT_ALIGNMENT > architectures these places probably should use memcpy() > instead as bcopy() additionally has to check for overlap > while the former does not. Overlaps unlikely are an issue > in these cases and at least NetBSD apparently has done the > switch to memcpy() 5.5 years ago.
even more orthogonal: I found that copying 8n + (5, 6 or 7) bytes was much much slower than copying a multiple of 8 bytes. For n=0, 1,2,4,8 bytes are efficient, other cases are slow (turned into 2 or 3 different writes). The netmap code uses a pkt_copy routine that does exactly this rounding, gaining some 10-20ns per packet for small sizes. cheers luigi _______________________________________________ freebsd-net@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-net To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"