VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/tstIEMN8veProfiling.cpp@ 106842

Last change on this file since 106842 was 106307, checked in by vboxsync, 2 months ago

VMM/IEM: Some more tweaking of the bitmap scanning. bugref:10720

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/* $Id: tstIEMN8veProfiling.cpp 106307 2024-10-14 14:45:58Z vboxsync $ */
2/** @file
3 * PDM Queue Testcase.
4 */
5
6/*
7 * Copyright (C) 2022-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define LOG_GROUP LOG_GROUP_PDM_QUEUE
33#define VBOX_IN_VMM
34
35#include <VBox/vmm/iem.h>
36
37#include <VBox/vmm/vm.h>
38#include <VBox/vmm/uvm.h>
39#include <VBox/vmm/vmm.h>
40#include <VBox/vmm/vmmr3vtable.h>
41
42#include <iprt/errcore.h>
43#include <iprt/assert.h>
44#include <iprt/getopt.h>
45#include <iprt/initterm.h>
46#include <iprt/message.h>
47#include <iprt/stream.h>
48#include <iprt/string.h>
49
50
51/*********************************************************************************************************************************
52* Global Variables *
53*********************************************************************************************************************************/
54static uint32_t g_cMaxTbs = 0;
55static uint64_t g_cbMaxExecMem = 0;
56static PCVMMR3VTABLE g_pVMM = NULL;
57
58
59/**
60 * @callback_method_impl{FNCFGMCONSTRUCTOR}
61 */
62static DECLCALLBACK(int) tstIEMN8veProfilingCfgConstructor(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, void *pvUser)
63{
64 RT_NOREF(pUVM, pvUser);
65 g_pVMM = pVMM;
66
67 /*
68 * Create a default configuration tree.
69 */
70 int rc = pVMM->pfnCFGMR3ConstructDefaultTree(pVM);
71 AssertRCReturn(rc, rc);
72
73 /*
74 * Now for our overrides.
75 */
76 PCFGMNODE const pRoot = pVMM->pfnCFGMR3GetRoot(pVM);
77 PCFGMNODE pIemNode = pVMM->pfnCFGMR3GetChild(pRoot, "IEM");
78 if (!pIemNode)
79 {
80 rc = pVMM->pfnCFGMR3InsertNode(pRoot, "IEM", &pIemNode);
81 if (RT_FAILURE(rc))
82 return RTMsgErrorRc(rc, "CFGMR3InsertNode/IEM failed: %Rrc", rc);
83 }
84
85 if (g_cMaxTbs != 0)
86 {
87 rc = pVMM->pfnCFGMR3InsertInteger(pIemNode, "MaxTbCount", g_cMaxTbs);
88 if (RT_FAILURE(rc))
89 return RTMsgErrorRc(rc, "CFGMR3InsertInteger/MaxTbCount failed: %Rrc", rc);
90 }
91
92 if (g_cbMaxExecMem != 0)
93 {
94 rc = pVMM->pfnCFGMR3InsertInteger(pIemNode, "MaxExecMem", g_cbMaxExecMem);
95 if (RT_FAILURE(rc))
96 return RTMsgErrorRc(rc, "CFGMR3InsertInteger/MaxExecMemaxTbCount failed: %Rrc", rc);
97 }
98
99 return VINF_SUCCESS;
100}
101
102
103
104int main(int argc, char **argv)
105{
106 /*
107 * We run the VMM in driverless mode to avoid needing to hardened the testcase.
108 */
109 RTEXITCODE rcExit;
110 int rc = RTR3InitExe(argc, &argv, SUPR3INIT_F_DRIVERLESS << RTR3INIT_FLAGS_SUPLIB_SHIFT);
111 if (RT_SUCCESS(rc))
112 {
113 /* Don't do anything unless we've been given some input. */
114 if (argc > 1)
115 {
116 /*
117 * Parse arguments.
118 */
119 PVM pVM = NULL;
120 PUVM pUVM = NULL;
121 unsigned cVerbosity = 0;
122 uint32_t cMinTbs = 0;
123 const char *pszStats = NULL;
124 static const RTGETOPTDEF s_aOptions[] =
125 {
126 { "--verbose", 'v', RTGETOPT_REQ_NOTHING },
127 { "--min-tbs", 'm', RTGETOPT_REQ_UINT32 },
128 { "--stats", 's', RTGETOPT_REQ_STRING },
129 { "--max-tb-count", 't', RTGETOPT_REQ_UINT32 },
130 { "--max-exec-mem", 'x', RTGETOPT_REQ_UINT64 },
131 };
132 RTGETOPTSTATE GetState;
133 rc = RTGetOptInit(&GetState, argc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, RTGETOPTINIT_FLAGS_OPTS_FIRST);
134 AssertRC(rc);
135
136 rcExit = RTEXITCODE_SUCCESS;
137 RTGETOPTUNION ValueUnion;
138 while ((rc = RTGetOpt(&GetState, &ValueUnion)))
139 {
140 switch (rc)
141 {
142 case 'm':
143 cMinTbs = ValueUnion.u32;
144 break;
145
146 case 'v':
147 cVerbosity++;
148 break;
149
150 case 'q':
151 cVerbosity = 0;
152 break;
153
154 case 's':
155 pszStats = *ValueUnion.psz ? ValueUnion.psz : NULL;
156 break;
157
158 case 't':
159 g_cMaxTbs = ValueUnion.u32;
160 break;
161
162 case 'x':
163 g_cbMaxExecMem = ValueUnion.u64;
164 break;
165
166 case 'h':
167 RTPrintf("Usage: %Rbn [options] <ThreadedTBsForRecompilerProfiling.sav>\n"
168 "\n"
169 "Options:\n"
170 " --min-tbs=<count>, -m<count>\n"
171 " Duplicate TBs till we have at least the specific count.\n"
172 , argv[0]);
173 return RTEXITCODE_SUCCESS;
174
175 case VINF_GETOPT_NOT_OPTION:
176 /*
177 * Create the VM the first time thru here.
178 */
179 if (!pVM)
180 {
181 rc = VMR3Create(1 /*cCpus*/, NULL, VMCREATE_F_DRIVERLESS, NULL, NULL,
182 tstIEMN8veProfilingCfgConstructor, NULL, &pVM, &pUVM);
183 if (RT_FAILURE(rc))
184 {
185 RTMsgError("VMR3Create failed: %Rrc", rc);
186 return RTEXITCODE_FAILURE;
187 }
188 }
189 rc = g_pVMM->pfnVMR3ReqCallWaitU(pUVM, 0, (PFNRT)IEMR3ThreadedProfileRecompilingSavedTbs,
190 3, pVM, ValueUnion.psz, cMinTbs);
191 if (RT_SUCCESS(rc))
192 {
193 if (pszStats)
194 g_pVMM->pfnSTAMR3Print(pUVM, pszStats);
195 }
196 else
197 rcExit = RTMsgErrorExitFailure("VMR3ReqCallWaitU/IEMR3ThreadedProfileRecompilingSavedTbs failed: %Rrc",
198 rc);
199 break;
200
201 default:
202 return RTGetOptPrintError(rc, &ValueUnion);
203 }
204 }
205 }
206 else
207 {
208 RTMsgInfo("Nothing to do. Try --help.\n");
209 rcExit = RTEXITCODE_SUCCESS;
210 }
211 }
212 else
213 rcExit = RTMsgInitFailure(rc);
214 return rcExit;
215}
216
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette