VirtualBox

Changeset 2565 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 9, 2007 4:28:03 PM (18 years ago)
Author:
vboxsync
Message:

A little experiment trying to get rid of the critsect contention in DevATA.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r2544 r2565  
    339339    /** The position at which to get a new request for the AIO thread. */
    340340    uint8_t             AsyncIOReqTail;
    341     uint8_t             Alignment3[2]; /** Explicit padding of the 2 byte gap. */
     341    uint8_t             Alignment3[2]; /**< Explicit padding of the 2 byte gap. */
    342342    /** Magic delay before triggering interrupts in DMA mode. */
    343343    uint32_t            DelayIRQMillies;
     
    597597    rc = RTSemMutexRelease(pCtl->AsyncIORequestMutex);
    598598    AssertRC(rc);
    599     rc = RTSemEventSignal(pCtl->AsyncIOSem);
    600     AssertRC(rc);
     599    LogBird(("ata: %x: signalling\n", pCtl->IOPortBase1));
     600    rc = PDMR3CritSectScheduleExitEvent(&pCtl->lock, pCtl->AsyncIOSem);
     601    if (VBOX_FAILURE(rc))
     602    {
     603        LogBird(("ata: %x: schedule failed, rc=%Vrc\n", pCtl->IOPortBase1, rc));
     604        rc = RTSemEventSignal(pCtl->AsyncIOSem);
     605        AssertRC(rc);
     606    }
    601607}
    602608
     
    39903996        if (pReq == NULL)
    39913997        {
     3998            LogBird(("ata: %x: going to sleep...\n", pCtl->IOPortBase1));
    39923999            rc = RTSemEventWait(pCtl->AsyncIOSem, RT_INDEFINITE_WAIT);
     4000            LogBird(("ata: %x: waking up\n", pCtl->IOPortBase1));
    39934001            if (VBOX_FAILURE(rc) || pCtl->fShutdown)
    39944002                break;
     
    40204028        {
    40214029        STAM_PROFILE_START(&pCtl->StatLockWait, a);
     4030        LogBird(("ata: %x: entering critsect\n", pCtl->IOPortBase1));
    40224031        PDMCritSectEnter(&pCtl->lock, VINF_SUCCESS);
     4032        LogBird(("ata: %x: entered\n", pCtl->IOPortBase1));
    40234033        STAM_PROFILE_STOP(&pCtl->StatLockWait, a);
    40244034        }
     
    43584368        }
    43594369
     4370        LogBird(("ata: %x: leaving critsect\n", pCtl->IOPortBase1));
    43604371        PDMCritSectLeave(&pCtl->lock);
    43614372    }
     
    47404751    else
    47414752        AssertMsgFailed(("ataIOPortWrite1: unsupported write to port %x val=%x size=%d\n", Port, u32, cb));
     4753    LogBird(("ata: leaving critsect\n"));
    47424754    PDMCritSectLeave(&pCtl->lock);
     4755    LogBird(("ata: left critsect\n"));
    47434756    return rc;
    47444757}
  • trunk/src/VBox/VMM/PDMCritSect.cpp

    r634 r2565  
    119119        pCritSect->pVMGC = pVM->pVMGC;
    120120        pCritSect->pvKey = pvKey;
     121        pCritSect->EventToSignal = NIL_RTSEMEVENT;
    121122        pCritSect->pNext = pVM->pdm.s.pCritSects;
    122123        pVM->pdm.s.pCritSects = pCritSect;
     
    323324}
    324325
     326
     327/**
     328 * Schedule a event semaphore for signalling upon critsect exit.
     329 *
     330 * @returns VINF_SUCCESS on success.
     331 * @returns VERR_TOO_MANY_SEMAPHORES if an event was already scheduled.
     332 * @returns VERR_NOT_OWNER if we're not the critsect owner.
     333 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
     334 * @param   pCritSect       The critical section.
     335 * @param   EventToSignal     The semapore that should be signalled.
     336 */
     337PDMR3DECL(int) PDMR3CritSectScheduleExitEvent(PPDMCRITSECT pCritSect, RTSEMEVENT EventToSignal)
     338{
     339    Assert(EventToSignal != NIL_RTSEMEVENT);
     340    if (RT_UNLIKELY(!RTCritSectIsOwner(&pCritSect->s.Core)))
     341        return VERR_NOT_OWNER;
     342    if (RT_LIKELY(   pCritSect->s.EventToSignal == NIL_RTSEMEVENT
     343                  || pCritSect->s.EventToSignal == EventToSignal))
     344    {
     345        pCritSect->s.EventToSignal = EventToSignal;
     346        return VINF_SUCCESS;
     347    }
     348    return VERR_TOO_MANY_SEMAPHORES;
     349}
     350
  • trunk/src/VBox/VMM/PDMInternal.h

    r1447 r2565  
    146146    /** Pointer to the VM - GCPtr. */
    147147    GCPTRTYPE(PVM)      pVMGC;
    148 #if GC_ARCH_BITS == 32
    149     uint32_t            u32Padding;
    150 #endif
     148#if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
     149    uint32_t            padding;
     150#endif
     151    /** Event semaphore that is scheduled to be signaled upon leaving the
     152     * critical section. This is Ring-3 only of course. */
     153    RTSEMEVENT          EventToSignal;
    151154    /** R0/GC lock contention. */
    152155    STAMCOUNTER         StatContentionR0GCLock;
  • trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp

    r23 r2565  
    3434#include <iprt/asm.h>
    3535#include <iprt/assert.h>
     36#ifdef IN_RING3
     37# include <iprt/semaphore.h>
     38#endif
    3639
    3740
     
    107110        STAM_PROFILE_ADV_STOP(&pCritSect->s.StatLocked, l);
    108111# endif
    109     int rc = RTCritSectLeave(&pCritSect->s.Core);
    110     AssertRC(rc);
     112    RTSEMEVENT EventToSignal = pCritSect->s.EventToSignal;
     113    if (RT_LIKELY(EventToSignal == NIL_RTSEMEVENT))
     114    {
     115        int rc = RTCritSectLeave(&pCritSect->s.Core);
     116        AssertRC(rc);
     117    }
     118    else
     119    {
     120        pCritSect->s.EventToSignal = NIL_RTSEMEVENT;
     121        int rc = RTCritSectLeave(&pCritSect->s.Core);
     122        AssertRC(rc);
     123        LogBird(("signalling %#x\n", EventToSignal));
     124        rc = RTSemEventSignal(EventToSignal);
     125        AssertRC(rc);
     126    }
    111127
    112 #else
     128#else /* !IN_RING3 */
    113129    Assert(VALID_PTR(pCritSect));
    114130    Assert(pCritSect->s.Core.u32Magic == RTCRITSECT_MAGIC);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette