From patchwork Thu Nov 29 11:44:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongkai Wu X-Patchwork-Id: 10704477 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F331918B8 for ; Thu, 29 Nov 2018 11:44:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E541A2E50B for ; Thu, 29 Nov 2018 11:44:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D96DE2E5A2; Thu, 29 Nov 2018 11:44:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DD9D2E595 for ; Thu, 29 Nov 2018 11:44:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F1486B5264; Thu, 29 Nov 2018 06:44:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5A1AF6B5265; Thu, 29 Nov 2018 06:44:22 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 492C26B5266; Thu, 29 Nov 2018 06:44:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 06C386B5264 for ; Thu, 29 Nov 2018 06:44:22 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id m16so1019144pgd.0 for ; Thu, 29 Nov 2018 03:44:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=qzn765aUDqzzJ2gdZD9+8/pJfQHoGGe3O3x6M3DeWjI=; b=NAg7MIYP9FQoZn/HIffsdKQGLWKgozzQwfnVqaS2pyAwfdh6vX2a/egAzbZa9/Lmy6 372UmOmx80JmjnEJM6fDGvF31lu/Gaun8rkgMciUFYstECp7Ewmt1i8zzt1yyB9wJ6KI /JuTIcJVHaS8jxNtYCn4fD+4JGyAEcP0iNJbjsL1nC5mk/5FPGJVZREOakU4PDjt3WBT qIYSc61gg0h3J+O/1tmh94A6lGapkndjBaVE8exA+Ou9J79cmabVf6XWJ7CO5ZxYfeYg oomY7RARdmH5AzqQsGQZlQRPav+1JG9Zl6ZGA1LmunS3wmidDktzkRx0hJ8gmE06me4C b2Cw== X-Gm-Message-State: AA+aEWb5/r2N2+wXSRp/zjA9TQUBVanfJ7fbCgFMiPGkB4MeE1l7llr3 G7h1MRQS8wGucZdCsFqYALHNhulgJDuZbcgCVpIwD81wcdHjdT3nIkZ3/MhaVc3QNNq0/Gj+0t6 xu2vHpisgcPLonjfHKBVf2wOVC+K8R6EeacVaXih5qvr46610esr7b89X6RB3d2Gk4a7VFLZGSJ UD4BzNnCFkRftss7klXirbF0dqr6M+dSOb1xp2RApa6axuPB3xI/TGnPLJivfQMnfwFiGSJypZT oCuOIR2sLH1SucceHO0vnNRjQ7IYQsEQdnKEpHuvA5DqPFZy2iQKRQRXEpI1ncsKNr85ic5FEjp 1XotPcWkXAVaqxkz27U+djr3VxifStopT4LCZq98gJ+Nv/wkIcoHFcsZfyL3C8VV0LN121okMiN P X-Received: by 2002:a63:bc02:: with SMTP id q2mr964876pge.116.1543491861568; Thu, 29 Nov 2018 03:44:21 -0800 (PST) X-Received: by 2002:a63:bc02:: with SMTP id q2mr964848pge.116.1543491860719; Thu, 29 Nov 2018 03:44:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543491860; cv=none; d=google.com; s=arc-20160816; b=As2jR2JR8CFAFGoJp2PeCEWTz4nlzK/Fpy3G1WxXGRUng8n5h/QBEPyHDN8FEBRe5P TdFbeufxkWwJWXIqrRC/PaJX2IyRXqjG0qmef1sROMQ57bPawLHqHJG3s0j/aaocOpTP SOOloZyta/Qcsr+0s53PTQYjjPMHte9H4gtq2I6s5xQVwZojMDNNtcyp0mGCNNz/2ZTV I0slzMWOatrWQ16LM3KertPXfRiaZYzzeTn5GVxSqAMm/ukYc2bwwHNkrjOk6yuNt+Lr VukfuzJMFFKkQT0YO9vvnvipJ1qqClQQTLCy8JgaU5hIzaJvCB9RLIno2oSQiOFfwukK 8nLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=qzn765aUDqzzJ2gdZD9+8/pJfQHoGGe3O3x6M3DeWjI=; b=jXoau9Y6BbJ2FsPvapxAm/LhXFg2tBfbDeKvt4PBN2/VWcGOHjwBIDS7BUxNmThLcq QzGh6ltNv/qAY0cCmjaAELz0p2tGpWfFpt43PS9GVxPKsTk3KtnDUMXGyXsPoAH909Zn 3KQe89ZsKa34JfluU98RwHui5odtCp6WVYyX5dOORFnJJ9yGZ7s/QXytY2wuYAW2Sxpj v1ca1NFmS3pVtNE99izfiDHa1nQ6w7L2LpoO0Dvc9GkNIis7R8Gb2snuKuhtegfeqgGg JNvRpcfSwM0q9qvdP6u+wrJm0k/WpOUphll92VsPDzPFT9HSJdHyivANXtInrhqN620q XO/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dO5Y1Z+H; spf=pass (google.com: domain of nic.wuyk@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nic.wuyk@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id t17sor1807275pgv.27.2018.11.29.03.44.20 for (Google Transport Security); Thu, 29 Nov 2018 03:44:20 -0800 (PST) Received-SPF: pass (google.com: domain of nic.wuyk@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dO5Y1Z+H; spf=pass (google.com: domain of nic.wuyk@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nic.wuyk@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=qzn765aUDqzzJ2gdZD9+8/pJfQHoGGe3O3x6M3DeWjI=; b=dO5Y1Z+HaDnbkNRHicAUnWF1WU8KOQEHGMTo6+1eVGGKDh6uRjq5WbEF7QyYHhn8sQ lsLQP2UO21xNAW6IRrAl+69Pgz4Z0nfWAPN9IG64kYhmJXHhSPd/D/gzm2XKs4EuZGJm wdG5gQqECc+aCWNwUE4R7z2bbgW56W4Eb2WXp+cL8w/3UkgxZv0HG4wn3MTDPe/c5OxQ RUTfMTk5DUlcg+QTyrTAbYgpGWIy3cudNZyeZOIQpzjI6D+0bjrzlDAqicQXdlPFoqpw fx4tAr3kDKADM/8HjhchX7Z/JMp5BjAJkRiIhPmmgIPVFuRAuk2N78uYYVJR7Mnunqyq WrOg== X-Google-Smtp-Source: AFSGD/XhP+Ouxm5cTpqRlnSdomAYQE9VQ1sxxQdSf3TkisyysHc95wn9MqL5NiMXkg6pBiZiGoI5Og== X-Received: by 2002:a62:3ac1:: with SMTP id v62mr1022372pfj.87.1543491860432; Thu, 29 Nov 2018 03:44:20 -0800 (PST) Received: from VM_67_44_centos.localdomain ([150.109.46.178]) by smtp.gmail.com with ESMTPSA id c67sm3041141pfg.170.2018.11.29.03.44.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 03:44:20 -0800 (PST) From: Yongkai Wu X-Google-Original-From: Yongkai Wu To: mike.kravetz@oracle.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, nic_w@163.com Subject: [PATCH] hugetlbfs: Call VM_BUG_ON_PAGE earlier in free_huge_page Date: Thu, 29 Nov 2018 19:44:03 +0800 Message-Id: <1543491843-23438-1-git-send-email-nic_w@163.com> X-Mailer: git-send-email 1.8.3.1 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: X-Virus-Scanned: ClamAV using ClamSMTP A stack trace was triggered by VM_BUG_ON_PAGE(page_mapcount(page), page) in free_huge_page(). Unfortunately, the page->mapping field was set to NULL before this test. This made it more difficult to determine the root cause of the problem. Move the VM_BUG_ON_PAGE tests earlier in the function so that if they do trigger more information is present in the page struct. Signed-off-by: Yongkai Wu Acked-by: Michal Hocko Acked-by: Mike Kravetz Reviewed-by: William Kucharski --- mm/hugetlb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7f2a28a..14ef274 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1248,10 +1248,11 @@ void free_huge_page(struct page *page) (struct hugepage_subpool *)page_private(page); bool restore_reserve; - set_page_private(page, 0); - page->mapping = NULL; VM_BUG_ON_PAGE(page_count(page), page); VM_BUG_ON_PAGE(page_mapcount(page), page); + + set_page_private(page, 0); + page->mapping = NULL; restore_reserve = PagePrivate(page); ClearPagePrivate(page);