14
14
#error SMP test requires at least two CPUs!
15
15
#endif
16
16
17
+ /*
18
+ * The test is designed to work with no more than 12 CPUs.
19
+ * If attempting to run on a platform with more than that,
20
+ * create a custom board overlay file to reduce the number
21
+ * of CPUs to 12.
22
+ */
23
+ #if CONFIG_MP_MAX_NUM_CPUS > 12
24
+ #error "Test only supports up to 12 CPUs\nReduce CONFIG_MP_MAX_NUM_CPUS\n"
25
+ #endif
26
+
17
27
#define RUN_FACTOR (CONFIG_SMP_TEST_RUN_FACTOR / 100.0)
18
28
19
29
#define T2_STACK_SIZE (2048 + CONFIG_TEST_EXTRA_STACK_SIZE)
20
30
#define STACK_SIZE (384 + CONFIG_TEST_EXTRA_STACK_SIZE)
21
31
#define DELAY_US 50000
22
- #define TIMEOUT 1000
32
+ #define TIMEOUT 5000
23
33
#define EQUAL_PRIORITY 1
24
34
#define TIME_SLICE_MS 500
25
35
#define THREAD_DELAY 1
@@ -372,11 +382,11 @@ ZTEST(smp, test_coop_resched_threads)
372
382
* since we don't give up current CPU, last thread
373
383
* will not get scheduled
374
384
*/
375
- spawn_threads (K_PRIO_COOP (10 ), num_threads , !EQUAL_PRIORITY ,
385
+ spawn_threads (K_PRIO_COOP (12 ), num_threads , !EQUAL_PRIORITY ,
376
386
& thread_entry_fn , THREAD_DELAY );
377
387
378
388
/* Wait for some time to let other core's thread run */
379
- k_busy_wait (DELAY_US );
389
+ k_busy_wait (DELAY_US * 5 );
380
390
381
391
382
392
/* Reassure that cooperative thread's are not preempted
@@ -413,7 +423,7 @@ ZTEST(smp, test_preempt_resched_threads)
413
423
* lower priority thread should
414
424
* be preempted by higher ones
415
425
*/
416
- spawn_threads (K_PRIO_PREEMPT (10 ), num_threads , !EQUAL_PRIORITY ,
426
+ spawn_threads (K_PRIO_PREEMPT (12 ), num_threads , !EQUAL_PRIORITY ,
417
427
& thread_entry_fn , THREAD_DELAY );
418
428
419
429
spin_for_threads_exit ();
@@ -446,11 +456,11 @@ ZTEST(smp, test_yield_threads)
446
456
* of cores, so the last thread would be
447
457
* pending.
448
458
*/
449
- spawn_threads (K_PRIO_COOP (10 ), num_threads , !EQUAL_PRIORITY ,
459
+ spawn_threads (K_PRIO_COOP (12 ), num_threads , !EQUAL_PRIORITY ,
450
460
& thread_entry_fn , !THREAD_DELAY );
451
461
452
462
k_yield ();
453
- k_busy_wait (DELAY_US );
463
+ k_busy_wait (DELAY_US * 5 );
454
464
455
465
for (int i = 0 ; i < num_threads ; i ++ ) {
456
466
zassert_true (tinfo [i ].executed == 1 ,
@@ -475,7 +485,7 @@ ZTEST(smp, test_sleep_threads)
475
485
{
476
486
unsigned int num_threads = arch_num_cpus ();
477
487
478
- spawn_threads (K_PRIO_COOP (10 ), num_threads , !EQUAL_PRIORITY ,
488
+ spawn_threads (K_PRIO_COOP (12 ), num_threads , !EQUAL_PRIORITY ,
479
489
& thread_entry_fn , !THREAD_DELAY );
480
490
481
491
k_msleep (TIMEOUT );
@@ -533,7 +543,7 @@ static void check_wokeup_threads(int tnum)
533
543
/* k_wakeup() isn't synchronous, give the other CPU time to
534
544
* schedule them
535
545
*/
536
- k_busy_wait (200000 );
546
+ k_busy_wait (300000 );
537
547
538
548
for (i = 0 ; i < tnum ; i ++ ) {
539
549
if (tinfo [i ].executed == 1 && threads_woke_up <= tnum ) {
@@ -558,7 +568,7 @@ ZTEST(smp, test_wakeup_threads)
558
568
unsigned int num_threads = arch_num_cpus ();
559
569
560
570
/* Spawn threads to run on all remaining cores */
561
- spawn_threads (K_PRIO_COOP (10 ), num_threads - 1 , !EQUAL_PRIORITY ,
571
+ spawn_threads (K_PRIO_COOP (12 ), num_threads - 1 , !EQUAL_PRIORITY ,
562
572
& thread_wakeup_entry , !THREAD_DELAY );
563
573
564
574
/* Check if all the threads have started, then call wakeup */
0 commit comments