From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-24.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07D7EC47088 for ; Wed, 26 May 2021 22:02:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB124613D7 for ; Wed, 26 May 2021 22:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234372AbhEZWEV (ORCPT ); Wed, 26 May 2021 18:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233037AbhEZWET (ORCPT ); Wed, 26 May 2021 18:04:19 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37003C061574 for ; Wed, 26 May 2021 15:02:47 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id q10so2712263qkc.5 for ; Wed, 26 May 2021 15:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=m9kpVikMq0X/WHn50vIzul0uM/x6WaxsLnPxzV8XYwY=; b=dW9xLrwNtI1/mAS/0ZIsltlDg3VzivWh4QdL3oj5P80QrOqsJ69IkopdmzJgTrUP7i l5A0d6UTWe5OLP4sU8Of5bV34YNk/UWBffHWn5OGsV49OJ5Jdh01D1M+jY+mtR8PrmA9 B44q7ZRKrUC9Pe09cqmAyWhdMXgy7pxhx4tGNi8duVL8lWaapkz0UqCWRzAcWiNmA/9m AkL++frY2KbZN2vGPPor4ECBZS7VWbYeCIRm/Ce7yDkzisEcxqrKu5G26527DQFIhfJQ 2/uOdSWAWU5DUCm35PmqOBF0cP9eHvHM3myu0sMTphxrJkGoC7fo8biIsTQlU5IH/j72 +SFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=m9kpVikMq0X/WHn50vIzul0uM/x6WaxsLnPxzV8XYwY=; b=Z/F8zC3/nAid0tmGnUQrOuDrLr1fVPwn5Lg0ne58N+YvmEUqqo5WwZOie/0Hr7FPFZ WHabB0iSxqEjkbmwkFMJKcSLmmONqMoZ8q4z1aBkV2qo4S4DwuXwii4PteM6RP26XR7Q oBUmZ31QuBEb/98R9evNVV4vUn4n9EbJjstZOBQv15Luw+SPoaXciDUhUtugJO21+gAJ 1fUiLu2e9N5CqA85/T8GUgExKsK8cOzCsQQgiAj7RXEkKBZeFmUpNm+C4VM7ohdJQWpW y53d5Yh+tqR6AtYylxM5TyiRmzzIsKH2h5mcJiaL3TW8swVtJ3Fs9GD6+9vHFT/RyJQA J8gg== X-Gm-Message-State: AOAM532aZ1WFAxcnsFxGCGzeiglKtrQX28D7b40aFvZzHyIcsO4FxV4h dBBgM6uKm5ZNRdIlmUBlOoRdmA== X-Google-Smtp-Source: ABdhPJwKeenmvMpGNUJK6iXR3FHH2Vz/PN88ujD0+f1MT4LHxXMV4WjPo3xcDmZWglNZYNlVyowE8A== X-Received: by 2002:a37:2cc3:: with SMTP id s186mr282800qkh.500.1622066566096; Wed, 26 May 2021 15:02:46 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 123sm140993qkh.104.2021.05.26.15.02.44 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 26 May 2021 15:02:45 -0700 (PDT) Date: Wed, 26 May 2021 15:02:30 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yang Shi cc: hughd@google.com, ziy@nvidia.com, kirill.shutemov@linux.intel.com, minchan@kernel.org, naoya.horiguchi@nec.com, wangyugui@e16-tech.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [v4 PATCH 1/2] mm: thp: replace DEBUG_VM BUG with VM_WARN when unmap fails for split In-Reply-To: <20210526201239.3351-1-shy828301@gmail.com> Message-ID: References: <20210526201239.3351-1-shy828301@gmail.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 26 May 2021, Yang Shi wrote: > 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. And 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/ > > Reviewed-by: Zi Yan > Signed-off-by: Yang Shi Acked-by: Hugh Dickins Thanks: and 2/2 already has my Ack, correct. > --- > v4: Updated the subject and commit log per Hugh. > Reordered the patches per Hugh. > v3: Incorporated the comments from Hugh. Keep Zi Yan's reviewed-by tag > since there is no fundamental change against v2. > v2: Removed dead code and updated the comment of try_to_unmap() per Zi > Yan. > > 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 19195fca1aee..8827f82c5302 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2336,15 +2336,15 @@ static void unmap_page(struct page *page) > { > enum ttu_flags ttu_flags = TTU_IGNORE_MLOCK | > TTU_RMAP_LOCKED | TTU_SPLIT_HUGE_PMD; > - 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, unsigned int nr) > @@ -2655,7 +2655,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > struct deferred_split *ds_queue = get_deferred_split_queue(head); > struct anon_vma *anon_vma = NULL; > struct address_space *mapping = NULL; > - int count, mapcount, extra_pins, ret; > + int extra_pins, ret; > pgoff_t end; > > VM_BUG_ON_PAGE(is_huge_zero_page(head), head); > @@ -2714,7 +2714,6 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > } > > unmap_page(head); > - VM_BUG_ON_PAGE(compound_mapcount(head), head); > > /* block interrupt reentry in xa_lock and spinlock */ > local_irq_disable(); > @@ -2732,9 +2731,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > > /* Prevent deferred_split_scan() touching ->_refcount */ > spin_lock(&ds_queue->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))) { > ds_queue->split_queue_len--; > list_del(page_deferred_list(head)); > @@ -2754,16 +2751,9 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > __split_huge_page(page, list, end); > 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(&ds_queue->split_queue_lock); > -fail: if (mapping) > +fail: > + if (mapping) > xa_unlock(&mapping->i_pages); > local_irq_enable(); > remap_page(head, thp_nr_pages(head)); > -- > 2.26.2 > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-24.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBA5FC47082 for ; Wed, 26 May 2021 22:02:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5151B613B0 for ; Wed, 26 May 2021 22:02:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5151B613B0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 415FB6B0036; Wed, 26 May 2021 18:02:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 394946B006E; Wed, 26 May 2021 18:02:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B8556B0070; Wed, 26 May 2021 18:02:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id D99EB6B0036 for ; Wed, 26 May 2021 18:02:47 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7688799AE for ; Wed, 26 May 2021 22:02:47 +0000 (UTC) X-FDA: 78184757574.04.F9E840E Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by imf14.hostedemail.com (Postfix) with ESMTP id 50150C0042EC for ; Wed, 26 May 2021 22:02:39 +0000 (UTC) Received: by mail-qk1-f182.google.com with SMTP id i5so2680586qkf.12 for ; Wed, 26 May 2021 15:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=m9kpVikMq0X/WHn50vIzul0uM/x6WaxsLnPxzV8XYwY=; b=dW9xLrwNtI1/mAS/0ZIsltlDg3VzivWh4QdL3oj5P80QrOqsJ69IkopdmzJgTrUP7i l5A0d6UTWe5OLP4sU8Of5bV34YNk/UWBffHWn5OGsV49OJ5Jdh01D1M+jY+mtR8PrmA9 B44q7ZRKrUC9Pe09cqmAyWhdMXgy7pxhx4tGNi8duVL8lWaapkz0UqCWRzAcWiNmA/9m AkL++frY2KbZN2vGPPor4ECBZS7VWbYeCIRm/Ce7yDkzisEcxqrKu5G26527DQFIhfJQ 2/uOdSWAWU5DUCm35PmqOBF0cP9eHvHM3myu0sMTphxrJkGoC7fo8biIsTQlU5IH/j72 +SFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=m9kpVikMq0X/WHn50vIzul0uM/x6WaxsLnPxzV8XYwY=; b=ZjmWUzuWKZDsg/0xpKyHfVT1RdhsTDP64TZSyoq5jKrG8zNNQ8hAtYdCQliE51iZDQ JNwh22ZXqsLrXMPUIPNNRg3qGo3jHWf5D+3i4DzxBAwJpgK3cbdpaEy1z5AOs9JetEO7 mb5q65eMQKI1Jp/9YSrPHliIVz94cOZNPkQNzf3B5I8MkdnTw8kfbcS0ukSWXOQBs56e RXZLS+pW4vNIUDo0OI2omgyHVjOAtQ6Wb361h3Uae9VckaUtAbwaVKRe6yXS9t+l/0zi ftgZynKwGfsLEnxR3crVxPfNd9T+bUTKqxC54gminzGSOWNUnL9ohVXo+60dk0ASXO7J g42Q== X-Gm-Message-State: AOAM530Y0zJYsQAEEiUm7+PHXbg2UR9NS+GTSxDgTDITOh9gvIGnxG1/ CZstKvTAQaHkQ+bEe0ckt6B6Vg== X-Google-Smtp-Source: ABdhPJwKeenmvMpGNUJK6iXR3FHH2Vz/PN88ujD0+f1MT4LHxXMV4WjPo3xcDmZWglNZYNlVyowE8A== X-Received: by 2002:a37:2cc3:: with SMTP id s186mr282800qkh.500.1622066566096; Wed, 26 May 2021 15:02:46 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 123sm140993qkh.104.2021.05.26.15.02.44 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Wed, 26 May 2021 15:02:45 -0700 (PDT) Date: Wed, 26 May 2021 15:02:30 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Yang Shi cc: hughd@google.com, ziy@nvidia.com, kirill.shutemov@linux.intel.com, minchan@kernel.org, naoya.horiguchi@nec.com, wangyugui@e16-tech.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [v4 PATCH 1/2] mm: thp: replace DEBUG_VM BUG with VM_WARN when unmap fails for split In-Reply-To: <20210526201239.3351-1-shy828301@gmail.com> Message-ID: References: <20210526201239.3351-1-shy828301@gmail.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=dW9xLrwN; spf=pass (imf14.hostedemail.com: domain of hughd@google.com designates 209.85.222.182 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 50150C0042EC X-Stat-Signature: 1xox4gw4kgiwwsbsaan6r5e8x7rdsdik X-HE-Tag: 1622066559-116603 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 26 May 2021, Yang Shi wrote: > 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. And 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/ > > Reviewed-by: Zi Yan > Signed-off-by: Yang Shi Acked-by: Hugh Dickins Thanks: and 2/2 already has my Ack, correct. > --- > v4: Updated the subject and commit log per Hugh. > Reordered the patches per Hugh. > v3: Incorporated the comments from Hugh. Keep Zi Yan's reviewed-by tag > since there is no fundamental change against v2. > v2: Removed dead code and updated the comment of try_to_unmap() per Zi > Yan. > > 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 19195fca1aee..8827f82c5302 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2336,15 +2336,15 @@ static void unmap_page(struct page *page) > { > enum ttu_flags ttu_flags = TTU_IGNORE_MLOCK | > TTU_RMAP_LOCKED | TTU_SPLIT_HUGE_PMD; > - 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, unsigned int nr) > @@ -2655,7 +2655,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > struct deferred_split *ds_queue = get_deferred_split_queue(head); > struct anon_vma *anon_vma = NULL; > struct address_space *mapping = NULL; > - int count, mapcount, extra_pins, ret; > + int extra_pins, ret; > pgoff_t end; > > VM_BUG_ON_PAGE(is_huge_zero_page(head), head); > @@ -2714,7 +2714,6 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > } > > unmap_page(head); > - VM_BUG_ON_PAGE(compound_mapcount(head), head); > > /* block interrupt reentry in xa_lock and spinlock */ > local_irq_disable(); > @@ -2732,9 +2731,7 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > > /* Prevent deferred_split_scan() touching ->_refcount */ > spin_lock(&ds_queue->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))) { > ds_queue->split_queue_len--; > list_del(page_deferred_list(head)); > @@ -2754,16 +2751,9 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) > __split_huge_page(page, list, end); > 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(&ds_queue->split_queue_lock); > -fail: if (mapping) > +fail: > + if (mapping) > xa_unlock(&mapping->i_pages); > local_irq_enable(); > remap_page(head, thp_nr_pages(head)); > -- > 2.26.2 > >