VirtualBox

Changeset 18597 in vbox


Ignore:
Timestamp:
Apr 1, 2009 1:34:19 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
45501
Message:

REM: Added a l0 map for PageDesc, this should fix the performance issue if our hunch is right about the cause. Profile tb_flush.

Location:
trunk/src/recompiler_new
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler_new/VBoxRecompiler.c

    r18596 r18597  
    390390    STAM_REG(pVM, &gStatSelOutOfSyncStateBack[4],   STAMTYPE_COUNTER,   "/REM/StateBack/SelOutOfSync/FS",   STAMUNIT_OCCURENCES, "FS out of sync");
    391391    STAM_REG(pVM, &gStatSelOutOfSyncStateBack[5],   STAMTYPE_COUNTER,   "/REM/StateBack/SelOutOfSync/GS",   STAMUNIT_OCCURENCES, "GS out of sync");
     392
     393    STAM_REG(pVM, &pVM->rem.s.Env.StatTbFlush,      STAMTYPE_PROFILE,   "/REM/TbFlush",     STAMUNIT_TICKS_PER_CALL, "profiling tb_flush().");
    392394#endif /* VBOX_WITH_STATISTICS */
    393395
  • trunk/src/recompiler_new/exec.c

    r18595 r18597  
    182182#define L1_BITS (TARGET_VIRT_ADDR_SPACE_BITS - L2_BITS - TARGET_PAGE_BITS)
    183183#else
    184 # ifdef VBOX /* > 4GB please. */
    185 #define L1_BITS (TARGET_PHYS_ADDR_SPACE_BITS - L2_BITS - TARGET_PAGE_BITS)
    186 # else
    187184#define L1_BITS (32 - L2_BITS - TARGET_PAGE_BITS)
    188 # endif
    189 #endif
    190 
     185#endif
     186#ifdef VBOX
     187/* Note: Not for PhysPageDesc, only to speed up page_flush_tb. */
     188#define L0_BITS (TARGET_PHYS_ADDR_SPACE_BITS - 32)
     189#endif
     190
     191#ifdef VBOX
     192#define L0_SIZE (1 << L0_BITS)
     193#endif
    191194#define L1_SIZE (1 << L1_BITS)
    192195#define L2_SIZE (1 << L2_BITS)
     
    200203
    201204/* XXX: for system emulation, it could just be an array */
     205#ifndef VBOX
    202206static PageDesc *l1_map[L1_SIZE];
     207#else
     208static l0_map_max_used = 0;
     209static PageDesc **l0_map[L0_SIZE];
     210#endif
    203211static PhysPageDesc **l1_phys_map;
    204212
     
    353361#endif
    354362{
     363#ifndef VBOX
    355364#if TARGET_LONG_BITS > 32
    356365    /* Host memory outside guest VM.  For 32-bit targets we have already
    357366       excluded high addresses.  */
    358 # ifndef VBOX
    359367    if (index > ((target_ulong)L2_SIZE * L1_SIZE))
    360368        return NULL;
    361 # else  /* VBOX */
    362     AssertMsgReturn(index < (target_ulong)L2_SIZE * L1_SIZE,
    363                     ("index=%RGp >= %RGp; L1_SIZE=%#x L2_SIZE=%#x\n",
    364                      (RTGCPHYS)index, (RTGCPHYS)L2_SIZE * L1_SIZE, L1_SIZE, L2_SIZE),
     369#endif
     370    return &l1_map[index >> L2_BITS];
     371#else  /* VBOX */
     372    PageDesc **l1_map;
     373    AssertMsgReturn(index < (target_ulong)L2_SIZE * L1_SIZE * L0_SIZE,
     374                    ("index=%RGp >= %RGp; L1_SIZE=%#x L2_SIZE=%#x L0_SIZE=%#x\n",
     375                     (RTGCPHYS)index, (RTGCPHYS)L2_SIZE * L1_SIZE, L1_SIZE, L2_SIZE, L0_SIZE),
    365376                    NULL);
    366 # endif /* VBOX */
    367 
    368 #endif
    369     return &l1_map[index >> L2_BITS];
     377    l1_map = l0_map[index >> (L1_BITS + L2_BITS)];
     378    if (RT_UNLIKELY(!l1_map))
     379    {
     380        unsigned i0 = index >> (L1_BITS + L2_BITS);
     381        l0_map[i0] = l1_map = qemu_mallocz(sizeof(PageDesc *) * L1_SIZE);
     382        if (RT_UNLIKELY(!l1_map))
     383            return NULL;
     384        if (i0 >= l0_map_max_used)
     385            l0_map_max_used = i0 + 1;
     386    }
     387    return &l1_map[(index >> L2_BITS) & (L1_SIZE - 1)];
     388#endif /* VBOX */
    370389}
    371390
     
    703722    int i, j;
    704723    PageDesc *p;
    705 
    706     for(i = 0; i < L1_SIZE; i++) {
    707         p = l1_map[i];
    708         if (p) {
    709             for(j = 0; j < L2_SIZE; j++) {
    710                 p->first_tb = NULL;
    711                 invalidate_page_bitmap(p);
    712                 p++;
     724#ifdef VBOX
     725    int k;
     726#endif
     727
     728#ifdef VBOX
     729    k = l0_map_max_used;
     730    while (k-- > 0) {
     731        PageDesc **l1_map = l0_map[k];
     732        if (l1_map) {
     733#endif
     734            for(i = 0; i < L1_SIZE; i++) {
     735                p = l1_map[i];
     736                if (p) {
     737                    for(j = 0; j < L2_SIZE; j++) {
     738                        p->first_tb = NULL;
     739                        invalidate_page_bitmap(p);
     740                        p++;
     741                    }
     742                }
    713743            }
    714         }
    715     }
     744#ifdef VBOX
     745        }
     746    }
     747#endif
    716748}
    717749
     
    721753{
    722754    CPUState *env;
     755#ifdef VBOX
     756    STAM_PROFILE_START(&env1->StatTbFlush, a);
     757#endif
    723758#if defined(DEBUG_FLUSH)
    724759    printf("qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n",
     
    743778       expensive */
    744779    tb_flush_count++;
     780#ifdef VBOX
     781    STAM_PROFILE_STOP(&env1->StatTbFlush, a);
     782#endif
    745783}
    746784
  • trunk/src/recompiler_new/target-i386/cpu.h

    r17274 r18597  
    6262# include <iprt/asm.h>
    6363# include <VBox/vmm.h>
     64# include <VBox/stam.h>
    6465#endif /* VBOX */
    6566
     
    677678#else
    678679    uint32_t alignment2[3];
     680    /** Profiling tb_flush. */
     681    STAMPROFILE StatTbFlush;
    679682#endif
    680683} CPUX86State;
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