From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933736AbdCUUmd (ORCPT ); Tue, 21 Mar 2017 16:42:33 -0400 Received: from mga07.intel.com ([134.134.136.100]:39373 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933430AbdCUUmc (ORCPT ); Tue, 21 Mar 2017 16:42:32 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,201,1486454400"; d="scan'208";a="69491895" Message-ID: <1490128938.3567.2.camel@linux.intel.com> Subject: Re: [PATCH] mm, swap: Remove WARN_ON_ONCE() in free_swap_slot() From: Tim Chen To: "Huang, Ying" , Linus Torvalds Cc: Andrew Morton , Dave Hansen , Shaohua Li , Rik van Riel , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Tue, 21 Mar 2017 16:42:18 -0400 In-Reply-To: <20170320062657.26683-1-ying.huang@intel.com> References: <20170320062657.26683-1-ying.huang@intel.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2 (3.18.5.2-1.fc23) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-03-20 at 14:26 +0800, Huang, Ying wrote: > From: Huang Ying > > 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. > This replaces my previous patch to replace the BUG_ON. Acked-by: Tim Chen > Reported-by: Linus Torvalds > Cc: Tim Chen > Cc: Michal Hocko > Signed-off-by: "Huang, Ying" > --- >  mm/swap_slots.c | 2 -- >  1 file changed, 2 deletions(-) > > diff --git a/mm/swap_slots.c b/mm/swap_slots.c > index 7ebb23836f68..b1ccb58ad397 100644 > --- a/mm/swap_slots.c > +++ b/mm/swap_slots.c > @@ -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);