Subject: Re: fdexpand() memory shortage check (Re: kern/14721)
To: Jaromir Dolecek <jdolecek@netbsd.org>
From: None <enami@but-b.or.jp>
List: tech-kern
Date: 01/09/2002 08:17:04
>  	/*
> -	 * Copy the existing ofile and ofileflags arrays
> -	 * and zero the new portion of each array.
> +	 * Copy the existing ofile and ofileflags arrays.
> +	 * The new portion of each array were zeroed above.

Probably fdexpand() may not be called so often but zeroing whole chunk
and then copying old contents obviously wastes cpu.  Also, since you
aren't using uvm_km_``z''alloc(), the code won't work as intented.

> +	if (__predict_false(newofile == NULL)) {
> +		int uid = p->p_cred && p->p_ucred ? p->p_ucred->cr_uid : -1;
> +		log(LOG_INFO, "pid %d (%s), uid %d: fdexpand() to %d files failed, process killed",
> +			p->p_pid, p->p_comm, uid, nfiles);
> +		exit1(p, W_EXITCODE(0, SIGKILL));
> +		/* NOTREACHED */
> +	}
> +

Please wrap that long line.  And it is better to have empty line after
the variable definition.  Also, continuation line shoule be indented
by four space (like other part of your change).  BTW, I guess you
copied base of this from kern_sig.c but p_cred and p_ucred really may
be NULL here (and there)?

enami.