Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: [matt-nb5-mips64] src/sys/uvm



> 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.

enami.

                /*
                 * If the last page is not free, skip entire region.
                 */
                if (VM_PAGE_IS_FREE(&pgs[end - 1]) == 0) {
                        try += roundup(num, align);
                        skip = 0;
                        continue;
                }

                /*
                 * If the last page is the only page to check,
                 * we found enough space.
                 */
                if (end - 1 == tryidx + skip) {
                        while (skip-- > 0) {
                                KDASSERT(VM_PAGE_IS_FREE(&pgs[tryidx + skip]));
                        }
#ifdef PGALLOC_VERBOSE
                        printf(": ok\n");
#endif
                        break;
                }

                /*
                 * If the start page is not free, start from next boundary
                 * to the start page.
                 */
                if (VM_PAGE_IS_FREE(&pgs[tryidx + skip]) == 0) {
                        try += roundup(skip + 1, align);
                        skip = 0;
                        continue;
                }


Home | Main Index | Thread Index | Old Index