VirtualBox

Changeset 81388 in vbox


Ignore:
Timestamp:
Oct 20, 2019 11:15:06 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134101
Message:

PDM: Introducing a asynchronous ring-3 task concept to alliviate the places where we use single item PDM queues to trigger ring-3 work from ring-0 (and formerly raw-mode). Untested code, not enabled yet. bugref:9218

Location:
trunk
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r81375 r81388  
    976976
    977977
     978/** @name PDM task structures.
     979 * @{ */
     980
     981/**
     982 * A asynchronous user mode task.
     983 */
     984typedef struct PDMTASK
     985{
     986    /** Task owner type. */
     987    PDMTASKTYPE volatile        enmType;
     988    /** Queue flags. */
     989    uint32_t volatile           fFlags;
     990    /** User argument for the callback. */
     991    R3PTRTYPE(void *) volatile  pvUser;
     992    /** The callback (will be cast according to enmType before callout). */
     993    R3PTRTYPE(PFNRT) volatile   pfnCallback;
     994    /** The owner identifier. */
     995    R3PTRTYPE(void *) volatile  pvOwner;
     996    /** Task name. */
     997    R3PTRTYPE(const char *)     pszName;
     998} PDMTASK;
     999/** Pointer to a PDM task. */
     1000typedef PDMTASK *PPDMTASK;
     1001
     1002/**
     1003 * A task set.
     1004 *
     1005 * This is served by one task executor thread.
     1006 */
     1007typedef struct PDMTASKSET
     1008{
     1009    /** Magic value (PDMTASKSET_MAGIC). */
     1010    uint32_t                u32Magic;
     1011    /** Set if this task set works for ring-0 and raw-mode. */
     1012    bool                    fRZEnabled;
     1013    /** Number of allocated taks. */
     1014    uint8_t volatile        cAllocated;
     1015    /** Base handle value for this set. */
     1016    uint16_t                uHandleBase;
     1017    /** The task executor thread. */
     1018    R3PTRTYPE(RTTHREAD)     hThread;
     1019    /** Event semaphore for waking up the thread when fRZEnabled is set. */
     1020    SUPSEMEVENT             hEventR0;
     1021    /** Event semaphore for waking up the thread when fRZEnabled is clear. */
     1022    R3PTRTYPE(RTSEMEVENT)   hEventR3;
     1023    /** Padding so fTriggered is in its own cacheline. */
     1024    uint64_t                au64Padding2[4];
     1025
     1026    /** Bitmask of triggered tasks. */
     1027    uint64_t volatile       fTriggered;
     1028    /** Shutdown thread indicator. */
     1029    bool volatile           fShutdown;
     1030    /** Padding.   */
     1031    bool volatile           afPadding3[3];
     1032    /** Task currently running, UINT32_MAX if idle. */
     1033    uint32_t volatile       idxRunning;
     1034    /** Padding so fTriggered and fShutdown are in their own cacheline. */
     1035    uint64_t volatile       au64Padding3[6];
     1036
     1037    /** The individual tasks.  (Unallocated tasks have NULL pvOwner.)  */
     1038    PDMTASK                 aTasks[64];
     1039} PDMTASKSET;
     1040AssertCompileMemberAlignment(PDMTASKSET, fTriggered, 64);
     1041AssertCompileMemberAlignment(PDMTASKSET, aTasks, 64);
     1042/** Magic value for PDMTASKSET::u32Magic. */
     1043#define PDMTASKSET_MAGIC        UINT32_C(0x19320314)
     1044/** Pointer to a task set. */
     1045typedef PDMTASKSET *PPDMTASKSET;
     1046
     1047/** @} */
     1048
     1049
    9781050/**
    9791051 * Queue device helper task operation.
     
    11331205    PDMCRITSECT                     NopCritSect;
    11341206
     1207    /** The ring-0 capable task sets (max 128). */
     1208    PDMTASKSET                      aTaskSets[2];
     1209    /** Pointer to task sets (max 512). */
     1210    R3PTRTYPE(PPDMTASKSET)          apTaskSets[8];
     1211
     1212    /** PCI Buses. */
     1213    PDMPCIBUS                       aPciBuses[PDM_PCI_BUSSES_MAX];
     1214    /** The register PIC device. */
     1215    PDMPIC                          Pic;
     1216    /** The registered APIC device. */
     1217    PDMAPIC                         Apic;
     1218    /** The registered I/O APIC device. */
     1219    PDMIOAPIC                       IoApic;
     1220
    11351221    /** List of registered devices. (FIFO) */
    11361222    R3PTRTYPE(PPDMDEV)              pDevs;
     
    11451231    /** The registered firmware device (can be NULL). */
    11461232    R3PTRTYPE(PPDMFW)               pFirmware;
    1147     /** PCI Buses. */
    1148     PDMPCIBUS                       aPciBuses[PDM_PCI_BUSSES_MAX];
    1149     /** The register PIC device. */
    1150     PDMPIC                          Pic;
    1151     /** The registered APIC device. */
    1152     PDMAPIC                         Apic;
    1153     /** The registered I/O APIC device. */
    1154     PDMIOAPIC                       IoApic;
    11551233    /** The registered DMAC device. */
    11561234    R3PTRTYPE(PPDMDMAC)             pDmac;
     
    11601238    R3PTRTYPE(PPDMUSBHUB)           pUsbHubs;
    11611239
     1240    /** @name Queues
     1241     * @{ */
    11621242    /** Queue in which devhlp tasks are queued for R3 execution - R3 Ptr. */
    11631243    R3PTRTYPE(PPDMQUEUE)            pDevHlpQueueR3;
     
    11751255     * See PDM_QUEUE_FLUSH_FLAG_ACTIVE and PDM_QUEUE_FLUSH_FLAG_PENDING. */
    11761256    uint32_t volatile               fQueueFlushing;
     1257    /** @} */
    11771258
    11781259    /** The current IRQ tag (tracing purposes). */
     
    12161297    STAMCOUNTER                     StatQueuedCritSectLeaves;
    12171298} PDM;
     1299AssertCompileMemberAlignment(PDM, CritSect, 8);
     1300AssertCompileMemberAlignment(PDM, aTaskSets, 64);
     1301AssertCompileMemberAlignment(PDM, StatQueuedCritSectLeaves, 8);
    12181302AssertCompileMemberAlignment(PDM, GCPhysVMMDevHeap, sizeof(RTGCPHYS));
    1219 AssertCompileMemberAlignment(PDM, CritSect, 8);
    1220 AssertCompileMemberAlignment(PDM, StatQueuedCritSectLeaves, 8);
    12211303/** Pointer to PDM VM instance data. */
    12221304typedef PDM *PPDM;
     
    13851467void        pdmR3QueueRelocate(PVM pVM, RTGCINTPTR offDelta);
    13861468
     1469int         pdmR3TaskInit(PVM pVM);
     1470void        pdmR3TaskTerm(PVM pVM);
     1471
    13871472int         pdmR3ThreadCreateDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADDEV pfnThread,
    13881473                                    PFNPDMTHREADWAKEUPDEV pfnWakeup, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
Note: See TracChangeset for help on using the changeset viewer.

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