The patch titled cond_resched() fix has been removed from the -mm tree. Its filename is cond_resched-fix.patch This patch was dropped because it was merged into mainline or a subsystem tree ------------------------------------------------------ Subject: cond_resched() fix From: Andrew Morton <akpm@xxxxxxxx> Fix a bug identified by Zou Nan hai <nanhai.zou@xxxxxxxxx>: If the system is in state SYSTEM_BOOTING, and need_resched() is true, cond_resched() returns true even though it didn't reschedule. Consequently need_resched() remains true and JBD locks up. Fix that by teaching cond_resched() to only return true if it really did call schedule(). cond_resched_lock() and cond_resched_softirq() have a problem too. If we're in SYSTEM_BOOTING state and need_resched() is true, these functions will drop the lock and will then try to call schedule(), but the SYSTEM_BOOTING state will prevent schedule() from being called. So on return, need_resched() will still be true, but cond_resched_lock() has to return 1 to tell the caller that the lock was dropped. The caller will probably lock up. Bottom line: if these functions dropped the lock, they _must_ call schedule() to clear need_resched(). Make it so. Also, uninline __cond_resched(). It's largeish, and slowpath. Acked-by: Ingo Molnar <mingo@xxxxxxx> Cc: <stable@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- kernel/sched.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff -puN kernel/sched.c~cond_resched-fix kernel/sched.c --- a/kernel/sched.c~cond_resched-fix +++ a/kernel/sched.c @@ -4386,7 +4386,16 @@ asmlinkage long sys_sched_yield(void) return 0; } -static inline void __cond_resched(void) +static inline int __resched_legal(void) +{ + if (unlikely(preempt_count())) + return 0; + if (unlikely(system_state != SYSTEM_RUNNING)) + return 0; + return 1; +} + +static void __cond_resched(void) { #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP __might_sleep(__FILE__, __LINE__); @@ -4396,10 +4405,6 @@ static inline void __cond_resched(void) * PREEMPT_ACTIVE, which could trigger a second * cond_resched() call. */ - if (unlikely(preempt_count())) - return; - if (unlikely(system_state != SYSTEM_RUNNING)) - return; do { add_preempt_count(PREEMPT_ACTIVE); schedule(); @@ -4409,13 +4414,12 @@ static inline void __cond_resched(void) int __sched cond_resched(void) { - if (need_resched()) { + if (need_resched() && __resched_legal()) { __cond_resched(); return 1; } return 0; } - EXPORT_SYMBOL(cond_resched); /* @@ -4436,7 +4440,7 @@ int cond_resched_lock(spinlock_t *lock) ret = 1; spin_lock(lock); } - if (need_resched()) { + if (need_resched() && __resched_legal()) { _raw_spin_unlock(lock); preempt_enable_no_resched(); __cond_resched(); @@ -4445,14 +4449,13 @@ int cond_resched_lock(spinlock_t *lock) } return ret; } - EXPORT_SYMBOL(cond_resched_lock); int __sched cond_resched_softirq(void) { BUG_ON(!in_softirq()); - if (need_resched()) { + if (need_resched() && __resched_legal()) { __local_bh_enable(); __cond_resched(); local_bh_disable(); @@ -4460,10 +4463,8 @@ int __sched cond_resched_softirq(void) } return 0; } - EXPORT_SYMBOL(cond_resched_softirq); - /** * yield - yield the current processor to other threads. * _ Patches currently in -mm which might be from akpm@xxxxxxxx are origin.patch disable-debugging-version-of-write_lock.patch git-acpi.patch acpi-asus-s3-resume-fix-fix.patch sony_apci-resume.patch kauditd_thread-warning-fix.patch git-geode-fixup.patch git-gfs2.patch git-gfs2-fixup.patch gfs2-get_sb_dev-fix.patch git-ia64.patch revert-sparc-build-breakage.patch git-klibc.patch git-hdrcleanup-vs-git-klibc-on-ia64.patch git-hdrcleanup-vs-git-klibc-on-ia64-2.patch git-libata-all.patch sata-is-bust-on-s390.patch git-netdev-all-fixup.patch forcedeth-typecast-cleanup.patch drivers-net-ns83820c-add-paramter-to-disable-auto.patch af_unix-datagram-getpeersec-fix.patch git-pcmcia-fixup.patch git-sas.patch serial-8250-sysrq-deadlock-fix.patch serial-fix-uart_bug_txen-test.patch revert-gregkh-pci-pci-test-that-drivers-properly-call-pci_set_master.patch revert-VIA-quirk-fixup-additional-PCI-IDs.patch revert-PCI-quirk-VIA-IRQ-fixup-should-only-run-for-VIA-southbridges.patch git-scsi-misc.patch areca-raid-linux-scsi-driver.patch git-scsi-target-fixup.patch pm-usb-hcds-use-pm_event_prethaw-fix.patch git-supertrak-fixup.patch bcm43xx-opencoded-locking.patch zvc-zone_reclaim-leave-1%-of-unmapped-pagecache-pages-for-file-i-o-tunable-rename.patch adix-tree-rcu-lockless-readside-update-tidy.patch mm-tracking-shared-dirty-pages-checks.patch mm-tracking-shared-dirty-pages-wimp.patch acx1xx-wireless-driver.patch tiacx-pci-build-fix.patch tiacx-ia64-fix.patch deprecate-smbfs-in-favour-of-cifs.patch rtc-class-driver-for-samsung-s3c-series-soc-tidy.patch hotcpu_notifier-fixes.patch add-___rodata-sections-to-asm-generic-sectionsh-fix.patch edac-new-opteron-athlon64-memory-controller-driver-tidy.patch reiserfs-on-demand-bitmap-loading-fix.patch per-task-delay-accounting-taskstats-interface-tidy.patch per-task-delay-accounting-proc-export-of-aggregated-block-i-o-delays-warning-fix.patch delay-accounting-taskstats-interface-send-tgid-once-fixes.patch sched-clean-up-fallout-of-recent-changes-fix.patch sched-clean-up-fallout-of-recent-changes-fix-fix-fix.patch swap_prefetch-vs-zoned-counters.patch mark-address_space_operations-const-vs-ecryptfs-mmap-operations.patch ecryptfs-alpha-build-fix.patch ecryptfs-more-elegant-aes-key-size-manipulation-tidy.patch ecryptfs-get_sb_dev-fix.patch namespaces-add-nsproxy-dont-include-compileh.patch namespaces-utsname-switch-to-using-uts-namespaces-alpha-fix.patch namespaces-utsname-use-init_utsname-when-appropriate-cifs-update.patch namespaces-utsname-implement-utsname-namespaces-export.patch namespaces-utsname-implement-utsname-namespaces-dont-include-compileh.patch namespaces-utsname-sysctl-hack-cleanup-2-fix.patch ipc-namespace-core-fix.patch task-watchers-task-watchers-tidy.patch task-watchers-add-support-for-per-task-watchers-warning-fix.patch readahead-sysctl-parameters-fix.patch make-copy_from_user_inatomic-not-zero-the-tail-on-i386-vs-reiser4.patch reiser4-hardirq-include-fix.patch reiser4-run-truncate_inode_pages-in-reiser4_delete_inode.patch reiser4-get_sb_dev-fix.patch reiser4-vs-zoned-allocator.patch hpt3xx-rework-rate-filtering-tidy.patch lockdep-add-disable-enable_irq_lockdep-api.patch lockdep-irqtrace-subsystem-x86_64-support.patch genirq-convert-the-i386-architecture-to-irq-chips-fix-2.patch genirq-msi-simplify-msi-enable-and-disable-fix.patch genirq-i386-irq-remove-the-msi-assumption-that-irq-==-vector-fix-tidies.patch srcu-rcu-variant-permitting-read-side-blocking-fixes.patch srcu-add-srcu-operations-to-rcutorture-fix.patch srcu-2-add-srcu-operations-to-rcutorture-fix.patch make-more-file_operation-structs-static-fix.patch nr_blockdev_pages-in_interrupt-warning.patch device-suspend-debug.patch revert-tty-buffering-comment-out-debug-code.patch slab-leaks3-default-y.patch x86-kmap_atomic-debugging.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html