possibly missed wakeup in swap_pager_getpages()

Divacky Roman xdivac02 at stud.fit.vutbr.cz
Fri Mar 9 13:28:53 UTC 2007


hi

when looking at PR103455 I found this and I have a question..

code:

   swp_pager_strategy(bp);

        /*
         * wait for the page we want to complete.  VPO_SWAPINPROG is always
         * cleared on completion.  If an I/O error occurs, SWAPBLK_NONE
         * is set in the meta-data.
         */
        VM_OBJECT_LOCK(object);
        while ((mreq->oflags & VPO_SWAPINPROG) != 0) {
                mreq->oflags |= VPO_WANTED;
                vm_page_lock_queues();
                vm_page_flag_set(mreq, PG_REFERENCED);
                vm_page_unlock_queues();
                cnt.v_intrans++;
                if (msleep(mreq, VM_OBJECT_MTX(object), PSWP, "swread", hz*20)) {

the swp_pager_strategy() initiates IO (which should issue the wakeup() necessary
for the msleep()). the problem in the PR is that the msleep() is never (within the
specified 20 seconds) woken up. I wonder if this is because the wakeup arrives BEFORE
the actual msleep() is issued. the page queue locking can take some time so there
is a space for a missed wakeup.

is my analysis correct? if so, can the race be mitigated by moving the flag setting (hence
also the locking) after the msleep()?

thnx

roman



More information about the freebsd-hackers mailing list