VirtualBox

Changeset 22885 in vbox for trunk/src/VBox/VMM/testcase


Ignore:
Timestamp:
Sep 9, 2009 9:58:49 PM (15 years ago)
Author:
vboxsync
Message:

VMM: Realigned VM and VMCPU members for 64 byte cache lines. Made VMCPU and VM::aCpus page aligned for potentially increasing the TLB efficiency. (This is expected to burn on 64-bit hosts.)

Location:
trunk/src/VBox/VMM/testcase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/testcase/tstHelp.h

    r20374 r22885  
    7070    do \
    7171    { \
    72         if ( RT_OFFSETOF(strct, member) & ((align) - 1) ) \
     72        if (RT_OFFSETOF(strct, member) & ((align) - 1) ) \
    7373        { \
    74             printf("%s::%s offset=%#x expected alignment %x, meaning %#x off\n", #strct, #member, (unsigned)RT_OFFSETOF(strct, member), \
    75                    (unsigned)(align), (unsigned)(RT_OFFSETOF(strct, member) & ((align) - 1))); \
     74            printf("%s::%s offset=%#x (%u) expected alignment %x, meaning %#x (%u) off\n", \
     75                   #strct, #member, \
     76                   (unsigned)RT_OFFSETOF(strct, member), \
     77                   (unsigned)RT_OFFSETOF(strct, member), \
     78                   (unsigned)(align), \
     79                   (unsigned)((align) - RT_OFFSETOF(strct, member) & ((align) - 1)), \
     80                   (unsigned)((align) - RT_OFFSETOF(strct, member) & ((align) - 1)) ); \
    7681            rc++; \
    7782        } \
     
    8590        if (RT_ALIGN_Z(sizeof(type), (align)) != sizeof(type)) \
    8691        { \
    87             printf("%s size=%#x, align=%#x %#x bytes off\n", #type, (int)sizeof(type), \
    88                   (align), (int)RT_ALIGN_Z(sizeof(type), align) - (int)sizeof(type)); \
     92            printf("%s size=%#x (%u), align=%#x %#x (%u) bytes off\n", \
     93                   #type, \
     94                   (unsigned)sizeof(type), \
     95                   (unsigned)sizeof(type), \
     96                   (align), \
     97                   (unsigned)RT_ALIGN_Z(sizeof(type), align) - (unsigned)sizeof(type), \
     98                   (unsigned)RT_ALIGN_Z(sizeof(type), align) - (unsigned)sizeof(type)); \
    8999            rc++; \
    90100        } \
     
    94104 * Checks that a internal struct padding is big enough.
    95105 */
    96 #define CHECK_PADDING(strct, member) \
     106#define CHECK_PADDING(strct, member, align) \
    97107    do \
    98108    { \
     
    101111        { \
    102112            printf("padding of %s::%s is too small, padding=%d struct=%d correct=%d\n", #strct, #member, \
    103                    (int)sizeof(p->member.padding), (int)sizeof(p->member.s), (int)RT_ALIGN_Z(sizeof(p->member.s), 64)); \
     113                   (int)sizeof(p->member.padding), (int)sizeof(p->member.s), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
     114            rc++; \
     115        } \
     116        else if (RT_ALIGN_Z(sizeof(p->member.padding), (align)) != sizeof(p->member.padding)) \
     117        { \
     118            printf("padding of %s::%s is misaligned, padding=%d correct=%d\n", #strct, #member, \
     119                   (int)sizeof(p->member.padding), (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
    104120            rc++; \
    105121        } \
  • trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp

    r21989 r22885  
    7373    printf("struct VM: %d bytes\n", (int)sizeof(VM));
    7474
    75 #define CHECK_PADDING_VM(member) \
     75#define CHECK_PADDING_VM(align, member) \
    7676    do \
    7777    { \
    78         CHECK_PADDING(VM, member); \
    79         CHECK_MEMBER_ALIGNMENT(VM, member, 32); \
     78        CHECK_PADDING(VM, member, align); \
     79        CHECK_MEMBER_ALIGNMENT(VM, member, align); \
     80        VM *p; \
     81        if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
     82            printf("warning: VM::%-8s: padding=%-5d s=%-5d -> %-4d  suggest=%-5u\n", \
     83                   #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
     84                   (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
     85                   (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
    8086    } while (0)
    8187
    8288
    83 #define CHECK_PADDING_VMCPU(member) \
     89#define CHECK_PADDING_VMCPU(align, member) \
    8490    do \
    8591    { \
    86         CHECK_PADDING(VMCPU, member); \
    87         CHECK_MEMBER_ALIGNMENT(VMCPU, member, 32); \
     92        CHECK_PADDING(VMCPU, member, align); \
     93        CHECK_MEMBER_ALIGNMENT(VMCPU, member, align); \
     94        VMCPU *p; \
     95        if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
     96            printf("warning: VMCPU::%-8s: padding=%-5d s=%-5d -> %-4d  suggest=%-5u\n", \
     97                   #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
     98                   (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
     99                   (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
    88100    } while (0)
    89101
     
    137149    CHECK_SIZE(X86PML4, PAGE_SIZE);
    138150
    139     CHECK_PADDING_VM(cfgm);
    140     CHECK_PADDING_VM(cpum);
    141     CHECK_PADDING_VM(dbgf);
    142     CHECK_PADDING_VM(em);
    143     CHECK_PADDING_VM(iom);
    144     CHECK_PADDING_VM(mm);
    145     CHECK_PADDING_VM(pdm);
    146     CHECK_PADDING_VM(pgm);
    147     CHECK_PADDING_VM(selm);
    148     CHECK_PADDING_VM(tm);
    149     CHECK_PADDING_VM(trpm);
    150     CHECK_PADDING_VM(vm);
    151     CHECK_PADDING_VM(vmm);
    152     CHECK_PADDING_VM(ssm);
    153     CHECK_PADDING_VM(rem);
    154     CHECK_PADDING_VM(hwaccm);
    155     CHECK_PADDING_VM(patm);
    156     CHECK_PADDING_VM(csam);
    157 
    158     CHECK_PADDING_VMCPU(cpum);
    159     CHECK_PADDING_VMCPU(pgm);
    160     CHECK_PADDING_VMCPU(em);
    161     CHECK_PADDING_VMCPU(hwaccm);
    162     CHECK_PADDING_VMCPU(trpm);
    163     CHECK_PADDING_VMCPU(tm);
    164     CHECK_PADDING_VMCPU(vmm);
     151    CHECK_PADDING_VM(64, cpum);
     152    CHECK_PADDING_VM(64, vmm);
     153    CHECK_PADDING_VM(64, pgm);
     154    CHECK_PADDING_VM(64, hwaccm);
     155    CHECK_PADDING_VM(64, trpm);
     156    CHECK_PADDING_VM(64, selm);
     157    CHECK_PADDING_VM(64, mm);
     158    CHECK_PADDING_VM(64, pdm);
     159    CHECK_PADDING_VM(64, iom);
     160    CHECK_PADDING_VM(64, patm);
     161    CHECK_PADDING_VM(64, csam);
     162    CHECK_PADDING_VM(64, em);
     163    CHECK_PADDING_VM(64, tm);
     164    CHECK_PADDING_VM(64, dbgf);
     165    CHECK_PADDING_VM(64, ssm);
     166    CHECK_PADDING_VM(64, rem);
     167    CHECK_PADDING_VM(8, vm);
     168#ifdef VBOX_WITH_VMI
     169    CHECK_PADDING_VM(8, parav);
     170#endif
     171    CHECK_PADDING_VM(8, cfgm);
     172
     173    CHECK_PADDING_VMCPU(64, cpum);
     174    CHECK_PADDING_VMCPU(64, pgm);
     175    CHECK_PADDING_VMCPU(64, hwaccm);
     176    CHECK_PADDING_VMCPU(64, em);
     177    CHECK_PADDING_VMCPU(64, trpm);
     178    CHECK_PADDING_VMCPU(64, tm);
     179    CHECK_PADDING_VMCPU(64, vmm);
     180    CHECK_PADDING_VMCPU(64, pdm);
     181    CHECK_PADDING_VMCPU(64, iom);
     182    CHECK_PADDING_VMCPU(64, dbgf);
    165183
    166184    CHECK_MEMBER_ALIGNMENT(VM, selm.s.Tss, 16);
     
    207225    CHECK_MEMBER_ALIGNMENT(VM, rem.s.StatsInQEMU, 8);
    208226    CHECK_MEMBER_ALIGNMENT(VM, rem.s.Env, 32);
    209     CHECK_MEMBER_ALIGNMENT(VM, aCpus, 64);
    210 
    211     /* vmcpu */
    212     CHECK_MEMBER_ALIGNMENT(VMCPU, cpum, 64);
    213     CHECK_MEMBER_ALIGNMENT(VMCPU, vmm, 32);
    214     CHECK_MEMBER_ALIGNMENT(VMCPU, pgm, 32);
    215     CHECK_MEMBER_ALIGNMENT(VMCPU, em, 32);
    216     CHECK_MEMBER_ALIGNMENT(VMCPU, hwaccm, 32);
    217     CHECK_MEMBER_ALIGNMENT(VMCPU, tm, 32);
    218     CHECK_SIZE_ALIGNMENT(VMCPU, 32);
     227
     228    /* the VMCPUs are page aligned TLB hit reassons. */
     229    CHECK_MEMBER_ALIGNMENT(VM, aCpus, 4096);
     230    CHECK_SIZE_ALIGNMENT(VMCPU, 4096);
    219231
    220232    /* cpumctx */
     
    268280    /* pdm */
    269281    CHECK_MEMBER_ALIGNMENT(PDMDEVINS, achInstanceData, 64);
    270     CHECK_PADDING(PDMDEVINS, Internal);
     282    CHECK_PADDING(PDMDEVINS, Internal, 1);
    271283    CHECK_MEMBER_ALIGNMENT(PDMUSBINS, achInstanceData, 16);
    272     CHECK_PADDING(PDMUSBINS, Internal);
     284    CHECK_PADDING(PDMUSBINS, Internal, 1);
    273285    CHECK_MEMBER_ALIGNMENT(PDMDRVINS, achInstanceData, 16);
    274     CHECK_PADDING(PDMDRVINS, Internal);
     286    CHECK_PADDING(PDMDRVINS, Internal, 1);
    275287    CHECK_PADDING2(PDMCRITSECT);
    276288    CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, idx, sizeof(uint16_t));
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