Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753079Ab2JZCPT (ORCPT ); Thu, 25 Oct 2012 22:15:19 -0400 Received: from mail-ia0-f174.google.com ([209.85.210.174]:49338 "EHLO mail-ia0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751165Ab2JZCPR (ORCPT ); Thu, 25 Oct 2012 22:15:17 -0400 Message-ID: <5089F22D.70007@gmail.com> Date: Fri, 26 Oct 2012 10:15:09 +0800 From: Ni zhan Chen User-Agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1 MIME-Version: 1.0 To: Hugh Dickins CC: Johannes Weiner , Dave Jones , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: shmem_getpage_gfp VM_BUG_ON triggered. [3.7rc2] References: <20121025023738.GA27001@redhat.com> <20121025205213.GB4771@cmpxchg.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2986 Lines: 67 On 10/26/2012 05:48 AM, Hugh Dickins wrote: > On Thu, 25 Oct 2012, Johannes Weiner wrote: >> On Wed, Oct 24, 2012 at 09:36:27PM -0700, Hugh Dickins wrote: >>> On Wed, 24 Oct 2012, Dave Jones wrote: >>> >>>> Machine under significant load (4gb memory used, swap usage fluctuating) >>>> triggered this... >>>> >>>> WARNING: at mm/shmem.c:1151 shmem_getpage_gfp+0xa5c/0xa70() >>>> Pid: 29795, comm: trinity-child4 Not tainted 3.7.0-rc2+ #49 >>>> >>>> 1148 error = shmem_add_to_page_cache(page, mapping, index, >>>> 1149 gfp, swp_to_radix_entry(swap)); >>>> 1150 /* We already confirmed swap, and make no allocation */ >>>> 1151 VM_BUG_ON(error); >>>> 1152 } >>> That's very surprising. Easy enough to handle an error there, but >>> of course I made it a VM_BUG_ON because it violates my assumptions: >>> I rather need to understand how this can be, and I've no idea. >> Could it be concurrent truncation clearing out the entry between >> shmem_confirm_swap() and shmem_add_to_page_cache()? I don't see >> anything preventing that. >> >> The empty slot would not match the expected swap entry this call >> passes in and the returned error would be -ENOENT. > Excellent notion, many thanks Hannes, I believe you've got it. > > I've hit that truncation problem in swapoff (and commented on it > in shmem_unuse_inode), but never hit it or considered it here. > I think of the page lock as holding it stable, but truncation's > free_swap_and_cache only does a trylock on the swapcache page, > so we're not secured against that possibility. Hi Hugh, Even though free_swap_and_cache only does a trylock on the swapcache page, but it doens't call delete_from_swap_cache and the associated entry should still be there, I am interested in what you have already introduce to protect it? > > So I'd like to change it to VM_BUG_ON(error && error != -ENOENT), > but there's a little tidying up to do in the -ENOENT case, which Do you mean radix_tree_insert will return -ENOENT if the associated entry is not present? Why I can't find this return value in the function radix_tree_insert? > needs more thought. A delete_from_swap_cache(page) - though we > can be lazy and leave that to reclaim for such a rare occurrence - > and probably a mem_cgroup uncharge; but the memcg hooks are always > the hardest to get right, I'll have think about that one carefully. > > Hugh > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/