VirtualBox

Changeset 44355 in vbox for trunk/src/VBox/VMM/include


Ignore:
Timestamp:
Jan 24, 2013 1:27:28 PM (12 years ago)
Author:
vboxsync
Message:

PDMNetShaper: Cleanups & fixes (untested). PVM -> PUVM. Note: cs is a register within the VMM, not critical section. :)

Location:
trunk/src/VBox/VMM/include
Files:
1 edited
1 moved

Legend:

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

    r43657 r44355  
    10861086    R3PTRTYPE(PPDMASYNCCOMPLETIONTEMPLATE) pAsyncCompletionTemplates;
    10871087    /** @} */
     1088
     1089    /** Global block cache data. */
     1090    R3PTRTYPE(PPDMBLKCACHEGLOBAL)   pBlkCacheGlobal;
    10881091#ifdef VBOX_WITH_NETSHAPER
    10891092    /** Pointer to network shaper instance. */
    10901093    R3PTRTYPE(PPDMNETSHAPER)        pNetShaper;
    10911094#endif /* VBOX_WITH_NETSHAPER */
    1092 
    1093     R3PTRTYPE(PPDMBLKCACHEGLOBAL)   pBlkCacheGlobal;
    10941095
    10951096} PDMUSERPERVM;
  • trunk/src/VBox/VMM/include/PDMNetShaperInternal.h

    r44346 r44355  
    11/* $Id$ */
    22/** @file
    3  * PDM Network Shaper - Internal data structures and functions common for both
    4  * R0 and R3 parts.
     3 * PDM Network Shaper - Internal data structures and functions common for both R0 and R3 parts.
    54 */
    65
    76/*
    8  * Copyright (C) 2011-2012 Oracle Corporation
     7 * Copyright (C) 2011-2013 Oracle Corporation
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3231{
    3332    /** Pointer to the next group in the list. */
    34     struct PDMNSBWGROUP                        *pNext;
     33    R3PTRTYPE(struct PDMNSBWGROUP *)            pNextR3;
    3534    /** Pointer to the shared UVM structure. */
    36     struct PDMNETSHAPER                        *pShaper;
     35    R3PTRTYPE(struct PDMNETSHAPER *)            pShaperR3;
    3736    /** Critical section protecting all members below. */
    38     PDMCRITSECT               cs;
     37    PDMCRITSECT                                 Lock;
    3938    /** Pointer to the first filter attached to this group. */
    40     struct PDMNSFILTER                         *pFiltersHead;
     39    R3PTRTYPE(struct PDMNSFILTER *)             pFiltersHeadR3;
    4140    /** Bandwidth group name. */
    42     char                                       *pszName;
     41    R3PTRTYPE(char *)                           pszNameR3;
    4342    /** Maximum number of bytes filters are allowed to transfer. */
    44     volatile uint64_t                           cbTransferPerSecMax;
     43    volatile uint64_t                           cbPerSecMax;
    4544    /** Number of bytes we are allowed to transfer in one burst. */
    46     volatile uint32_t                           cbBucketSize;
     45    volatile uint32_t                           cbBucket;
    4746    /** Number of bytes we were allowed to transfer at the last update. */
    4847    volatile uint32_t                           cbTokensLast;
     
    5554typedef PDMNSBWGROUP *PPDMNSBWGROUP;
    5655
    57 DECLINLINE(bool) pdmNsAllocateBandwidth(PPDMNSFILTER pFilter, size_t cbTransfer)
    58 {
    59     AssertPtrReturn(pFilter, true);
    60     if (!VALID_PTR(pFilter->CTX_SUFF(pBwGroup)))
    61         return true;
    6256
    63     PPDMNSBWGROUP pBwGroup = ASMAtomicReadPtrT(&pFilter->CTX_SUFF(pBwGroup), PPDMNSBWGROUP);
    64     int rc = PDMCritSectEnter(&pBwGroup->cs, VERR_SEM_BUSY); AssertRC(rc);
    65     if (RT_UNLIKELY(rc == VERR_SEM_BUSY))
    66         return true;
    67     bool fAllowed = true;
    68     if (pBwGroup->cbTransferPerSecMax)
    69     {
    70         /* Re-fill the bucket first */
    71         uint64_t tsNow = RTTimeSystemNanoTS();
    72         uint32_t uTokensAdded = (tsNow - pBwGroup->tsUpdatedLast)*pBwGroup->cbTransferPerSecMax/(1000*1000*1000);
    73         uint32_t uTokens = RT_MIN(pBwGroup->cbBucketSize, uTokensAdded + pBwGroup->cbTokensLast);
    74 
    75         if (cbTransfer > uTokens)
    76         {
    77             fAllowed = false;
    78             ASMAtomicWriteBool(&pFilter->fChoked, true);
    79         }
    80         else
    81         {
    82             pBwGroup->tsUpdatedLast = tsNow;
    83             pBwGroup->cbTokensLast = uTokens - (uint32_t)cbTransfer;
    84         }
    85         Log2((LOG_FN_FMT "BwGroup=%#p{%s} cbTransfer=%u uTokens=%u uTokensAdded=%u fAllowed=%RTbool\n",
    86               __PRETTY_FUNCTION__, pBwGroup, pBwGroup->pszName, cbTransfer, uTokens, uTokensAdded, fAllowed));
    87     }
    88     else
    89         Log2((LOG_FN_FMT "BwGroup=%#p{%s} disabled fAllowed=%RTbool\n",
    90               __PRETTY_FUNCTION__, pBwGroup, pBwGroup->pszName, fAllowed));
    91 
    92     rc = PDMCritSectLeave(&pBwGroup->cs); AssertRC(rc);
    93     return fAllowed;
    94 }
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