mm, swap: Remove WARN_ON_ONCE() in free_swap_slot()
PATCH 1/1 mm, swap: Remove WARN_ON_ONCE() in free_swap_slot()
From: Huang Ying <[email protected]>
Before commit 452b94b8c8c7 ("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-g24c534bb161b #1 Hardware name: System manufacturer System Product Name/Z170-K, BIOS 1803 05/06/2016 RIP: 0010:free_swap_slot+0xba/0xd0 Call Trace: swap_free+0x36/0x40 do_swap_page+0x360/0x6d0 __handle_mm_fault+0x880/0x1080 handle_mm_fault+0xd0/0x240 __do_page_fault+0x232/0x4d0 do_page_fault+0x20/0x70 page_fault+0x22/0x30 ---[ 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 452b94b8c8c7, the BUG_ON() is replaced by WARN_ON_ONCE(). In the patch, the WARN_ON_ONCE() is removed too.
--- mm/swap_slots.c | 2 -- 1 file changed, 2 deletions(-)
mm/swap_slots.c +0 -2
@@ -267,8 +267,6 @@ int free_swap_slot(swp_entry_t entry) {struct swap_slots_cache *cache; -WARN_ON_ONCE (!swap_slot_cache_initialized); - cache = &get_cpu_var (swp_slots);if (use_swap_slot_cache && cache->slots_ret) {spin_lock_irq (&cache->free_lock);
Signature · 7 lines
2.11.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 22 lines · Ying
From: Huang Ying <[email protected]>
Before commit
452b94b8c8c7("mm/swap: don'tBUG_ON()due to uninitialized swap slot cache"), the following bug is reported,A ------------[ cut here ]------------ A kernel BUG at mm/swap_slots.c:270! A invalid opcode: 0000 [#1] SMP A CPU: 5 PID: 1745 Comm: (sd-pam) Not tainted 4.11.0-rc1-00243-g24c534bb161b #1 A Hardware name: System manufacturer System Product Name/Z170-K, BIOS1803 05/06/2016
A RIP: 0010:free_swap_slot+0xba/0xd0
A Call Trace:
A A Aswap_free+0x36/0x40
A A Ado_swap_page+0x360/0x6d0
A A A__handle_mm_fault+0x880/0x1080
A A Ahandle_mm_fault+0xd0/0x240
A A A__do_page_fault+0x232/0x4d0
A A Ado_page_fault+0x20/0x70
A A Apage_fault+0x22/0x30
A ---[ end traceaefc9ede53e0ab21]---
Quoted 9 lines
This is raised by the
BUG_ON(!swap_slot_cache_initialized)in free_swap_slot().A A This is incorrect, because even if the swap slots cache fails to be initialized, the swap should operate properly without the swap slots cache.A A And theuse_swap_slot_cachecheck later in the function will protect the uninitialized swap slots cache case.In commit
452b94b8c8c7, theBUG_ON()is replaced byWARN_ON_ONCE(). In the patch, theWARN_ON_ONCE()is removed too.
This replaces my previous patch to replace the BUG_ON.
Quoted 18 lines
Reported-by Linus Torvalds <[email protected]>Cc Tim Chen <[email protected]>Cc Michal Hocko <[email protected]>Signed-off-by "Huang, Ying" <[email protected]>---
Amm/swap_slots.c| 2 --
A 1 file changed, 2 deletions(-)mm/swap_slots.c +0
-0@@ -267,8 +267,6 @@ int free_swap_slot(swp_entry_t entry) A { A struct swap_slots_cache *cache;A
mm/swap_slots.c +0
-2-WARN_ON_ONCE (!swap_slot_cache_initialized); -
Quoted 3 lines
A cache =
&get_cpu_var(swp_slots);
A if (use_swap_slot_cache&&cache->slots_ret) {
Aspin_lock_irq(&cache->free_lock);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>