Commit b2bd3a26 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] set TASK_RUNNING in cond_resched()

do_select() does set_current_state(TASK_INTERRUPTIBLE) then calls
__pollwait() which calls __get_free_page() and the cond_resched() which
I added to the pagecache reclaim code never returns.

The patch makes cond_resched() more useful by setting current->state to
TASK_RUNNING before scheduling.
parent f42e6ed8
...@@ -837,10 +837,11 @@ static inline int need_resched(void) ...@@ -837,10 +837,11 @@ static inline int need_resched(void)
return unlikely(test_thread_flag(TIF_NEED_RESCHED)); return unlikely(test_thread_flag(TIF_NEED_RESCHED));
} }
extern void __cond_resched(void);
static inline void cond_resched(void) static inline void cond_resched(void)
{ {
if (need_resched()) if (need_resched())
schedule(); __cond_resched();
} }
/* Reevaluate whether the task has signals pending delivery. /* Reevaluate whether the task has signals pending delivery.
......
...@@ -473,6 +473,7 @@ EXPORT_SYMBOL(preempt_schedule); ...@@ -473,6 +473,7 @@ EXPORT_SYMBOL(preempt_schedule);
#endif #endif
EXPORT_SYMBOL(schedule_timeout); EXPORT_SYMBOL(schedule_timeout);
EXPORT_SYMBOL(sys_sched_yield); EXPORT_SYMBOL(sys_sched_yield);
EXPORT_SYMBOL(__cond_resched);
EXPORT_SYMBOL(set_user_nice); EXPORT_SYMBOL(set_user_nice);
EXPORT_SYMBOL(task_nice); EXPORT_SYMBOL(task_nice);
EXPORT_SYMBOL_GPL(idle_cpu); EXPORT_SYMBOL_GPL(idle_cpu);
......
...@@ -1447,6 +1447,12 @@ asmlinkage long sys_sched_yield(void) ...@@ -1447,6 +1447,12 @@ asmlinkage long sys_sched_yield(void)
return 0; return 0;
} }
void __cond_resched(void)
{
set_current_state(TASK_RUNNING);
schedule();
}
asmlinkage long sys_sched_get_priority_max(int policy) asmlinkage long sys_sched_get_priority_max(int policy)
{ {
int ret = -EINVAL; int ret = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment