Revision d1908362ae0b97374eb8328fbb471576332f9fb1 authored by Minchan Kim on 22 September 2010, 20:05:01 UTC, committed by Linus Torvalds on 23 September 2010, 00:22:39 UTC
M.  Vefa Bicakci reported 2.6.35 kernel hang up when hibernation on his
32bit 3GB mem machine.
(https://bugzilla.kernel.org/show_bug.cgi?id=16771). Also he bisected
the regression to

  commit bb21c7ce18eff8e6e7877ca1d06c6db719376e3c
  Author: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
  Date:   Fri Jun 4 14:15:05 2010 -0700

     vmscan: fix do_try_to_free_pages() return value when priority==0 reclaim failure

At first impression, this seemed very strange because the above commit
only chenged function return value and hibernate_preallocate_memory()
ignore return value of shrink_all_memory().  But it's related.

Now, page allocation from hibernation code may enter infinite loop if the
system has highmem.  The reasons are that vmscan don't care enough OOM
case when oom_killer_disabled.

The problem sequence is following as.

1. hibernation
2. oom_disable
3. alloc_pages
4. do_try_to_free_pages
       if (scanning_global_lru(sc) && !all_unreclaimable)
               return 1;

If kswapd is not freozen, it would set zone->all_unreclaimable to 1 and
then shrink_zones maybe return true(ie, all_unreclaimable is true).  So at
last, alloc_pages could go to _nopage_.  If it is, it should have no
problem.

This patch adds all_unreclaimable check to protect in direct reclaim path,
too.  It can care of hibernation OOM case and help bailout
all_unreclaimable case slightly.

Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Minchan Kim <minchan.kim@gmail.com>
Reported-by: M. Vefa Bicakci <bicave@superonline.com>
Reported-by: <caiqian@redhat.com>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Tested-by: <caiqian@redhat.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Rik van Riel <riel@redhat.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent eba93fc
Raw File
Kconfig.locks
#
# The ARCH_INLINE foo is necessary because select ignores "depends on"
#
config ARCH_INLINE_SPIN_TRYLOCK
	bool

config ARCH_INLINE_SPIN_TRYLOCK_BH
	bool

config ARCH_INLINE_SPIN_LOCK
	bool

config ARCH_INLINE_SPIN_LOCK_BH
	bool

config ARCH_INLINE_SPIN_LOCK_IRQ
	bool

config ARCH_INLINE_SPIN_LOCK_IRQSAVE
	bool

config ARCH_INLINE_SPIN_UNLOCK
	bool

config ARCH_INLINE_SPIN_UNLOCK_BH
	bool

config ARCH_INLINE_SPIN_UNLOCK_IRQ
	bool

config ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE
	bool


config ARCH_INLINE_READ_TRYLOCK
	bool

config ARCH_INLINE_READ_LOCK
	bool

config ARCH_INLINE_READ_LOCK_BH
	bool

config ARCH_INLINE_READ_LOCK_IRQ
	bool

config ARCH_INLINE_READ_LOCK_IRQSAVE
	bool

config ARCH_INLINE_READ_UNLOCK
	bool

config ARCH_INLINE_READ_UNLOCK_BH
	bool

config ARCH_INLINE_READ_UNLOCK_IRQ
	bool

config ARCH_INLINE_READ_UNLOCK_IRQRESTORE
	bool


config ARCH_INLINE_WRITE_TRYLOCK
	bool

config ARCH_INLINE_WRITE_LOCK
	bool

config ARCH_INLINE_WRITE_LOCK_BH
	bool

config ARCH_INLINE_WRITE_LOCK_IRQ
	bool

config ARCH_INLINE_WRITE_LOCK_IRQSAVE
	bool

config ARCH_INLINE_WRITE_UNLOCK
	bool

config ARCH_INLINE_WRITE_UNLOCK_BH
	bool

config ARCH_INLINE_WRITE_UNLOCK_IRQ
	bool

config ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
	bool

#
# lock_* functions are inlined when:
#   - DEBUG_SPINLOCK=n and GENERIC_LOCKBREAK=n and ARCH_INLINE_*LOCK=y
#
# trylock_* functions are inlined when:
#   - DEBUG_SPINLOCK=n and ARCH_INLINE_*LOCK=y
#
# unlock and unlock_irq functions are inlined when:
#   - DEBUG_SPINLOCK=n and ARCH_INLINE_*LOCK=y
#  or
#   - DEBUG_SPINLOCK=n and PREEMPT=n
#
# unlock_bh and unlock_irqrestore functions are inlined when:
#   - DEBUG_SPINLOCK=n and ARCH_INLINE_*LOCK=y
#

config INLINE_SPIN_TRYLOCK
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_TRYLOCK

config INLINE_SPIN_TRYLOCK_BH
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_TRYLOCK_BH

config INLINE_SPIN_LOCK
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && ARCH_INLINE_SPIN_LOCK

config INLINE_SPIN_LOCK_BH
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_SPIN_LOCK_BH

config INLINE_SPIN_LOCK_IRQ
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_SPIN_LOCK_IRQ

config INLINE_SPIN_LOCK_IRQSAVE
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_SPIN_LOCK_IRQSAVE

config INLINE_SPIN_UNLOCK
	def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_SPIN_UNLOCK)

config INLINE_SPIN_UNLOCK_BH
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_UNLOCK_BH

config INLINE_SPIN_UNLOCK_IRQ
	def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_SPIN_UNLOCK_BH)

config INLINE_SPIN_UNLOCK_IRQRESTORE
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE


config INLINE_READ_TRYLOCK
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_TRYLOCK

config INLINE_READ_LOCK
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && ARCH_INLINE_READ_LOCK

config INLINE_READ_LOCK_BH
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_READ_LOCK_BH

config INLINE_READ_LOCK_IRQ
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_READ_LOCK_IRQ

config INLINE_READ_LOCK_IRQSAVE
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_READ_LOCK_IRQSAVE

config INLINE_READ_UNLOCK
	def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_READ_UNLOCK)

config INLINE_READ_UNLOCK_BH
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_UNLOCK_BH

config INLINE_READ_UNLOCK_IRQ
	def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_READ_UNLOCK_BH)

config INLINE_READ_UNLOCK_IRQRESTORE
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_READ_UNLOCK_IRQRESTORE


config INLINE_WRITE_TRYLOCK
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_WRITE_TRYLOCK

config INLINE_WRITE_LOCK
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && ARCH_INLINE_WRITE_LOCK

config INLINE_WRITE_LOCK_BH
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_WRITE_LOCK_BH

config INLINE_WRITE_LOCK_IRQ
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_WRITE_LOCK_IRQ

config INLINE_WRITE_LOCK_IRQSAVE
	def_bool !DEBUG_SPINLOCK && !GENERIC_LOCKBREAK && \
		 ARCH_INLINE_WRITE_LOCK_IRQSAVE

config INLINE_WRITE_UNLOCK
	def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_WRITE_UNLOCK)

config INLINE_WRITE_UNLOCK_BH
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_WRITE_UNLOCK_BH

config INLINE_WRITE_UNLOCK_IRQ
	def_bool !DEBUG_SPINLOCK && (!PREEMPT || ARCH_INLINE_WRITE_UNLOCK_BH)

config INLINE_WRITE_UNLOCK_IRQRESTORE
	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE

config MUTEX_SPIN_ON_OWNER
	def_bool SMP && !DEBUG_MUTEXES && !HAVE_DEFAULT_NO_SPIN_MUTEXES
back to top