VirtualBox

Changeset 78673 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 22, 2019 5:43:36 PM (6 years ago)
Author:
vboxsync
Message:

FsPerf: More tweaks/options for tailorying windows testing. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/fs/FsPerf.cpp

    r78535 r78673  
    325325    kCmdOpt_MMap,
    326326    kCmdOpt_NoMMap,
     327    kCmdOpt_MMapCoherency,
     328    kCmdOpt_NoMMapCoherency,
     329    kCmdOpt_MMapPlacement,
    327330    kCmdOpt_IgnoreNoCache,
    328331    kCmdOpt_NoIgnoreNoCache,
     
    344347    kCmdOpt_ManyTreeDepth,
    345348
     349    kCmdOpt_MaxBufferSize,
     350
    346351    kCmdOpt_End
    347352};
     
    369374    { "--subdirs-per-dir",          kCmdOpt_ManyTreeSubdirsPerDir,  RTGETOPT_REQ_UINT32 },
    370375    { "--tree-depth",               kCmdOpt_ManyTreeDepth,          RTGETOPT_REQ_UINT32 },
     376    { "--max-buffer-size",          kCmdOpt_MaxBufferSize,          RTGETOPT_REQ_UINT32 },
     377    { "--mmap-placement",           kCmdOpt_MMapPlacement,          RTGETOPT_REQ_STRING },
    371378
    372379    { "--open",                     kCmdOpt_Open,                   RTGETOPT_REQ_NOTHING },
     
    426433    { "--mmap",                     kCmdOpt_MMap,                   RTGETOPT_REQ_NOTHING },
    427434    { "--no-mmap",                  kCmdOpt_NoMMap,                 RTGETOPT_REQ_NOTHING },
     435    { "--mmap-coherency",           kCmdOpt_MMapCoherency,          RTGETOPT_REQ_NOTHING },
     436    { "--no-mmap-coherency",        kCmdOpt_NoMMapCoherency,        RTGETOPT_REQ_NOTHING },
    428437    { "--ignore-no-cache",          kCmdOpt_IgnoreNoCache,          RTGETOPT_REQ_NOTHING },
    429438    { "--no-ignore-no-cache",       kCmdOpt_NoIgnoreNoCache,        RTGETOPT_REQ_NOTHING },
     
    460469/** Verbosity level. */
    461470static uint32_t     g_uVerbosity = 0;
     471/** Max buffer size, UINT32_MAX for unlimited.
     472 * This is for making sure we don't run into the MDL limit on windows, which
     473 * a bit less than 64 MiB. */
     474#if defined(RT_OS_WINDOWS)
     475static uint32_t     g_cbMaxBuffer = _32M;
     476#else
     477static uint32_t     g_cbMaxBuffer = UINT32_MAX;
     478#endif
     479/** When to place the mmap test. */
     480static int          g_iMMapPlacement = 0;
    462481
    463482/** @name Selected subtest
     
    495514static bool         g_fFSync                = true;
    496515static bool         g_fMMap                 = true;
     516static bool         g_fMMapCoherency        = true;
    497517static bool         g_fCopy                 = true;
    498518static bool         g_fRemote               = true;
     
    13061326     * Allocate a suitable buffer.
    13071327     */
    1308     size_t   cbBuf = cbToWrite >= _2M ? _2M : RT_ALIGN_Z((size_t)cbToWrite, 512);
    1309     uint8_t *pbBuf = (uint8_t *)RTMemTmpAlloc(cbBuf);
     1328    size_t   cbMaxBuf = RT_MIN(_2M, g_cbMaxBuffer);
     1329    size_t   cbBuf    = cbToWrite >= cbMaxBuf ? cbMaxBuf : RT_ALIGN_Z((size_t)cbToWrite, 512);
     1330    uint8_t *pbBuf    = (uint8_t *)RTMemTmpAlloc(cbBuf);
    13101331    if (!pbBuf)
    13111332    {
     
    22012222void fsPerfNtQueryInfoFileWorker(HANDLE hNtFile1, uint32_t fType)
    22022223{
     2224    char const chType = fType == RTFS_TYPE_DIRECTORY ? 'd' : 'r';
     2225
    22032226    /** @todo may run out of buffer for really long paths? */
    22042227    union
     
    23632386            {
    23642387                if (rcNt != STATUS_INVALID_INFO_CLASS)
    2365                     RTTestIFailed("%s/%#x: %#x, expected STATUS_INVALID_INFO_CLASS", pszClass, cbBuf, rcNt);
     2388                    RTTestIFailed("%s/%#x/%c: %#x, expected STATUS_INVALID_INFO_CLASS", pszClass, cbBuf, chType, rcNt);
    23662389            }
    23672390            else if (   rcNt != STATUS_INVALID_INFO_CLASS
     
    23882411                               || (   fType == RTFS_TYPE_DIRECTORY
    23892412                                   && (enmClass == FileSfioReserveInformation || enmClass == FileStatLxInformation)))
     2413                     && !(rcNt == STATUS_INVALID_DEVICE_REQUEST && fType == RTFS_TYPE_FILE)
    23902414                    )
    2391                 RTTestIFailed("%s/%#x: %#x", pszClass, cbBuf, rcNt);
     2415                RTTestIFailed("%s/%#x/%c: %#x", pszClass, cbBuf, chType, rcNt);
    23922416            if (   (Ios.Status != VirginIos.Status || Ios.Information != VirginIos.Information)
    23932417                && !(   fType == RTFS_TYPE_DIRECTORY /* NTFS/W10-17763 */
    23942418                    && Ios.Status == rcNt && Ios.Information == 0) )
    2395                 RTTestIFailed("%s/%#x: I/O status block was modified: %#x %#zx", pszClass, cbBuf, Ios.Status, Ios.Information);
     2419                RTTestIFailed("%s/%#x/%c: I/O status block was modified: %#x %#zx",
     2420                              pszClass, cbBuf, chType, Ios.Status, Ios.Information);
    23962421            if (!ASMMemIsAllU8(&uBuf, sizeof(uBuf), 0xff))
    2397                 RTTestIFailed("%s/%#x: Buffer was touched in failure case!", pszClass, cbBuf);
     2422                RTTestIFailed("%s/%#x/%c: Buffer was touched in failure case!", pszClass, cbBuf, chType);
    23982423        }
    23992424    }
     
    34403465
    34413466
     3467int fsPerfIoPrepFileWorker(RTFILE hFile1, uint64_t cbFile, uint8_t *pbBuf, size_t cbBuf)
     3468{
     3469    /*
     3470     * Fill the file with 0xf6 and insert offset markers with 1KB intervals.
     3471     */
     3472    RTTESTI_CHECK_RC_RET(RTFileSeek(hFile1, 0, RTFILE_SEEK_BEGIN, NULL), VINF_SUCCESS, rcCheck);
     3473    memset(pbBuf, 0xf6, cbBuf);
     3474    uint64_t cbLeft = cbFile;
     3475    uint64_t off = 0;
     3476    while (cbLeft > 0)
     3477    {
     3478        Assert(!(off   & (_1K - 1)));
     3479        Assert(!(cbBuf & (_1K - 1)));
     3480        for (size_t offBuf = 0; offBuf < cbBuf; offBuf += _1K, off += _1K)
     3481            *(uint64_t *)&pbBuf[offBuf] = off;
     3482
     3483        size_t cbToWrite = cbBuf;
     3484        if (cbToWrite > cbLeft)
     3485            cbToWrite = (size_t)cbLeft;
     3486
     3487        RTTESTI_CHECK_RC_RET(RTFileWrite(hFile1, pbBuf, cbToWrite, NULL), VINF_SUCCESS, rcCheck);
     3488        cbLeft -= cbToWrite;
     3489    }
     3490    return VINF_SUCCESS;
     3491}
     3492
    34423493int fsPerfIoPrepFile(RTFILE hFile1, uint64_t cbFile, uint8_t **ppbFree)
    34433494{
     
    34533504     */
    34543505    RTTESTI_CHECK_RC_RET(RTFileSeek(hFile1, 0, RTFILE_SEEK_BEGIN, NULL), VINF_SUCCESS, rcCheck);
    3455     size_t   cbBuf = _1M;
     3506    size_t   cbBuf = RT_MIN(_1M, g_cbMaxBuffer);
    34563507    uint8_t *pbBuf = *ppbFree = (uint8_t *)RTMemAlloc(cbBuf);
    34573508    RTTESTI_CHECK_RET(pbBuf != NULL, VERR_NO_MEMORY);
     
    34733524     * Fill the file with 0xf6 and insert offset markers with 1KB intervals.
    34743525     */
    3475     RTTESTI_CHECK_RC_RET(RTFileSeek(hFile1, 0, RTFILE_SEEK_BEGIN, NULL), VINF_SUCCESS, rcCheck);
    3476     memset(pbBuf, 0xf6, cbBuf);
    3477     cbLeft = cbFile;
    3478     uint64_t off = 0;
    3479     while (cbLeft > 0)
    3480     {
    3481         Assert(!(off   & (_1K - 1)));
    3482         Assert(!(cbBuf & (_1K - 1)));
    3483         for (size_t offBuf = 0; offBuf < cbBuf; offBuf += _1K, off += _1K)
    3484             *(uint64_t *)&pbBuf[offBuf] = off;
    3485 
    3486         size_t cbToWrite = cbBuf;
    3487         if (cbToWrite > cbLeft)
    3488             cbToWrite = (size_t)cbLeft;
    3489 
    3490         RTTESTI_CHECK_RC_RET(RTFileWrite(hFile1, pbBuf, cbToWrite, NULL), VINF_SUCCESS, rcCheck);
    3491 
    3492         cbLeft -= cbToWrite;
    3493     }
    3494 
    3495     return VINF_SUCCESS;
    3496 }
    3497 
     3526    return fsPerfIoPrepFileWorker(hFile1, cbFile, pbBuf, cbBuf);
     3527}
     3528
     3529/**
     3530 * Used in relation to the mmap test when in non-default position.
     3531 */
     3532int fsPerfReinitFile(RTFILE hFile1, uint64_t cbFile)
     3533{
     3534    size_t   cbBuf = RT_MIN(_1M, g_cbMaxBuffer);
     3535    uint8_t *pbBuf = (uint8_t *)RTMemAlloc(cbBuf);
     3536    RTTESTI_CHECK_RET(pbBuf != NULL, VERR_NO_MEMORY);
     3537
     3538    int rc = fsPerfIoPrepFileWorker(hFile1, cbFile, pbBuf, cbBuf);
     3539
     3540    RTMemFree(pbBuf);
     3541    return rc;
     3542}
    34983543
    34993544/**
     
    38493894     */
    38503895    FSPERFSENDFILEARGS Args;
    3851     Args.cbBuf = RT_MIN(cbFileMax, _16M);
     3896    Args.cbBuf = RT_MIN(RT_MIN(cbFileMax, _16M), g_cbMaxBuffer);
    38523897    Args.pbBuf = (uint8_t *)RTMemAlloc(Args.cbBuf);
    38533898    while (!Args.pbBuf)
     
    41064151     */
    41074152    FSPERFSPLICEARGS Args;
    4108     Args.cbBuf = RT_MIN(cbFileMax, _16M);
     4153    Args.cbBuf = RT_MIN(RT_MIN(cbFileMax, _16M), g_cbMaxBuffer);
    41094154    Args.pbBuf = (uint8_t *)RTMemAlloc(Args.cbBuf);
    41104155    while (!Args.pbBuf)
     
    43304375     */
    43314376    FSPERFSPLICEARGS Args;
    4332     Args.cbBuf = RT_MIN(cbFileMax, _16M);
     4377    Args.cbBuf = RT_MIN(RT_MIN(cbFileMax, _16M), g_cbMaxBuffer);
    43334378    Args.pbBuf = (uint8_t *)RTMemAlloc(Args.cbBuf);
    43344379    while (!Args.pbBuf)
     
    45234568     * Allocate a big buffer we can play around with.  Min size is 1MB.
    45244569     */
    4525     size_t   cbBuf = cbFile < _64M ? (size_t)cbFile : _64M;
    4526     uint8_t *pbBuf = (uint8_t *)RTMemPageAlloc(cbBuf);
     4570    size_t   cbMaxBuf = RT_MIN(_64M, g_cbMaxBuffer);
     4571    size_t   cbBuf    = cbFile < cbMaxBuf ? (size_t)cbFile : cbMaxBuf;
     4572    uint8_t *pbBuf    = (uint8_t *)RTMemPageAlloc(cbBuf);
    45274573    while (!pbBuf)
    45284574    {
     
    50145060     * Allocate a big buffer we can play around with.  Min size is 1MB.
    50155061     */
    5016     size_t   cbBuf = cbFile < _64M ? (size_t)cbFile : _64M;
    5017     uint8_t *pbBuf = (uint8_t *)RTMemPageAlloc(cbBuf);
     5062    size_t   cbMaxBuf = RT_MIN(_64M, g_cbMaxBuffer);
     5063    size_t   cbBuf    = cbFile < cbMaxBuf ? (size_t)cbFile : cbMaxBuf;
     5064    uint8_t *pbBuf    = (uint8_t *)RTMemPageAlloc(cbBuf);
    50185065    while (!pbBuf)
    50195066    {
     
    54125459               corruption of shared data during content checking of the RW iterations. */
    54135460            fsPerfFillWriteBuf(0, pbMapping, _2M, 0xf7);
    5414             if (enmState == kMMap_ReadWrite)
     5461            if (enmState == kMMap_ReadWrite && g_fMMapCoherency)
    54155462            {
    54165463                /* For RW we can try read back from the file handle and check if we get
     
    54275474                RTTESTI_CHECK(msync(pbMapping, _2M, MS_SYNC) == 0);
    54285475# endif
    5429 
    5430                 /*
    5431                  * Time modifying and flushing a few different number of pages.
    5432                  */
     5476            }
     5477
     5478            /*
     5479             * Time modifying and flushing a few different number of pages.
     5480             */
     5481            if (enmState == kMMap_ReadWrite)
     5482            {
    54335483                static size_t const s_acbFlush[] = { PAGE_SIZE, PAGE_SIZE * 2, PAGE_SIZE * 3, PAGE_SIZE * 8, PAGE_SIZE * 16, _2M };
    54345484                for (unsigned iFlushSize = 0 ; iFlushSize < RT_ELEMENTS(s_acbFlush); iFlushSize++)
     
    54515501                    if (!g_fIgnoreNoCache || hFileNoCache != NIL_RTFILE)
    54525502                    {
    5453                         size_t   cbBuf = _2M;
     5503                        size_t   cbBuf = RT_MIN(_2M, g_cbMaxBuffer);
    54545504                        uint8_t *pbBuf = (uint8_t *)RTMemPageAlloc(cbBuf);
    54555505                        if (!pbBuf)
     
    55055555         * when not performed thru an no-cache handle.
    55065556         */
    5507         if (enmState == kMMap_ReadOnly || enmState == kMMap_ReadWrite)
    5508         {
    5509             size_t   cbBuf = RT_MIN(_2M, cbMapping / 2);
     5557        if (   (enmState == kMMap_ReadOnly || enmState == kMMap_ReadWrite)
     5558            && g_fMMapCoherency)
     5559        {
     5560            size_t   cbBuf = RT_MIN(RT_MIN(_2M, cbMapping / 2), g_cbMaxBuffer);
    55105561            uint8_t *pbBuf = (uint8_t *)RTMemPageAlloc(cbBuf);
    55115562            if (!pbBuf)
     
    57375788            fsPerfIoSeek(hFile1, cbFile);
    57385789
     5790        if (g_fMMap && g_iMMapPlacement < 0)
     5791        {
     5792            fsPerfMMap(hFile1, hFileNoCache, cbFile);
     5793            fsPerfReinitFile(hFile1, cbFile);
     5794        }
     5795
    57395796        if (g_fReadTests)
    57405797            fsPerfRead(hFile1, hFileNoCache, cbFile);
     
    57505807            fsPerfSpliceToPipe(hFile1, cbFile);
    57515808#endif
    5752         if (g_fMMap)
     5809        if (g_fMMap && g_iMMapPlacement == 0)
    57535810            fsPerfMMap(hFile1, hFileNoCache, cbFile);
    57545811
     
    57655822        if (g_fFSync)
    57665823            fsPerfFSync(hFile1, cbFile);
     5824
     5825        if (g_fMMap && g_iMMapPlacement > 0)
     5826        {
     5827            fsPerfReinitFile(hFile1, cbFile);
     5828            fsPerfMMap(hFile1, hFileNoCache, cbFile);
     5829        }
    57675830    }
    57685831
     
    62326295            case kCmdOpt_ManyTreeSubdirsPerDir: pszHelp = "Count of subdirs per directory in test tree. default: 16"; break;
    62336296            case kCmdOpt_ManyTreeDepth:         pszHelp = "Depth of test tree (not counting root).      default: 1"; break;
     6297#if defined(RT_OS_WINDOWS)
     6298            case kCmdOpt_MaxBufferSize:         pszHelp = "For avoiding the MDL limit on windows.       default: 32MiB"; break;
     6299#else
     6300            case kCmdOpt_MaxBufferSize:         pszHelp = "For avoiding the MDL limit on windows.       default: 0"; break;
     6301#endif
     6302            case kCmdOpt_MMapPlacement:         pszHelp = "When to do mmap testing (caching effects): first, between (default), last "; break;
    62346303            case kCmdOpt_IgnoreNoCache:         pszHelp = "Ignore error wrt no-cache handle.            default: --no-ignore-no-cache"; break;
    62356304            case kCmdOpt_NoIgnoreNoCache:       pszHelp = "Do not ignore error wrt no-cache handle.     default: --no-ignore-no-cache"; break;
     
    63816450                g_fFSync                = true;
    63826451                g_fMMap                 = true;
     6452                g_fMMapCoherency        = true;
    63836453                g_fCopy                 = true;
    63846454                g_fRemote               = true;
     
    64186488                g_fFSync                = false;
    64196489                g_fMMap                 = false;
     6490                g_fMMapCoherency        = false;
    64206491                g_fCopy                 = false;
    64216492                g_fRemote               = false;
     
    64566527            CASE_OPT(FSync);
    64576528            CASE_OPT(MMap);
     6529            CASE_OPT(MMapCoherency);
    64586530            CASE_OPT(IgnoreNoCache);
    64596531            CASE_OPT(Copy);
     
    65026574                RTTestFailed(g_hTest, "Out of range --tree-depth value: %u (%#x)\n", ValueUnion.u32, ValueUnion.u32);
    65036575                return RTTestSummaryAndDestroy(g_hTest);
     6576
     6577            case kCmdOpt_MaxBufferSize:
     6578                if (ValueUnion.u32 >= 4096)
     6579                    g_cbMaxBuffer = ValueUnion.u32;
     6580                else if (ValueUnion.u32 == 0)
     6581                    g_cbMaxBuffer = UINT32_MAX;
     6582                else
     6583                {
     6584                    RTTestFailed(g_hTest, "max buffer size is less than 4KB: %#x\n", ValueUnion.u32);
     6585                    return RTTestSummaryAndDestroy(g_hTest);
     6586                }
     6587                break;
    65046588
    65056589            case kCmdOpt_IoFileSize:
     
    65346618                }
    65356619                return RTTestSummaryAndDestroy(g_hTest);
     6620
     6621            case kCmdOpt_MMapPlacement:
     6622                if (strcmp(ValueUnion.psz, "first") == 0)
     6623                    g_iMMapPlacement = -1;
     6624                else if (   strcmp(ValueUnion.psz, "between") == 0
     6625                         || strcmp(ValueUnion.psz, "default") == 0)
     6626                    g_iMMapPlacement = 0;
     6627                else if (strcmp(ValueUnion.psz, "last") == 0)
     6628                    g_iMMapPlacement = 1;
     6629                else
     6630                {
     6631                    RTTestFailed(g_hTest,
     6632                                 "Invalid --mmap-placment directive '%s'! Expected 'first', 'last', 'between' or 'default'.\n",
     6633                                 ValueUnion.psz);
     6634                    return RTTestSummaryAndDestroy(g_hTest);
     6635                }
     6636                break;
    65366637
    65376638            case 'q':
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