@@ -337,6 +337,12 @@ scheduler_wall_time_test(Type) ->
337337 end .
338338
339339run_scheduler_wall_time_test (Type ) ->
340+ % % All dirty schedulers will be hogged during a period of time
341+ % % during these tests. If the testcase fails during this time, all
342+ % % disc io and large gc will be blocked making the test case
343+ % % timeout instead of failing, i.e., do not add stuff that can
344+ % % fail the test case while all dirty schedulers are hogged...
345+
340346 % % Should return undefined if system_flag is not turned on yet
341347 undefined = statistics (Type ),
342348 % % Turn on statistics
@@ -383,7 +389,7 @@ run_scheduler_wall_time_test(Type) ->
383389 end ,
384390 StartDirtyHog = fun (Func ) ->
385391 F = fun () ->
386- erts_debug :Func (alive_waitexiting ,
392+ erts_debug :Func (alive_waitexitingonly ,
387393 MeMySelfAndI )
388394 end ,
389395 Pid = spawn_link (F ),
@@ -394,8 +400,9 @@ run_scheduler_wall_time_test(Type) ->
394400 % % Max on one, the other schedulers empty (hopefully)
395401 % % Be generous the process can jump between schedulers
396402 % % which is ok and we don't want the test to fail for wrong reasons
397- _L1 = [S1Load |EmptyScheds1 ] = get_load (Type ),
398- {true ,_ } = {S1Load > 50 ,S1Load },
403+ L1 = get_load (Type ),
404+ [High1Load |EmptyScheds1 ] = lists :reverse (lists :sort (L1 )),
405+ {true ,_ } = {High1Load > 50 ,High1Load },
399406 {false ,_ } = {lists :any (fun (Load ) -> Load > 50 end , EmptyScheds1 ),EmptyScheds1 },
400407 {true ,_ } = {lists :sum (EmptyScheds1 ) < 60 ,EmptyScheds1 },
401408
@@ -417,33 +424,33 @@ run_scheduler_wall_time_test(Type) ->
417424 % % 100% load. Need to take into consideration an odd number of
418425 % % schedulers and also special consideration for when there is
419426 % % only 1 scheduler
420- LastHogs = [StartHog () || _ <- lists :seq (1 , (Schedulers + 1 ) div 2 ),
421- Schedulers =/= 1 ],
427+
422428 LastDirtyCPUHogs = [StartDirtyHog (dirty_cpu )
423429 || _ <- lists :seq (1 , (DirtyCPUSchedulers + 1 ) div 2 ),
424430 DirtyCPUSchedulers =/= 1 ],
425431 LastDirtyIOHogs = [StartDirtyHog (dirty_io )
426432 || _ <- lists :seq (1 , (DirtyIOSchedulers + 1 ) div 2 ),
427433 DirtyIOSchedulers =/= 1 ],
434+ LastHogs = [StartHog () || _ <- lists :seq (1 , (Schedulers + 1 ) div 2 ),
435+ Schedulers =/= 1 ],
428436 FullScheds = get_load (Type ),
429437 ct :log (" FullScheds: ~w " ,[FullScheds ]),
438+
439+ AllHogs = [P1 |HalfHogs ++ HalfDirtyCPUHogs ++ HalfDirtyIOHogs
440+ ++ LastHogs ++ LastDirtyCPUHogs ++ LastDirtyIOHogs ],
441+
442+ KillHog = fun (HP ) -> unlink (HP ), exit (HP , kill ) end ,
443+ WaitKilledHog = fun (HP ) -> false = is_process_alive (HP ) end ,
444+ [KillHog (Pid ) || Pid <- AllHogs ],
445+ [WaitKilledHog (Pid ) || Pid <- AllHogs ],
446+ receive after 1000 -> ok end , % % Give dirty schedulers time to complete...
447+
430448 {false ,_ } = {lists :any (fun (Load ) -> Load < 80 end , FullScheds ),FullScheds },
431449 FullLoad = lists :sum (FullScheds ) div TotLoadSchedulers ,
432450 if FullLoad > 90 -> ok ;
433451 true -> exit ({fullload , FullLoad })
434452 end ,
435453
436- KillHog = fun (HP ) ->
437- HPM = erlang :monitor (process , HP ),
438- unlink (HP ),
439- exit (HP , kill ),
440- receive
441- {'DOWN' , HPM , process , HP , killed } ->
442- ok
443- end
444- end ,
445- [KillHog (Pid ) || Pid <- [P1 |HalfHogs ++ HalfDirtyCPUHogs ++ HalfDirtyIOHogs
446- ++ LastHogs ++ LastDirtyCPUHogs ++ LastDirtyIOHogs ]],
447454 receive after 2000 -> ok end , % % Give dirty schedulers time to complete...
448455 AfterLoad = get_load (Type ),
449456 io :format (" AfterLoad=~p~n " , [AfterLoad ]),
@@ -454,12 +461,12 @@ run_scheduler_wall_time_test(Type) ->
454461 end .
455462
456463get_load (Type ) ->
464+ % % Returns info for each *online* scheduler in scheduler id order
457465 Start = erlang :statistics (Type ),
458466 timer :sleep (1500 ),
459467 End = erlang :statistics (Type ),
460468
461- lists :reverse (
462- lists :sort (load_percentage (online_statistics (Start ),online_statistics (End )))).
469+ load_percentage (online_statistics (Start ),online_statistics (End )).
463470
464471% % We are only interested in schedulers that are online to remove all
465472% % offline normal and dirty cpu schedulers (dirty io cannot be offline)
0 commit comments