Subject: Re: loaning for read() of regular files
To: None <chuq@chuq.com>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-kern
Date: 02/16/2005 08:22:30
hi,

> +	/*
> +	 * None of the obvious reasons why we might not be able to do the loan
> +	 * are true.  If we need to COW the amap, try to do it now.
> +	 */

don't you need to check (entry->protection & VM_PROT_WRITE) ?

> +	aref = entry->aref;

why copy aref?

> +		simple_lock(&uobj->vmobjlock);
> +		uvm_lock_pageq();
> +		for (i = 0; i < npages; i++) {
> +			uvm_pageactivate(pgs[i]);
> +		}
> +		uvm_page_unbusy(pgs, npages);
> +		uvm_unlock_pageq();
> +		simple_unlock(&uobj->vmobjlock);

(although somewhat offtopic,) how do you think about PR/28372 ?

> +		pg->loan_count++;
> +		uvm_pageactivate(pg);
> +		anon = amap_lookup(&aref, aoff + (i << PAGE_SHIFT));
> +		if (anon) {
> +			oanons[oanon++] = anon;
> +			amap_unadd(&aref, aoff + (i << PAGE_SHIFT));
> +		}
> +		if (pg->uanon) {
> +			anon = pg->uanon;
> +			simple_lock(&anon->an_lock);
> +			anon->an_ref++;

i think you shouldn't increment loan_count if the page is
already ->A loaned.

YAMAMOTO Takashi