# HG changeset patch # User tobaru # Date 1579781802 -32400 # Node ID 6e03cee9733ef5eec736d35b8e39c324e32dd79c # Parent 66db83ec1ec2ca730c0e97b38f77531bac51ddb2 can use r diff -r 66db83ec1ec2 -r 6e03cee9733e src/impl/vm_impl.cbc --- a/src/impl/vm_impl.cbc Thu Jan 23 20:48:16 2020 +0900 +++ b/src/impl/vm_impl.cbc Thu Jan 23 21:16:42 2020 +0900 @@ -76,10 +76,9 @@ goto next(...); } __code kpt_allocvm_impl(struct vm_impl* vm, __code next(...)) { - struct run *r; acquire(&kpt_mem.lock); - goto kpt_alloc_check_impl(vm_impl, r, next(...)); + goto kpt_alloc_check_impl(vm_impl, next(...)); goto next(...); } diff -r 66db83ec1ec2 -r 6e03cee9733e src/impl/vm_impl_private.cbc --- a/src/impl/vm_impl_private.cbc Thu Jan 23 20:48:16 2020 +0900 +++ b/src/impl/vm_impl_private.cbc Thu Jan 23 21:16:42 2020 +0900 @@ -107,8 +107,20 @@ goto next(...); } +struct run { + struct run *next; +}; + +struct { + struct spinlock lock; + struct run* freelist; +} kpt_mem; + __code kpt_alloc_check_impl(struct vm_impl* vm_impl, __code next(...)) { - + struct run* r; + if ((r = kpt_mem.freelist) != NULL ) { + kpt_mem.freelist = r->next; + } goto kpt_alloc_check_inital_page(vm_impl, next(...)); }