Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Dec 2001 08:00:10 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Luigi Rizzo <luigi@FreeBSD.org>
Cc:        Peter Wemm <peter@wemm.org>, <cvs-committers@FreeBSD.org>, <cvs-all@FreeBSD.org>
Subject:   Re: NFS and unaligned accesses (was  Re: cvs commit: src/sys/pci if_sis.c)
Message-ID:  <20011201074728.P2691-100000@gamplex.bde.org>
In-Reply-To: <20011129090643.E19821@iguana.aciri.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 29 Nov 2001, Luigi Rizzo wrote:

> So to go back where this came from, and hopefully disprove
> what I always considered to be an urban legend:
>
> the "sis" and other drivers do an m_devget() (which involves a
> bcopy) to make sure that buffers are aligned (to a 32 bit boundary,
> probably) in the upper level layers. On architectures which trap
> on unaligned accesses there is no other way, but on the i386 at
> least, the bcopy() just makes you pays the cost of misalignment in
> advance (and even when you do not need e.g. because you
> are forwarding traffic or handling TCP, which has its own
> alignment constraints and more often than not ends up in userspace).
>
> The remedy seems as bad or worse than the evil.

On some i386's at least, bcopy() can be "optimized" so that alignment
doesn't matter much (align the destination), but this isn't done because
it would pessimize the usual case where everything is aligned, especially
for small counts.

Aligning the destination instead of the source (when one of them must
remained misaligned) is best (at least on i386's) because read caching
tends to work better than write buffering/caching.  Perhaps this changed
when writes started being preallocated for the PII or PPro.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011201074728.P2691-100000>