Subject: Re: percpu storage allocator
To: None <ad@netbsd.org>
From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
List: tech-kern
Date: 11/13/2007 08:48:21
> I think you could get away with not taking the rwlock in the cross call
> thread by deferring the lock to percpu_cpu_enlarge():
> 
> 	if (pcc.pcc_data != NULL) {
> 		rw_enter(&percpu_swap_lock, RW_WRITER);
> 		/* Ensures old value of pcc_data is no longer used. */
> 		rw_exit(&percpu_swap_lock);
> 		kmem_free(pcc.pcc_data, pcc.pcc_size);
> 	}
> 
> Threads traversing will see either old or new values, but in either case the
> pointer dereference will be safe. It may not be worth it; if so we should
> probably document that threads doing a traversal should be careful not to
> delay the xcall thread.

it's a good idea.

> The caller's stack could be swapped out before the xcall completes so &pcc
> isn't safe.

good catch.

YAMAMOTO Takashi