Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752154AbcCAGn4 (ORCPT ); Tue, 1 Mar 2016 01:43:56 -0500 Received: from mail-ob0-f175.google.com ([209.85.214.175]:36758 "EHLO mail-ob0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590AbcCAGnz (ORCPT ); Tue, 1 Mar 2016 01:43:55 -0500 Date: Mon, 29 Feb 2016 22:43:37 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: "Kirill A. Shutemov" cc: Hugh Dickins , Andrew Morton , "Kirill A. Shutemov" , Joonsoo Kim , Sasha Levin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: __delete_from_page_cache WARN_ON(page_mapped) In-Reply-To: <20160229095216.GA9616@node.shutemov.name> Message-ID: References: <20160229095216.GA9616@node.shutemov.name> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2390 Lines: 58 On Mon, 29 Feb 2016, Kirill A. Shutemov wrote: > On Sun, Feb 28, 2016 at 08:49:10PM -0800, Hugh Dickins wrote: > > Commit e1534ae95004 ("mm: differentiate page_mapped() from page_mapcount() > > for compound pages") changed the famous BUG_ON(page_mapped(page)) in > > __delete_from_page_cache() to VM_BUG_ON_PAGE(page_mapped(page)): which > > gives us more info when CONFIG_DEBUG_VM=y, but nothing at all when not. > > > > Although it has not usually been very helpul, being hit long after the > > error in question, we do need to know if it actually happens on users' > > systems; but reinstating a crash there is likely to be opposed :) > > > > In the non-debug case, use WARN_ON() plus dump_page() and add_taint() - > > I don't really believe LOCKDEP_NOW_UNRELIABLE, but that seems to be the > > standard procedure now. > > So you put here TAINT_WARN plus TAINT_BAD_PAGE. I guess just the second > would be enough. You're right, I hadn't thought about the over-tainting at all: one's enough, yes. > > We can replace WARN_ON() with plain page_mapped(page), plus dump_stack() > below add_taint(). Okay, I'll post another now, but it does remind me why I used WARN_ON(): that was an easy way of printing a standard format, without having to think too much. Now I'm adding a "BUG: Bad page cache" header line to make it fit in with the "Bad page map" and "Bad page state" messages. > > > Move that, or the VM_BUG_ON_PAGE(), up before > > the deletion from tree: so that the unNULLified page->mapping gives a > > little more information. > > > > If the inode is being evicted (rather than truncated), it won't have > > any vmas left, so it's safe(ish) to assume that the raised mapcount is > > erroneous, and we can discount it from page_count to avoid leaking the > > page (I'm less worried by leaking the occasional 4kB, than losing a > > potential 2MB page with each 4kB page leaked). > > > > Signed-off-by: Hugh Dickins > > Otherwise, > > Acked-by: Kirill A. Shutemov Thank you, but since I haven't done it exactly the way you suggest, I won't assume your Ack carries over to the "Bad page cache" version. > > > --- > > I think this should go into v4.5, so I've written it with an atomic_sub > > on page->_count; but Joonsoo will probably want some page_ref thingy. And thanks to Joonsoo for taking it on board. Hugh