On Jan 22, 2010, at 12:28 AM, enami tsugutomo wrote: >> Module Name: src >> Committed By: matt >> Date: Fri Jan 22 05:17:32 UTC 2010 >> >> Modified Files: >> src/sys/uvm [matt-nb5-mips64]: uvm_pglist.c >> >> Log Message: >> Rework the algorithm to allocate contiguous pages to be much much faster. >> (read the comments if you want to know how it's done). >> >> >> To generate a diff of this commit: >> cvs rdiff -u -r1.42 -r1.42.16.1 src/sys/uvm/uvm_pglist.c > >> /* >> * Test both the ending and starting pages to see if they are >> * both free. If the ending and starting pages are same page, >> * we only test one of them. If the pages aren't free, there >> * is no reason to continue this iteration so advance to the >> * next address and try again. >> */ >> if (VM_PAGE_IS_FREE(&pgs[end - 1]) == 0 >> || end - 1 == tryidx + skip >> || VM_PAGE_IS_FREE(&pgs[tryidx + skip]) == 0) { >> try += roundup(num, align); >> skip = 0; >> continue; >> } > > I guess this part can be improved and/or fixed as below.
I initially did something like that but realized it didn't really buy me anything since the compiler will actually do something like that anyways.