VirtualBox

Changeset 75498 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Nov 16, 2018 12:03:41 AM (6 years ago)
Author:
vboxsync
Message:

HGCM,Main,SharedFolder,SharedClipboard,GuestProperties: Added HGCM service helpers for statistics and dbg info registration/deregistration. A PUVM is passed to HGCMService (where the helpers are implemented) when the service is loaded. Since this drags in both dbg.h and stam.h, LOG_GROUP defines now have to be at the top of the include list as everywhere else (i.e. hgcmsvc.h will define LOG_GROUP default by dragging in log.h). Added generic statistics of HGCM message processing and function level statistics to the shared folder service. [missing files, ++]

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/HGCM.cpp

    r75497 r75498  
    909909        RTStrCopy(szThreadName, sizeof(szThreadName), pszServiceName);
    910910
    911     int rc = hgcmThreadCreate(&m_thread, szThreadName, hgcmServiceThread, this);
     911    int rc = hgcmThreadCreate(&m_thread, szThreadName, hgcmServiceThread, this, pszServiceName, pUVM);
    912912
    913913    if (RT_SUCCESS(rc))
     
    26812681         */
    26822682
    2683         rc = hgcmThreadCreate(&g_hgcmThread, "MainHGCMthread", hgcmThread, NULL);
     2683        rc = hgcmThreadCreate(&g_hgcmThread, "MainHGCMthread", hgcmThread, NULL /*pvUser*/, NULL /*pszStatsSubDir*/, NULL /*pUVM*/);
    26842684
    26852685        if (RT_FAILURE(rc))
  • trunk/src/VBox/Main/src-client/HGCMThread.cpp

    r69500 r75498  
    2222
    2323#include <VBox/err.h>
     24#include <VBox/vmm/stam.h>
    2425#include <iprt/semaphore.h>
    2526#include <iprt/thread.h>
     
    119120        HGCMTHREADHANDLE m_handle;
    120121
     122        /** @name Statistics
     123         * @{ */
     124        STAMCOUNTER m_StatPostMsgNoPending;
     125        STAMCOUNTER m_StatPostMsgOnePending;
     126        STAMCOUNTER m_StatPostMsgTwoPending;
     127        STAMCOUNTER m_StatPostMsgThreePending;
     128        STAMCOUNTER m_StatPostMsgManyPending;
     129        /** @} */
     130
    121131        inline int Enter (void);
    122132        inline void Leave (void);
     
    133143        int WaitForTermination (void);
    134144
    135         int Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser);
     145        int Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser,
     146                        const char *pszStatsSubDir, PUVM pUVM);
    136147
    137148        int MsgAlloc (HGCMMSGHANDLE *pHandle, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage);
     
    264275}
    265276
    266 int HGCMThread::Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser)
    267 {
    268     int rc = VINF_SUCCESS;
    269 
    270     rc = RTSemEventMultiCreate (&m_eventThread);
     277int HGCMThread::Initialize (HGCMTHREADHANDLE handle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser,
     278                            const char *pszStatsSubDir, PUVM pUVM)
     279{
     280    int rc = RTSemEventMultiCreate (&m_eventThread);
    271281
    272282    if (RT_SUCCESS(rc))
     
    294304                if (RT_SUCCESS(rc))
    295305                {
     306                    /* Register statistics while the thread starts. */
     307                    if (pUVM)
     308                    {
     309                        STAMR3RegisterFU(pUVM, &m_StatPostMsgNoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     310                                         "Times a message was appended to an empty input queue.",
     311                                         "/HGCM/%s/PostMsg0Pending", pszStatsSubDir);
     312                        STAMR3RegisterFU(pUVM, &m_StatPostMsgOnePending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     313                                         "Times a message was appended to input queue with only one pending message.",
     314                                         "/HGCM/%s/PostMsg1Pending", pszStatsSubDir);
     315                        STAMR3RegisterFU(pUVM, &m_StatPostMsgTwoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     316                                         "Times a message was appended to input queue with only one pending message.",
     317                                         "/HGCM/%s/PostMsg2Pending", pszStatsSubDir);
     318                        STAMR3RegisterFU(pUVM, &m_StatPostMsgTwoPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     319                                         "Times a message was appended to input queue with only one pending message.",
     320                                         "/HGCM/%s/PostMsg3Pending", pszStatsSubDir);
     321                        STAMR3RegisterFU(pUVM, &m_StatPostMsgManyPending, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT,
     322                                         "Times a message was appended to input queue with only one pending message.",
     323                                         "/HGCM/%s/PostMsgManyPending", pszStatsSubDir);
     324                    }
     325
     326
    296327                    /* Wait until the thread is ready. */
    297328                    rc = RTThreadUserWait (thread, 30000);
     
    314345        {
    315346            Log(("hgcmThreadCreate: FAILURE: Can't create an event semaphore for a sent messages.\n"));
    316             m_eventSend = 0;
     347            m_eventSend = NIL_RTSEMEVENTMULTI;
    317348        }
    318349    }
     
    320351    {
    321352        Log(("hgcmThreadCreate: FAILURE: Can't create an event semaphore for a hgcm worker thread.\n"));
    322         m_eventThread = 0;
     353        m_eventThread = NIL_RTSEMEVENTMULTI;
    323354    }
    324355
     
    409440        /* Insert the message to the queue tail. */
    410441        pMsg->m_pNext = NULL;
    411         pMsg->m_pPrev = m_pMsgInputQueueTail;
    412 
    413         if (m_pMsgInputQueueTail)
    414         {
    415             m_pMsgInputQueueTail->m_pNext = pMsg;
     442        HGCMMsgCore * const pPrev = m_pMsgInputQueueTail;
     443        pMsg->m_pPrev = pPrev;
     444
     445        if (pPrev)
     446        {
     447            pPrev->m_pNext = pMsg;
     448            if (!pPrev->m_pPrev)
     449                STAM_REL_COUNTER_INC(&m_StatPostMsgOnePending);
     450            else if (!pPrev->m_pPrev)
     451                STAM_REL_COUNTER_INC(&m_StatPostMsgTwoPending);
     452            else if (!pPrev->m_pPrev->m_pPrev)
     453                STAM_REL_COUNTER_INC(&m_StatPostMsgThreePending);
     454            else
     455                STAM_REL_COUNTER_INC(&m_StatPostMsgManyPending);
    416456        }
    417457        else
    418458        {
    419459            m_pMsgInputQueueHead = pMsg;
     460            STAM_REL_COUNTER_INC(&m_StatPostMsgNoPending);
    420461        }
    421462
     
    630671 */
    631672
    632 int hgcmThreadCreate (HGCMTHREADHANDLE *pHandle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser)
     673int hgcmThreadCreate (HGCMTHREADHANDLE *pHandle, const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser,
     674                      const char *pszStatsSubDir, PUVM pUVM)
    633675{
    634676    int rc = VINF_SUCCESS;
     
    647689
    648690        /* Initialize the object. */
    649         rc = pThread->Initialize (handle, pszThreadName, pfnThread, pvUser);
     691        rc = pThread->Initialize (handle, pszThreadName, pfnThread, pvUser, pszStatsSubDir, pUVM);
    650692    }
    651693    else
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