User: | Jiri Slaby |
Error type: | Leaving function in locked state |
Error type description: | Some lock is not unlocked on all paths of a function, so it is leaked |
File location: | kernel/sched.c |
Line in file: | 5630 |
Project: | Linux Kernel |
Project version: | 2.6.28 |
Tools: |
Stanse
(1.2)
|
Entered: | 2012-05-21 20:30:05 UTC |
5600 * This works OK both with and without CONFIG_PREEMPT. We do strange low-level 5601 * operations here to prevent schedule() from being called twice (once via 5602 * spin_unlock(), once by hand). 5603 */ 5604int cond_resched_lock(spinlock_t *lock) 5605{ 5606 int resched = need_resched() && system_state == SYSTEM_RUNNING; 5607 int ret = 0; 5608 5609 if (spin_needbreak(lock) || resched) { 5610 spin_unlock(lock); 5611 if (resched && need_resched()) 5612 __cond_resched(); 5613 else 5614 cpu_relax(); 5615 ret = 1; 5616 spin_lock(lock); 5617 } 5618 return ret; 5619} 5620EXPORT_SYMBOL(cond_resched_lock); 5621 5622int __sched cond_resched_softirq(void) 5623{ 5624 BUG_ON(!in_softirq()); 5625 5626 if (need_resched() && system_state == SYSTEM_RUNNING) { 5627 local_bh_enable(); 5628 __cond_resched(); 5629 local_bh_disable(); 5630 return 1; 5631 } 5632 return 0; 5633} 5634EXPORT_SYMBOL(cond_resched_softirq); 5635 5636/** 5637 * yield - yield the current processor to other threads. 5638 * 5639 * This is a shortcut for kernel-space yielding - it marks the 5640 * thread runnable and calls sys_sched_yield().