- 论坛徽章:
- 0
|
bdi_forker_thread 函数里
428 /*
429 * If there is no work to do and the bdi thread was
430 * inactive long enough - kill it. The wb_lock is taken
431 * to make sure no-one adds more work to this bdi and
432 * wakes the bdi thread up.
433 */
434 if (bdi->wb.task && !have_dirty_io && --->还没有脏页需要flush
435 time_after(jiffies, bdi->wb.last_active +
436 bdi_longest_inactive())) {
437 task = bdi->wb.task; ---> 这时刚好有脏页需要fush 到硬盘 ---> 别的地方唤醒wb.task 进程。
438 bdi->wb.task = NULL; ---> 这时清空, 使得进入try_to_wake_up函数里的p 为空指针
439 spin_unlock(&bdi->wb_lock);
440 set_bit(BDI_pending, &bdi->state);
441 action = KILL_THREAD;
442 break;
443 }
2839 static int
2840 try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) 这里的p 为 bdi->wb.task
2841 {
2842 unsigned long flags;
2843 int cpu, success = 0;
2844
2845 smp_wmb();
2846 raw_spin_lock_irqsave(&p->pi_lock, flags);
2847 if (!(p->state & state))
2848 goto out;
2849
2850 success = 1; /* we're going to change ->state */
2851 cpu = task_cpu(p);
2852
2853 if (p->on_rq && ttwu_remote(p, wake_flags))
2854 goto stat;
2855
|
|