VirtualBox

Changeset 38749 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 14, 2011 12:19:14 PM (13 years ago)
Author:
vboxsync
Message:

PDM: Warn if devices/drivers take too long to suspend or power off. Also log the total time spent suspending and powering off.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PDM.cpp

    r37466 r38749  
    278278#define PDM_SAVED_STATE_VERSION             4
    279279#define PDM_SAVED_STATE_VERSION_PRE_NMI_FF  3
     280
     281/** The number of nanoseconds a suspend callback needs to take before
     282 * PDMR3Suspend warns about it taking too long. */
     283#define PDMSUSPEND_WARN_AT_NS               UINT64_C(1200000000)
     284
     285/** The number of nanoseconds a suspend callback needs to take before
     286 * PDMR3PowerOff warns about it taking too long. */
     287#define PDMPOWEROFF_WARN_AT_NS              UINT64_C( 900000000)
    280288
    281289
     
    14811489        if (pDrvIns->pReg->pfnSuspend)
    14821490        {
     1491            uint64_t cNsElapsed = RTTimeNanoTS();
     1492
    14831493            if (!pDrvIns->Internal.s.pfnAsyncNotify)
    14841494            {
     
    14961506                         pDrvIns->pReg->szName, pDrvIns->iInstance, iLun, pszDevName, iDevInstance));
    14971507            }
     1508
     1509            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     1510            if (cNsElapsed >= PDMSUSPEND_WARN_AT_NS)
     1511                LogRel(("PDMR3Suspend: Driver '%s'/%d on LUN#%d of device '%s'/%d took %'llu ns to suspend\n",
     1512                        pDrvIns->pReg->szName, pDrvIns->iInstance, iLun, pszDevName, iDevInstance, cNsElapsed));
     1513
    14981514            if (pDrvIns->Internal.s.pfnAsyncNotify)
    14991515            {
     
    15221538        if (pUsbIns->pReg->pfnVMSuspend)
    15231539        {
     1540            uint64_t cNsElapsed = RTTimeNanoTS();
     1541
    15241542            if (!pUsbIns->Internal.s.pfnAsyncNotify)
    15251543            {
    1526                 LogFlow(("PDMR3Suspend: Notifying - device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
     1544                LogFlow(("PDMR3Suspend: Notifying - USB device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
    15271545                pUsbIns->pReg->pfnVMSuspend(pUsbIns);
    15281546                if (pUsbIns->Internal.s.pfnAsyncNotify)
    1529                     LogFlow(("PDMR3Suspend: Async notification started - device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
     1547                    LogFlow(("PDMR3Suspend: Async notification started - USB device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
    15301548            }
    15311549            else if (pUsbIns->Internal.s.pfnAsyncNotify(pUsbIns))
    15321550            {
    1533                 LogFlow(("PDMR3Suspend: Async notification completed - device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
     1551                LogFlow(("PDMR3Suspend: Async notification completed - USB device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
    15341552                pUsbIns->Internal.s.pfnAsyncNotify = NULL;
    15351553            }
     
    15391557                pdmR3NotifyAsyncAdd(pAsync, pUsbIns->Internal.s.pUsbDev->pReg->szName, pUsbIns->iInstance);
    15401558            }
     1559
     1560            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     1561            if (cNsElapsed >= PDMSUSPEND_WARN_AT_NS)
     1562                LogRel(("PDMR3Suspend: USB device '%s'/%d took %'llu ns to suspend\n",
     1563                        pUsbIns->pReg->szName, pUsbIns->iInstance, cNsElapsed));
    15411564        }
    15421565    }
     
    15581581        if (pDevIns->pReg->pfnSuspend)
    15591582        {
     1583            uint64_t cNsElapsed = RTTimeNanoTS();
     1584
    15601585            if (!pDevIns->Internal.s.pfnAsyncNotify)
    15611586            {
     
    15751600                pdmR3NotifyAsyncAdd(pAsync, pDevIns->Internal.s.pDevR3->pReg->szName, pDevIns->iInstance);
    15761601            }
     1602
     1603            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     1604            if (cNsElapsed >= PDMSUSPEND_WARN_AT_NS)
     1605                LogRel(("PDMR3Suspend: device '%s'/%d took %'llu ns to suspend\n",
     1606                        pDevIns->pReg->szName, pDevIns->iInstance, cNsElapsed));
    15771607        }
    15781608    }
     
    15911621    LogFlow(("PDMR3Suspend:\n"));
    15921622    VM_ASSERT_EMT0(pVM);
     1623    uint64_t cNsElapsed = RTTimeNanoTS();
    15931624
    15941625    /*
     
    16581689    pdmR3ThreadSuspendAll(pVM);
    16591690
    1660     LogFlow(("PDMR3Suspend: returns void\n"));
     1691    cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     1692    LogRel(("PDMR3Suspend: %'llu ns run time\n", cNsElapsed));
    16611693}
    16621694
     
    18141846        if (pDrvIns->pReg->pfnPowerOff)
    18151847        {
     1848            uint64_t cNsElapsed = RTTimeNanoTS();
     1849
    18161850            if (!pDrvIns->Internal.s.pfnAsyncNotify)
    18171851            {
     
    18291863                         pDrvIns->pReg->szName, pDrvIns->iInstance, iLun, pszDevName, iDevInstance));
    18301864            }
     1865
     1866            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     1867            if (cNsElapsed >= PDMPOWEROFF_WARN_AT_NS)
     1868                LogRel(("PDMR3PowerOff: Driver '%s'/%d on LUN#%d of device '%s'/%d took %'llu ns to power off\n",
     1869                        pDrvIns->pReg->szName, pDrvIns->iInstance, iLun, pszDevName, iDevInstance, cNsElapsed));
     1870
    18311871            if (pDrvIns->Internal.s.pfnAsyncNotify)
    18321872            {
     
    18561896        if (pUsbIns->pReg->pfnVMPowerOff)
    18571897        {
     1898            uint64_t cNsElapsed = RTTimeNanoTS();
     1899
    18581900            if (!pUsbIns->Internal.s.pfnAsyncNotify)
    18591901            {
    1860                 LogFlow(("PDMR3PowerOff: Notifying - device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
     1902                LogFlow(("PDMR3PowerOff: Notifying - USB device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
    18611903                pUsbIns->pReg->pfnVMPowerOff(pUsbIns);
    18621904                if (pUsbIns->Internal.s.pfnAsyncNotify)
    1863                     LogFlow(("PDMR3PowerOff: Async notification started - device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
     1905                    LogFlow(("PDMR3PowerOff: Async notification started - USB device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
    18641906            }
    18651907            else if (pUsbIns->Internal.s.pfnAsyncNotify(pUsbIns))
    18661908            {
    1867                 LogFlow(("PDMR3PowerOff: Async notification completed - device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
     1909                LogFlow(("PDMR3PowerOff: Async notification completed - USB device '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
    18681910                pUsbIns->Internal.s.pfnAsyncNotify = NULL;
    18691911            }
     
    18731915                pdmR3NotifyAsyncAdd(pAsync, pUsbIns->Internal.s.pUsbDev->pReg->szName, pUsbIns->iInstance);
    18741916            }
     1917
     1918            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     1919            if (cNsElapsed >= PDMPOWEROFF_WARN_AT_NS)
     1920                LogRel(("PDMR3PowerOff: USB device '%s'/%d took %'llu ns to power off\n",
     1921                        pUsbIns->pReg->szName, pUsbIns->iInstance, cNsElapsed));
     1922
    18751923        }
    18761924    }
     
    18921940        if (pDevIns->pReg->pfnPowerOff)
    18931941        {
     1942            uint64_t cNsElapsed = RTTimeNanoTS();
     1943
    18941944            if (!pDevIns->Internal.s.pfnAsyncNotify)
    18951945            {
     
    19091959                pdmR3NotifyAsyncAdd(pAsync, pDevIns->Internal.s.pDevR3->pReg->szName, pDevIns->iInstance);
    19101960            }
     1961
     1962            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     1963            if (cNsElapsed >= PDMPOWEROFF_WARN_AT_NS)
     1964                LogFlow(("PDMR3PowerOff: Device '%s'/%d took %'llu ns to power off\n",
     1965                         pDevIns->pReg->szName, pDevIns->iInstance, cNsElapsed));
    19111966        }
    19121967    }
     
    19231978{
    19241979    LogFlow(("PDMR3PowerOff:\n"));
     1980    uint64_t cNsElapsed = RTTimeNanoTS();
    19251981
    19261982    /*
     
    19852041    pdmR3ThreadSuspendAll(pVM);
    19862042
    1987     LogFlow(("PDMR3PowerOff: returns void\n"));
     2043    cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     2044    LogRel(("PDMR3PowerOff: %'llu ns run time\n", cNsElapsed));
    19882045}
    19892046
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