Subject: Re: lock bug in getnewvnode, or uvm_km_kmemalloc/uvm_map ?
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: enami tsugutomo <enami@sm.sony.co.jp>
List: tech-kern
Date: 11/27/2002 11:02:54
Manuel Bouyer <bouyer@antioche.eu.org> writes:

> @@ -300,8 +300,8 @@
>  	struct vm_anon **newover, **oldover;
>  	UVMHIST_FUNC("amap_extend"); UVMHIST_CALLED(maphist);
>  
> -	UVMHIST_LOG(maphist, "  (entry=0x%x, addsize=0x%x, forwards=%d)",
> -	    entry, addsize, forwards, 0);
> +	UVMHIST_LOG(maphist, "  (entry=0x%x, addsize=0x%x, flags=%d)",
> +	    entry, addsize, flags, 0);

I prefer flags to be printed in hex rather than decimal.

> @@ -911,7 +932,14 @@
>  
>  			vaddr_t to_add = (flags & UVM_FLAG_AMAPPAD) ?
>  				UVM_AMAP_CHUNK << PAGE_SHIFT : 0;
> -			struct vm_amap *amap = amap_alloc(size, to_add, M_WAITOK);
> +			struct vm_amap *amap = amap_alloc(size, to_add,
> +			    (flags & UVM_KMF_NOWAIT) ? M_NOWAIT : M_WAITOK);
> +			if (__predict_false(amap == NULL)) {
> +				vm_map_unlock(map);
> +				if (new_entry)
> +					uvm_mapent_free(new_entry);
> +				return ENOMEM;
> +			}
>  			new_entry->aref.ar_pageoff = 0;
>  			new_entry->aref.ar_amap = amap;
>  		} else {

`if (new_entry)' is always true here.

enami.