Subject: Re: Further mbuf adventures
To: Darren Reed <avalon@caligula.anu.edu.au>
From: Jason Thorpe <thorpej@wasabisystems.com>
List: tech-net
Date: 05/01/2004 22:08:18
--Apple-Mail-10--59399740
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII; format=flowed


On May 1, 2004, at 4:44 PM, Darren Reed wrote:

> Now, I have another problem...M_ROMAP & M_READONLY.  M_ROMAP appears:
>
> /usr/src/sys/kern/uipc_socket.c
> /usr/src/sys/arch/arm/arm32/bus_dma.c
> /usr/src/sys/sys/mbuf.h
> /usr/src/sys/nfs/nfs_vnops.c
> /usr/src/sys/nfs/nfs_serv.c
> /usr/src/sys/nfs/nfs_subs.c
>
> ...and so one might surmise that its purpose is to mark external mbuf
> data as being mapped read-only.  I'm curious as to why only arm32's
> bus_dma consider's this significant.

The purpose is to mark that the mbuf data is mapped read-only at the 
MMU level.  This is not quite the same as an mbuf that must not be 
modified, which does not reflect MMU state... it is possible for an 
mbuf to be M_READONLY and *not* M_ROMAP.

The purpose of M_ROMAP is to indicate to bus_dma back-ends that they 
might be able to skip some work.  Take the example of the ARM... when a 
mapping is made read-only at the MMU, the cache is cleaned; these 
read-only mappings are used when page loaning (see sosend_loan).  Now, 
when the packet makes it down to the bus_dma layer on its way out to 
the wire, bus_dma can see that M_ROMAP is set and thus skip an 
otherwise redundant cache clean operation (it was cleaned when the 
mapping was made read-only).

> Strangely, the M_ROMAP flag does not directly imply M_READONLY, but
> by virtue of how mbufs are setup for M_ROMAP, M_READONLY should always
> be true.  I'm not 100% sure if this is satisfactory - a more explicit
> relationship between these two wouldn't be missed.

Yes, it's perfectly satisfactory the way it is.  The two indicators 
mean different things.

         -- Jason R. Thorpe <thorpej@wasabisystems.com>


--Apple-Mail-10--59399740
content-type: application/pgp-signature; x-mac-type=70674453;
	name=PGP.sig
content-description: This is a digitally signed message part
content-disposition: inline; filename=PGP.sig
content-transfer-encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (Darwin)

iD8DBQFAlIJHOpVKkaBm8XkRAuVBAJ0V8G8LoGlVUJ5yY+RgV0S8ozxyNgCaA/az
53vWmgNf9ftlaEAMf0AAJbs=
=TcW5
-----END PGP SIGNATURE-----

--Apple-Mail-10--59399740--