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
[EMAIL PROTECTED]         | 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to