From owner-freebsd-current Sun Oct 22 15:21:21 2000 Delivered-To: freebsd-current@freebsd.org Received: from hda.hda.com (host65.hda.com [63.104.68.65]) by hub.freebsd.org (Postfix) with ESMTP id C405537B4CF; Sun, 22 Oct 2000 15:21:16 -0700 (PDT) Received: (from dufault@localhost) by hda.hda.com (8.9.3/8.9.3) id SAA00866; Sun, 22 Oct 2000 18:24:03 -0400 (EDT) (envelope-from dufault) From: Peter Dufault Message-Id: <200010222224.SAA00866@hda.hda.com> Subject: Re: Junior Kernel Hacker Task: M_ZERO In-Reply-To: <17100.972069144@critter> from Poul-Henning Kamp at "Oct 20, 2000 09:12:24 pm" To: Poul-Henning Kamp Date: Sun, 22 Oct 2000 18:23:57 -0400 (EDT) Cc: current@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL61 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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