Commit 093b995e authored by Huang Ying's avatar Huang Ying Committed by Linus Torvalds

mm, swap: Remove WARN_ON_ONCE() in free_swap_slot()

Before commit 452b94b8 ("mm/swap: don't BUG_ON() due to
uninitialized swap slot cache"), the following bug is reported,

  ------------[ cut here ]------------
  kernel BUG at mm/swap_slots.c:270!
  invalid opcode: 0000 [#1] SMP
  CPU: 5 PID: 1745 Comm: (sd-pam) Not tainted 4.11.0-rc1-00243-g24c534bb #1
  Hardware name: System manufacturer System Product Name/Z170-K, BIOS 1803 05/06/2016
  RIP: 0010:free_swap_slot+0xba/0xd0
  Call Trace:
  ---[ end trace aefc9ede53e0ab21 ]---

This is raised by the BUG_ON(!swap_slot_cache_initialized) in
free_swap_slot().  This is incorrect, because even if the swap slots
cache fails to be initialized, the swap should operate properly without
the swap slots cache.  And the use_swap_slot_cache check later in the
function will protect the uninitialized swap slots cache case.

In commit 452b94b8, the BUG_ON() is replaced by WARN_ON_ONCE().  In
the patch, the WARN_ON_ONCE() is removed too.
Reported-by: default avatarLinus Torvalds <>
Acked-by: Tim Chen's avatarTim Chen <>
Cc: Michal Hocko <>
Signed-off-by: default avatar"Huang, Ying" <>
Signed-off-by: default avatarLinus Torvalds <>
parent 1f020713
......@@ -267,8 +267,6 @@ int free_swap_slot(swp_entry_t entry)
struct swap_slots_cache *cache;
cache = &get_cpu_var(swp_slots);
if (use_swap_slot_cache && cache->slots_ret) {
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