Scheduler.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/ScopeGuard.h>
  7. #include <AK/Singleton.h>
  8. #include <AK/Time.h>
  9. #include <Kernel/Arch/x86/InterruptDisabler.h>
  10. #include <Kernel/Debug.h>
  11. #include <Kernel/Panic.h>
  12. #include <Kernel/PerformanceManager.h>
  13. #include <Kernel/Process.h>
  14. #include <Kernel/RTC.h>
  15. #include <Kernel/Scheduler.h>
  16. #include <Kernel/Sections.h>
  17. #include <Kernel/Time/TimeManagement.h>
  18. // Remove this once SMP is stable and can be enabled by default
  19. #define SCHEDULE_ON_ALL_PROCESSORS 0
  20. namespace Kernel {
  21. RecursiveSpinlock g_scheduler_lock;
  22. static u32 time_slice_for(const Thread& thread)
  23. {
  24. // One time slice unit == 4ms (assuming 250 ticks/second)
  25. if (thread.is_idle_thread())
  26. return 1;
  27. return 2;
  28. }
  29. READONLY_AFTER_INIT Thread* g_finalizer;
  30. READONLY_AFTER_INIT WaitQueue* g_finalizer_wait_queue;
  31. Atomic<bool> g_finalizer_has_work { false };
  32. READONLY_AFTER_INIT static Process* s_colonel_process;
  33. struct ThreadReadyQueue {
  34. IntrusiveList<Thread, RawPtr<Thread>, &Thread::m_ready_queue_node> thread_list;
  35. };
  36. struct ThreadReadyQueues {
  37. u32 mask {};
  38. static constexpr size_t count = sizeof(mask) * 8;
  39. Array<ThreadReadyQueue, count> queues;
  40. };
  41. static Singleton<SpinlockProtected<ThreadReadyQueues>> g_ready_queues;
  42. static SpinlockProtected<TotalTimeScheduled> g_total_time_scheduled;
  43. // The Scheduler::current_time function provides a current time for scheduling purposes,
  44. // which may not necessarily relate to wall time
  45. u64 (*Scheduler::current_time)();
  46. static void dump_thread_list(bool = false);
  47. static inline u32 thread_priority_to_priority_index(u32 thread_priority)
  48. {
  49. // Converts the priority in the range of THREAD_PRIORITY_MIN...THREAD_PRIORITY_MAX
  50. // to a index into g_ready_queues where 0 is the highest priority bucket
  51. VERIFY(thread_priority >= THREAD_PRIORITY_MIN && thread_priority <= THREAD_PRIORITY_MAX);
  52. constexpr u32 thread_priority_count = THREAD_PRIORITY_MAX - THREAD_PRIORITY_MIN + 1;
  53. static_assert(thread_priority_count > 0);
  54. auto priority_bucket = ((thread_priority_count - (thread_priority - THREAD_PRIORITY_MIN)) / thread_priority_count) * (ThreadReadyQueues::count - 1);
  55. VERIFY(priority_bucket < ThreadReadyQueues::count);
  56. return priority_bucket;
  57. }
  58. Thread& Scheduler::pull_next_runnable_thread()
  59. {
  60. auto affinity_mask = 1u << Processor::current_id();
  61. return g_ready_queues->with([&](auto& ready_queues) -> Thread& {
  62. auto priority_mask = ready_queues.mask;
  63. while (priority_mask != 0) {
  64. auto priority = __builtin_ffsl(priority_mask);
  65. VERIFY(priority > 0);
  66. auto& ready_queue = ready_queues.queues[--priority];
  67. for (auto& thread : ready_queue.thread_list) {
  68. VERIFY(thread.m_runnable_priority == (int)priority);
  69. if (thread.is_active())
  70. continue;
  71. if (!(thread.affinity() & affinity_mask))
  72. continue;
  73. thread.m_runnable_priority = -1;
  74. ready_queue.thread_list.remove(thread);
  75. if (ready_queue.thread_list.is_empty())
  76. ready_queues.mask &= ~(1u << priority);
  77. // Mark it as active because we are using this thread. This is similar
  78. // to comparing it with Processor::current_thread, but when there are
  79. // multiple processors there's no easy way to check whether the thread
  80. // is actually still needed. This prevents accidental finalization when
  81. // a thread is no longer in Running state, but running on another core.
  82. // We need to mark it active here so that this thread won't be
  83. // scheduled on another core if it were to be queued before actually
  84. // switching to it.
  85. // FIXME: Figure out a better way maybe?
  86. thread.set_active(true);
  87. return thread;
  88. }
  89. priority_mask &= ~(1u << priority);
  90. }
  91. return *Processor::idle_thread();
  92. });
  93. }
  94. Thread* Scheduler::peek_next_runnable_thread()
  95. {
  96. auto affinity_mask = 1u << Processor::current_id();
  97. return g_ready_queues->with([&](auto& ready_queues) -> Thread* {
  98. auto priority_mask = ready_queues.mask;
  99. while (priority_mask != 0) {
  100. auto priority = __builtin_ffsl(priority_mask);
  101. VERIFY(priority > 0);
  102. auto& ready_queue = ready_queues.queues[--priority];
  103. for (auto& thread : ready_queue.thread_list) {
  104. VERIFY(thread.m_runnable_priority == (int)priority);
  105. if (thread.is_active())
  106. continue;
  107. if (!(thread.affinity() & affinity_mask))
  108. continue;
  109. return &thread;
  110. }
  111. priority_mask &= ~(1u << priority);
  112. }
  113. // Unlike in pull_next_runnable_thread() we don't want to fall back to
  114. // the idle thread. We just want to see if we have any other thread ready
  115. // to be scheduled.
  116. return nullptr;
  117. });
  118. }
  119. bool Scheduler::dequeue_runnable_thread(Thread& thread, bool check_affinity)
  120. {
  121. if (thread.is_idle_thread())
  122. return true;
  123. return g_ready_queues->with([&](auto& ready_queues) {
  124. auto priority = thread.m_runnable_priority;
  125. if (priority < 0) {
  126. VERIFY(!thread.m_ready_queue_node.is_in_list());
  127. return false;
  128. }
  129. if (check_affinity && !(thread.affinity() & (1 << Processor::current_id())))
  130. return false;
  131. VERIFY(ready_queues.mask & (1u << priority));
  132. auto& ready_queue = ready_queues.queues[priority];
  133. thread.m_runnable_priority = -1;
  134. ready_queue.thread_list.remove(thread);
  135. if (ready_queue.thread_list.is_empty())
  136. ready_queues.mask &= ~(1u << priority);
  137. return true;
  138. });
  139. }
  140. void Scheduler::enqueue_runnable_thread(Thread& thread)
  141. {
  142. VERIFY(g_scheduler_lock.own_lock());
  143. if (thread.is_idle_thread())
  144. return;
  145. auto priority = thread_priority_to_priority_index(thread.priority());
  146. g_ready_queues->with([&](auto& ready_queues) {
  147. VERIFY(thread.m_runnable_priority < 0);
  148. thread.m_runnable_priority = (int)priority;
  149. VERIFY(!thread.m_ready_queue_node.is_in_list());
  150. auto& ready_queue = ready_queues.queues[priority];
  151. bool was_empty = ready_queue.thread_list.is_empty();
  152. ready_queue.thread_list.append(thread);
  153. if (was_empty)
  154. ready_queues.mask |= (1u << priority);
  155. });
  156. }
  157. UNMAP_AFTER_INIT void Scheduler::start()
  158. {
  159. VERIFY_INTERRUPTS_DISABLED();
  160. // We need to acquire our scheduler lock, which will be released
  161. // by the idle thread once control transferred there
  162. g_scheduler_lock.lock();
  163. auto& processor = Processor::current();
  164. VERIFY(processor.is_initialized());
  165. auto& idle_thread = *Processor::idle_thread();
  166. VERIFY(processor.current_thread() == &idle_thread);
  167. idle_thread.set_ticks_left(time_slice_for(idle_thread));
  168. idle_thread.did_schedule();
  169. idle_thread.set_initialized(true);
  170. processor.init_context(idle_thread, false);
  171. idle_thread.set_state(Thread::Running);
  172. VERIFY(idle_thread.affinity() == (1u << processor.id()));
  173. processor.initialize_context_switching(idle_thread);
  174. VERIFY_NOT_REACHED();
  175. }
  176. bool Scheduler::pick_next()
  177. {
  178. VERIFY_INTERRUPTS_DISABLED();
  179. // Set the in_scheduler flag before acquiring the spinlock. This
  180. // prevents a recursive call into Scheduler::invoke_async upon
  181. // leaving the scheduler lock.
  182. ScopedCritical critical;
  183. Processor::set_current_in_scheduler(true);
  184. ScopeGuard guard(
  185. []() {
  186. // We may be on a different processor after we got switched
  187. // back to this thread!
  188. VERIFY(Processor::current_in_scheduler());
  189. Processor::set_current_in_scheduler(false);
  190. });
  191. SpinlockLocker lock(g_scheduler_lock);
  192. if constexpr (SCHEDULER_RUNNABLE_DEBUG) {
  193. dump_thread_list();
  194. }
  195. auto& thread_to_schedule = pull_next_runnable_thread();
  196. if constexpr (SCHEDULER_DEBUG) {
  197. dbgln("Scheduler[{}]: Switch to {} @ {:#04x}:{:p}",
  198. Processor::current_id(),
  199. thread_to_schedule,
  200. thread_to_schedule.regs().cs, thread_to_schedule.regs().ip());
  201. }
  202. // We need to leave our first critical section before switching context,
  203. // but since we're still holding the scheduler lock we're still in a critical section
  204. critical.leave();
  205. thread_to_schedule.set_ticks_left(time_slice_for(thread_to_schedule));
  206. return context_switch(&thread_to_schedule);
  207. }
  208. bool Scheduler::yield()
  209. {
  210. InterruptDisabler disabler;
  211. auto current_thread = Thread::current();
  212. dbgln_if(SCHEDULER_DEBUG, "Scheduler[{}]: yielding thread {} in_irq={}", Processor::current_id(), *current_thread, Processor::current_in_irq());
  213. VERIFY(current_thread != nullptr);
  214. if (Processor::current_in_irq() || Processor::in_critical()) {
  215. // If we're handling an IRQ we can't switch context, or we're in
  216. // a critical section where we don't want to switch contexts, then
  217. // delay until exiting the trap or critical section
  218. Processor::current().invoke_scheduler_async();
  219. return false;
  220. }
  221. if (!Scheduler::pick_next())
  222. return false;
  223. if constexpr (SCHEDULER_DEBUG)
  224. dbgln("Scheduler[{}]: yield returns to thread {} in_irq={}", Processor::current_id(), *current_thread, Processor::current_in_irq());
  225. return true;
  226. }
  227. bool Scheduler::context_switch(Thread* thread)
  228. {
  229. if (Memory::s_mm_lock.own_lock()) {
  230. PANIC("In context switch while holding Memory::s_mm_lock");
  231. }
  232. thread->did_schedule();
  233. auto from_thread = Thread::current();
  234. if (from_thread == thread)
  235. return false;
  236. if (from_thread) {
  237. // If the last process hasn't blocked (still marked as running),
  238. // mark it as runnable for the next round.
  239. if (from_thread->state() == Thread::Running)
  240. from_thread->set_state(Thread::Runnable);
  241. #ifdef LOG_EVERY_CONTEXT_SWITCH
  242. const auto msg = "Scheduler[{}]: {} -> {} [prio={}] {:#04x}:{:p}";
  243. dbgln(msg,
  244. Processor::current_id(), from_thread->tid().value(),
  245. thread->tid().value(), thread->priority(), thread->regs().cs, thread->regs().ip());
  246. #endif
  247. }
  248. auto& proc = Processor::current();
  249. if (!thread->is_initialized()) {
  250. proc.init_context(*thread, false);
  251. thread->set_initialized(true);
  252. }
  253. thread->set_state(Thread::Running);
  254. PerformanceManager::add_context_switch_perf_event(*from_thread, *thread);
  255. proc.switch_context(from_thread, thread);
  256. // NOTE: from_thread at this point reflects the thread we were
  257. // switched from, and thread reflects Thread::current()
  258. enter_current(*from_thread, false);
  259. VERIFY(thread == Thread::current());
  260. if (thread->process().is_user_process() && thread->previous_mode() != Thread::PreviousMode::KernelMode && thread->current_trap()) {
  261. auto& regs = thread->get_register_dump_from_stack();
  262. auto iopl = get_iopl_from_eflags(regs.flags());
  263. if (iopl != 0) {
  264. PANIC("Switched to thread {} with non-zero IOPL={}", Thread::current()->tid().value(), iopl);
  265. }
  266. }
  267. return true;
  268. }
  269. void Scheduler::enter_current(Thread& prev_thread, bool is_first)
  270. {
  271. VERIFY(g_scheduler_lock.own_lock());
  272. // We already recorded the scheduled time when entering the trap, so this merely accounts for the kernel time since then
  273. auto scheduler_time = Scheduler::current_time();
  274. prev_thread.update_time_scheduled(scheduler_time, true, true);
  275. auto* current_thread = Thread::current();
  276. current_thread->update_time_scheduled(scheduler_time, true, false);
  277. prev_thread.set_active(false);
  278. if (prev_thread.state() == Thread::Dying) {
  279. // If the thread we switched from is marked as dying, then notify
  280. // the finalizer. Note that as soon as we leave the scheduler lock
  281. // the finalizer may free from_thread!
  282. notify_finalizer();
  283. } else if (!is_first) {
  284. // Check if we have any signals we should deliver (even if we don't
  285. // end up switching to another thread).
  286. if (!current_thread->is_in_block() && current_thread->previous_mode() != Thread::PreviousMode::KernelMode && current_thread->current_trap()) {
  287. SpinlockLocker lock(current_thread->get_lock());
  288. if (current_thread->state() == Thread::Running && current_thread->pending_signals_for_state()) {
  289. current_thread->dispatch_one_pending_signal();
  290. }
  291. }
  292. }
  293. }
  294. void Scheduler::leave_on_first_switch(u32 flags)
  295. {
  296. // This is called when a thread is switched into for the first time.
  297. // At this point, enter_current has already be called, but because
  298. // Scheduler::context_switch is not in the call stack we need to
  299. // clean up and release locks manually here
  300. g_scheduler_lock.unlock(flags);
  301. VERIFY(Processor::current_in_scheduler());
  302. Processor::set_current_in_scheduler(false);
  303. }
  304. void Scheduler::prepare_after_exec()
  305. {
  306. // This is called after exec() when doing a context "switch" into
  307. // the new process. This is called from Processor::assume_context
  308. VERIFY(g_scheduler_lock.own_lock());
  309. VERIFY(!Processor::current_in_scheduler());
  310. Processor::set_current_in_scheduler(true);
  311. }
  312. void Scheduler::prepare_for_idle_loop()
  313. {
  314. // This is called when the CPU finished setting up the idle loop
  315. // and is about to run it. We need to acquire he scheduler lock
  316. VERIFY(!g_scheduler_lock.own_lock());
  317. g_scheduler_lock.lock();
  318. VERIFY(!Processor::current_in_scheduler());
  319. Processor::set_current_in_scheduler(true);
  320. }
  321. Process* Scheduler::colonel()
  322. {
  323. VERIFY(s_colonel_process);
  324. return s_colonel_process;
  325. }
  326. static u64 current_time_tsc()
  327. {
  328. return read_tsc();
  329. }
  330. static u64 current_time_monotonic()
  331. {
  332. // We always need a precise timestamp here, we cannot rely on a coarse timestamp
  333. return (u64)TimeManagement::the().monotonic_time(TimePrecision::Precise).to_nanoseconds();
  334. }
  335. UNMAP_AFTER_INIT void Scheduler::initialize()
  336. {
  337. VERIFY(Processor::is_initialized()); // sanity check
  338. // Figure out a good scheduling time source
  339. if (Processor::current().has_feature(CPUFeature::TSC)) {
  340. // TODO: only use if TSC is running at a constant frequency?
  341. current_time = current_time_tsc;
  342. } else {
  343. // TODO: Using HPET is rather slow, can we use any other time source that may be faster?
  344. current_time = current_time_monotonic;
  345. }
  346. RefPtr<Thread> idle_thread;
  347. g_finalizer_wait_queue = new WaitQueue;
  348. g_finalizer_has_work.store(false, AK::MemoryOrder::memory_order_release);
  349. s_colonel_process = Process::create_kernel_process(idle_thread, "colonel", idle_loop, nullptr, 1, Process::RegisterProcess::No).leak_ref();
  350. VERIFY(s_colonel_process);
  351. VERIFY(idle_thread);
  352. idle_thread->set_priority(THREAD_PRIORITY_MIN);
  353. idle_thread->set_name(KString::try_create("idle thread #0"));
  354. set_idle_thread(idle_thread);
  355. }
  356. UNMAP_AFTER_INIT void Scheduler::set_idle_thread(Thread* idle_thread)
  357. {
  358. idle_thread->set_idle_thread();
  359. Processor::current().set_idle_thread(*idle_thread);
  360. Processor::set_current_thread(*idle_thread);
  361. }
  362. UNMAP_AFTER_INIT Thread* Scheduler::create_ap_idle_thread(u32 cpu)
  363. {
  364. VERIFY(cpu != 0);
  365. // This function is called on the bsp, but creates an idle thread for another AP
  366. VERIFY(Processor::is_bootstrap_processor());
  367. VERIFY(s_colonel_process);
  368. Thread* idle_thread = s_colonel_process->create_kernel_thread(idle_loop, nullptr, THREAD_PRIORITY_MIN, KString::try_create(String::formatted("idle thread #{}", cpu)), 1 << cpu, false);
  369. VERIFY(idle_thread);
  370. return idle_thread;
  371. }
  372. void Scheduler::add_time_scheduled(u64 time_to_add, bool is_kernel)
  373. {
  374. g_total_time_scheduled.with([&](auto& total_time_scheduled) {
  375. total_time_scheduled.total += time_to_add;
  376. if (is_kernel)
  377. total_time_scheduled.total_kernel += time_to_add;
  378. });
  379. }
  380. void Scheduler::timer_tick(const RegisterState& regs)
  381. {
  382. VERIFY_INTERRUPTS_DISABLED();
  383. VERIFY(Processor::current_in_irq());
  384. auto current_thread = Processor::current_thread();
  385. if (!current_thread)
  386. return;
  387. // Sanity checks
  388. VERIFY(current_thread->current_trap());
  389. VERIFY(current_thread->current_trap()->regs == &regs);
  390. #if !SCHEDULE_ON_ALL_PROCESSORS
  391. if (!Processor::is_bootstrap_processor())
  392. return; // TODO: This prevents scheduling on other CPUs!
  393. #endif
  394. if (current_thread->process().is_kernel_process()) {
  395. // Because the previous mode when entering/exiting kernel threads never changes
  396. // we never update the time scheduled. So we need to update it manually on the
  397. // timer interrupt
  398. current_thread->update_time_scheduled(current_time(), true, false);
  399. }
  400. if (current_thread->previous_mode() == Thread::PreviousMode::UserMode && current_thread->should_die() && !current_thread->is_blocked()) {
  401. SpinlockLocker scheduler_lock(g_scheduler_lock);
  402. dbgln_if(SCHEDULER_DEBUG, "Scheduler[{}]: Terminating user mode thread {}", Processor::current_id(), *current_thread);
  403. current_thread->set_state(Thread::Dying);
  404. Processor::current().invoke_scheduler_async();
  405. return;
  406. }
  407. if (current_thread->tick())
  408. return;
  409. if (!current_thread->is_idle_thread() && !peek_next_runnable_thread()) {
  410. // If no other thread is ready to be scheduled we don't need to
  411. // switch to the idle thread. Just give the current thread another
  412. // time slice and let it run!
  413. current_thread->set_ticks_left(time_slice_for(*current_thread));
  414. current_thread->did_schedule();
  415. dbgln_if(SCHEDULER_DEBUG, "Scheduler[{}]: No other threads ready, give {} another timeslice", Processor::current_id(), *current_thread);
  416. return;
  417. }
  418. VERIFY_INTERRUPTS_DISABLED();
  419. VERIFY(Processor::current_in_irq());
  420. Processor::current().invoke_scheduler_async();
  421. }
  422. void Scheduler::invoke_async()
  423. {
  424. VERIFY_INTERRUPTS_DISABLED();
  425. VERIFY(!Processor::current_in_irq());
  426. // Since this function is called when leaving critical sections (such
  427. // as a Spinlock), we need to check if we're not already doing this
  428. // to prevent recursion
  429. if (!Processor::current_in_scheduler())
  430. pick_next();
  431. }
  432. void Scheduler::notify_finalizer()
  433. {
  434. if (g_finalizer_has_work.exchange(true, AK::MemoryOrder::memory_order_acq_rel) == false)
  435. g_finalizer_wait_queue->wake_all();
  436. }
  437. void Scheduler::idle_loop(void*)
  438. {
  439. auto& proc = Processor::current();
  440. dbgln("Scheduler[{}]: idle loop running", proc.id());
  441. VERIFY(are_interrupts_enabled());
  442. for (;;) {
  443. proc.idle_begin();
  444. asm("hlt");
  445. proc.idle_end();
  446. VERIFY_INTERRUPTS_ENABLED();
  447. #if SCHEDULE_ON_ALL_PROCESSORS
  448. yield();
  449. #else
  450. if (Processor::current_id() == 0)
  451. yield();
  452. #endif
  453. }
  454. }
  455. void Scheduler::dump_scheduler_state(bool with_stack_traces)
  456. {
  457. dump_thread_list(with_stack_traces);
  458. }
  459. bool Scheduler::is_initialized()
  460. {
  461. // The scheduler is initialized iff the idle thread exists
  462. return Processor::idle_thread() != nullptr;
  463. }
  464. TotalTimeScheduled Scheduler::get_total_time_scheduled()
  465. {
  466. return g_total_time_scheduled.with([&](auto& total_time_scheduled) { return total_time_scheduled; });
  467. }
  468. void dump_thread_list(bool with_stack_traces)
  469. {
  470. dbgln("Scheduler thread list for processor {}:", Processor::current_id());
  471. auto get_cs = [](Thread& thread) -> u16 {
  472. if (!thread.current_trap())
  473. return thread.regs().cs;
  474. return thread.get_register_dump_from_stack().cs;
  475. };
  476. auto get_eip = [](Thread& thread) -> u32 {
  477. if (!thread.current_trap())
  478. return thread.regs().ip();
  479. return thread.get_register_dump_from_stack().ip();
  480. };
  481. Thread::for_each([&](Thread& thread) {
  482. switch (thread.state()) {
  483. case Thread::Dying:
  484. dmesgln(" {:14} {:30} @ {:04x}:{:08x} Finalizable: {}, (nsched: {})",
  485. thread.state_string(),
  486. thread,
  487. get_cs(thread),
  488. get_eip(thread),
  489. thread.is_finalizable(),
  490. thread.times_scheduled());
  491. break;
  492. default:
  493. dmesgln(" {:14} Pr:{:2} {:30} @ {:04x}:{:08x} (nsched: {})",
  494. thread.state_string(),
  495. thread.priority(),
  496. thread,
  497. get_cs(thread),
  498. get_eip(thread),
  499. thread.times_scheduled());
  500. break;
  501. }
  502. if (with_stack_traces)
  503. dbgln("{}", thread.backtrace());
  504. return IterationDecision::Continue;
  505. });
  506. }
  507. }