> I have introduced the M_ZERO flag to the kernel malloc, which provides
> the service to bzero() the memory allocted.
> 
> In the kernel sources, the archetypical change to use this facility
> looks like this:
> 
> Old code:
>                databuf = malloc(length, M_DEVBUF, M_WAITOK);
>                bzero(databuf, length);
> 
> New code:
>                databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO);
> 
> Short term the benefit is less clutter in the code and a smaller
> cache footprint of the kernel.
> 
> Long term, this will allow us to optimize malloc(9) by allocating
> from a pool of memory which is zero'ed whenever the cpu is idle.

I'm thinking you really want to split this into two cases - first,
I want zeroed out memory NOW and second I want zeroed out memory when
and if I'm called into action because it might not happen.

You can have a ZFOD (zero fill on demand) fault give you a zeroed
out page for the second case.  For the first case I'm not sure what
the optimization gives you other than indeterminacy.  I'm also
not clear when you want an idle task zeroing memory compared to
a ZFOD type of operation for anyone expecting zeroed memory.

I guess I'm suggesting a clarification on when you want to set this flag.
If I want to be sure I get my zeroed out stuff real soon should I use
still use bzero?

Peter (couldn't afford BSDcon this year, looking forward to the right
coast version)

--
Peter Dufault ([EMAIL PROTECTED])   Realtime development, Machine control,
HD Associates, Inc.               Fail-Safe systems, Agency approval


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to