@@ -198,12 +198,35 @@ static void calc_min_max_cpu(void)
198
198
"Only one usable CPU, task migration not possible" );
199
199
}
200
200
201
+ static void help (const char * name )
202
+ {
203
+ puts ("" );
204
+ printf ("usage: %s [-h] [-u]\n" , name );
205
+ printf (" -u: Don't sanity check the number of successful KVM_RUNs\n" );
206
+ puts ("" );
207
+ exit (0 );
208
+ }
209
+
201
210
int main (int argc , char * argv [])
202
211
{
212
+ bool skip_sanity_check = false;
203
213
int r , i , snapshot ;
204
214
struct kvm_vm * vm ;
205
215
struct kvm_vcpu * vcpu ;
206
216
u32 cpu , rseq_cpu ;
217
+ int opt ;
218
+
219
+ while ((opt = getopt (argc , argv , "hu" )) != -1 ) {
220
+ switch (opt ) {
221
+ case 'u' :
222
+ skip_sanity_check = true;
223
+ break ;
224
+ case 'h' :
225
+ default :
226
+ help (argv [0 ]);
227
+ break ;
228
+ }
229
+ }
207
230
208
231
r = sched_getaffinity (0 , sizeof (possible_mask ), & possible_mask );
209
232
TEST_ASSERT (!r , "sched_getaffinity failed, errno = %d (%s)" , errno ,
@@ -264,9 +287,17 @@ int main(int argc, char *argv[])
264
287
* getcpu() to stabilize. A 2:1 migration:KVM_RUN ratio is a fairly
265
288
* conservative ratio on x86-64, which can do _more_ KVM_RUNs than
266
289
* migrations given the 1us+ delay in the migration task.
290
+ *
291
+ * Another reason why it may have small migration:KVM_RUN ratio is that,
292
+ * on systems with large low power mode wakeup latency, it may happen
293
+ * quite often that the scheduler is not able to wake up the target CPU
294
+ * before the vCPU thread is scheduled to another CPU.
267
295
*/
268
- TEST_ASSERT (i > (NR_TASK_MIGRATIONS / 2 ),
269
- "Only performed %d KVM_RUNs, task stalled too much?" , i );
296
+ TEST_ASSERT (skip_sanity_check || i > (NR_TASK_MIGRATIONS / 2 ),
297
+ "Only performed %d KVM_RUNs, task stalled too much?\n\n"
298
+ " Try disabling deep sleep states to reduce CPU wakeup latency,\n"
299
+ " e.g. via cpuidle.off=1 or setting /dev/cpu_dma_latency to '0',\n"
300
+ " or run with -u to disable this sanity check." , i );
270
301
271
302
pthread_join (migration_thread , NULL );
272
303
0 commit comments