Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp659133pxv; Fri, 9 Jul 2021 06:21:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkbjAhJd3sYsL8jgvoPjfFazN+de0ym34t1JZn/gZdlgDV4IW+b3N2g/Ejm61GA85As292 X-Received: by 2002:a02:2382:: with SMTP id u124mr10608344jau.138.1625836912300; Fri, 09 Jul 2021 06:21:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625836912; cv=none; d=google.com; s=arc-20160816; b=xWAcncJ4FhxR1sanKrfxhHLTOom4wDDnGb144KKGzMwrbHD3TboWpqsnXjSl6F5q5C ljyoiD/cZJWs+UlWItOT/5x+0m1FayqU53O93Oh9/4P0IyZ7J0YvjZHrJcvceTdA2tS8 XYkQ1skMEjlECjaJ9zfUJHvTGJ9ztXeiaRryvoL/4unqB0IUi2a9lLFv/aB0lCw8SeBk cY5Ie7qvhDVStM80YdASy4XlYhWkxVCHnGuLbMg5t+rrPRtARTe7f2Qj9NV73SAWdQsq 4DYvZWjdZHq0OzUW7Oqq2mvAVrn1ZIgXnlm1M5atBGpqIWkAIO8hEnARmgBzUCahVlM6 oC3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wxg9duIhvs8ueXBOrcjnNPyrjDJkMyrQisUTgufDgtE=; b=CtWDxWhb4fZPV5xTZgYIkV0Kr4u9ee/rPal+Ny+MhsCCYARe17rhZ/InzSafrVqb84 +nBk1QZ9mbgJKpCve7U9AuIP5RsTcoOhXT3Lsuie/5/nldImqzEyl8em1T8QjirWj3tF Xn/9AQLSftIIb3OmRbznZJCu4S0C1IJ0QPzHeDy5uPECdOSm6cbHV8f2lc+XPP7iN4Tn ncfmyaecNZOuds+ocN2Lmorsrs+Q5tT+SdS775mSZuzVwAKqISW5oezLRKatrBUZgYrM ZixTXYZP20TvpOcKBHFJAJv+7QUiE3dPjzB3rh3IxDuRymK3KguKiz04DNYRDX5aIDwj Af8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MdVLAewM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si6933799ilc.129.2021.07.09.06.21.40; Fri, 09 Jul 2021 06:21:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MdVLAewM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232228AbhGINWP (ORCPT + 99 others); Fri, 9 Jul 2021 09:22:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:52498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231605AbhGINWH (ORCPT ); Fri, 9 Jul 2021 09:22:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D134613BC; Fri, 9 Jul 2021 13:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625836763; bh=9mmBXJAnuL45EjK73Ph5Tb8Ht2zMq3a3Jkp3+nOqYGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MdVLAewMCtzqostPIGHFXq8owmwAZ5/WoZfCoMK3TVuC8m8dWHVPWVrkBQcPx5o51 bPZezmUSdjUf33TXTnT/2dWhFtSQZM8yngrjVurgKpZwvQfAv/6fst/g8J1so96P2N U2fSfCxJvpHTLIODha6oJMiB41I5YUcNLksBcXos= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Shi , Zi Yan , "Kirill A. Shutemov" , Hugh Dickins , Alistair Popple , Jan Kara , Jue Wang , "Matthew Wilcox (Oracle)" , Miaohe Lin , Minchan Kim , Naoya Horiguchi , Oscar Salvador , Peter Xu , Ralph Campbell , Shakeel Butt , Wang Yugui , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 08/25] mm: thp: replace DEBUG_VM BUG with VM_WARN when unmap fails for split Date: Fri, 9 Jul 2021 15:18:39 +0200 Message-Id: <20210709131632.916418953@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210709131627.928131764@linuxfoundation.org> References: <20210709131627.928131764@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Shi [ Upstream commit 504e070dc08f757bccaed6d05c0f53ecbfac8a23 ] When debugging the bug reported by Wang Yugui [1], try_to_unmap() may fail, but the first VM_BUG_ON_PAGE() just checks page_mapcount() however it may miss the failure when head page is unmapped but other subpage is mapped. Then the second DEBUG_VM BUG() that check total mapcount would catch it. This may incur some confusion. As this is not a fatal issue, so consolidate the two DEBUG_VM checks into one VM_WARN_ON_ONCE_PAGE(). [1] https://lore.kernel.org/linux-mm/20210412180659.B9E3.409509F4@e16-tech.com/ Link: https://lkml.kernel.org/r/d0f0db68-98b8-ebfb-16dc-f29df24cf012@google.com Signed-off-by: Yang Shi Reviewed-by: Zi Yan Acked-by: Kirill A. Shutemov Signed-off-by: Hugh Dickins Cc: Alistair Popple Cc: Jan Kara Cc: Jue Wang Cc: "Matthew Wilcox (Oracle)" Cc: Miaohe Lin Cc: Minchan Kim Cc: Naoya Horiguchi Cc: Oscar Salvador Cc: Peter Xu Cc: Ralph Campbell Cc: Shakeel Butt Cc: Wang Yugui Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Note on stable backport: fixed up variables, split_queue_lock, tree_lock in split_huge_page_to_list(), and conflict on ttu_flags in unmap_page(). Signed-off-by: Hugh Dickins Signed-off-by: Sasha Levin --- mm/huge_memory.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 5705ccff3e7f..972893908bcd 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2325,15 +2325,15 @@ static void unmap_page(struct page *page) { enum ttu_flags ttu_flags = TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS | TTU_RMAP_LOCKED | TTU_SPLIT_HUGE_PMD | TTU_SYNC; - bool unmap_success; VM_BUG_ON_PAGE(!PageHead(page), page); if (PageAnon(page)) ttu_flags |= TTU_SPLIT_FREEZE; - unmap_success = try_to_unmap(page, ttu_flags); - VM_BUG_ON_PAGE(!unmap_success, page); + try_to_unmap(page, ttu_flags); + + VM_WARN_ON_ONCE_PAGE(page_mapped(page), page); } static void remap_page(struct page *page) @@ -2586,7 +2586,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) struct pglist_data *pgdata = NODE_DATA(page_to_nid(head)); struct anon_vma *anon_vma = NULL; struct address_space *mapping = NULL; - int count, mapcount, extra_pins, ret; + int extra_pins, ret; bool mlocked; unsigned long flags; pgoff_t end; @@ -2648,7 +2648,6 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) mlocked = PageMlocked(page); unmap_page(head); - VM_BUG_ON_PAGE(compound_mapcount(head), head); /* Make sure the page is not on per-CPU pagevec as it takes pin */ if (mlocked) @@ -2674,9 +2673,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) /* Prevent deferred_split_scan() touching ->_refcount */ spin_lock(&pgdata->split_queue_lock); - count = page_count(head); - mapcount = total_mapcount(head); - if (!mapcount && page_ref_freeze(head, 1 + extra_pins)) { + if (page_ref_freeze(head, 1 + extra_pins)) { if (!list_empty(page_deferred_list(head))) { pgdata->split_queue_len--; list_del(page_deferred_list(head)); @@ -2692,16 +2689,9 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) } else ret = 0; } else { - if (IS_ENABLED(CONFIG_DEBUG_VM) && mapcount) { - pr_alert("total_mapcount: %u, page_count(): %u\n", - mapcount, count); - if (PageTail(page)) - dump_page(head, NULL); - dump_page(page, "total_mapcount(head) > 0"); - BUG(); - } spin_unlock(&pgdata->split_queue_lock); -fail: if (mapping) +fail: + if (mapping) spin_unlock(&mapping->tree_lock); spin_unlock_irqrestore(zone_lru_lock(page_zone(head)), flags); remap_page(head); -- 2.30.2