Date: Sun, 22 Oct 2000 18:23:57 -0400 (EDT) From: Peter Dufault <dufault@hda.com> To: Poul-Henning Kamp <phk@FreeBSD.ORG> Cc: current@FreeBSD.ORG Subject: Re: Junior Kernel Hacker Task: M_ZERO Message-ID: <200010222224.SAA00866@hda.hda.com> In-Reply-To: <17100.972069144@critter> from Poul-Henning Kamp at "Oct 20, 2000 09:12:24 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
> 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 (dufault@hda.com) Realtime development, Machine control, HD Associates, Inc. Fail-Safe systems, Agency approval To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200010222224.SAA00866>