From owner-freebsd-current Fri Oct 20 12:27:12 2000 Delivered-To: freebsd-current@freebsd.org Received: from critter.freebsd.dk (termroom.bsdcon.org [206.55.247.2]) by hub.freebsd.org (Postfix) with ESMTP id 5F96F37B479 for ; Fri, 20 Oct 2000 12:27:10 -0700 (PDT) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.1/8.9.3) with ESMTP id e9KJCOm17102 for ; Fri, 20 Oct 2000 21:12:24 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: current@freebsd.org Subject: Junior Kernel Hacker Task: M_ZERO From: Poul-Henning Kamp Date: Fri, 20 Oct 2000 21:12:24 +0200 Message-ID: <17100.972069144@critter> 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. If anybody is looking for a simple task to perform in the FreeBSD kernel: this is it. A quick grep tells me that there are at least 91 files in the src/sys tree which could use this flag to simplify and optimize the code. The ground rules for such a cleanup are: Respect the style of the source file. Don't make unrelated changes: If you spot other issues with the code as you read it, make a separate diff for those issues. Bundle the patches at administrative boundaries: a directory at a time, a driver at a time etc etc. Submit changes to the maintainer of the file (if any) or with send-pr. Junior committers are encouraged to review and commit these PR's as they arrive -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message