From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756007AbbGPBnH (ORCPT ); Wed, 15 Jul 2015 21:43:07 -0400 Received: from TYO201.gate.nec.co.jp ([210.143.35.51]:60549 "EHLO tyo201.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755993AbbGPBnF convert rfc822-to-8bit (ORCPT ); Wed, 15 Jul 2015 21:43:05 -0400 From: Naoya Horiguchi To: Andrew Morton CC: Andi Kleen , Dean Nelson , "Tony Luck" , "Kirill A. Shutemov" , "Hugh Dickins" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "Naoya Horiguchi" Subject: [PATCH v1 3/4] mm/memory-failure: give up error handling for non-tail-refcounted thp Thread-Topic: [PATCH v1 3/4] mm/memory-failure: give up error handling for non-tail-refcounted thp Thread-Index: AQHQv2iZqep/tm21g0+65vbSfJU/bw== Date: Thu, 16 Jul 2015 01:41:56 +0000 Message-ID: <1437010894-10262-4-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1437010894-10262-1-git-send-email-n-horiguchi@ah.jp.nec.com> In-Reply-To: <1437010894-10262-1-git-send-email-n-horiguchi@ah.jp.nec.com> Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.23] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "non anonymous thp" case is still racy with freeing thp, which causes panic due to put_page() for refcount-0 page. It seems that closing up this race might be hard (and/or not worth doing,) so let's give up the error handling for this case. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git v4.2-rc2.orig/mm/memory-failure.c v4.2-rc2/mm/memory-failure.c index f72d2fad0b90..421d7c9b30f4 100644 --- v4.2-rc2.orig/mm/memory-failure.c +++ v4.2-rc2/mm/memory-failure.c @@ -909,6 +909,15 @@ int get_hwpoison_page(struct page *page) * directly for tail pages. */ if (PageTransHuge(head)) { + /* + * Non anonymous thp exists only in allocation/free time. We + * can't handle such a case correctly, so let's give it up. + * This should be better than triggering BUG_ON when kernel + * tries to touch a "partially handled" page. + */ + if (!PageAnon(head)) + return 0; + if (get_page_unless_zero(head)) { if (PageTail(page)) get_page(page); @@ -1134,15 +1143,6 @@ int memory_failure(unsigned long pfn, int trapno, int flags) } if (!PageHuge(p) && PageTransHuge(hpage)) { - if (!PageAnon(hpage)) { - pr_err("MCE: %#lx: non anonymous thp\n", pfn); - if (TestClearPageHWPoison(p)) - atomic_long_sub(nr_pages, &num_poisoned_pages); - put_page(p); - if (p != hpage) - put_page(hpage); - return -EBUSY; - } if (unlikely(split_huge_page(hpage))) { pr_err("MCE: %#lx: thp split failed\n", pfn); if (TestClearPageHWPoison(p)) -- 2.4.3 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ob0-f181.google.com (mail-ob0-f181.google.com [209.85.214.181]) by kanga.kvack.org (Postfix) with ESMTP id CB38A2802C2 for ; Wed, 15 Jul 2015 21:43:00 -0400 (EDT) Received: by obbgp5 with SMTP id gp5so38207358obb.0 for ; Wed, 15 Jul 2015 18:43:00 -0700 (PDT) Received: from tyo201.gate.nec.co.jp (TYO201.gate.nec.co.jp. [210.143.35.51]) by mx.google.com with ESMTPS id w12si5068821oiw.66.2015.07.15.18.42.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 15 Jul 2015 18:43:00 -0700 (PDT) From: Naoya Horiguchi Subject: [PATCH v1 3/4] mm/memory-failure: give up error handling for non-tail-refcounted thp Date: Thu, 16 Jul 2015 01:41:56 +0000 Message-ID: <1437010894-10262-4-git-send-email-n-horiguchi@ah.jp.nec.com> References: <1437010894-10262-1-git-send-email-n-horiguchi@ah.jp.nec.com> In-Reply-To: <1437010894-10262-1-git-send-email-n-horiguchi@ah.jp.nec.com> Content-Language: ja-JP Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: owner-linux-mm@kvack.org List-ID: To: Andrew Morton Cc: Andi Kleen , Dean Nelson , Tony Luck , "Kirill A. Shutemov" , Hugh Dickins , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Naoya Horiguchi "non anonymous thp" case is still racy with freeing thp, which causes panic due to put_page() for refcount-0 page. It seems that closing up this race might be hard (and/or not worth doing,) so let's give up the error handling for this case. Signed-off-by: Naoya Horiguchi --- mm/memory-failure.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git v4.2-rc2.orig/mm/memory-failure.c v4.2-rc2/mm/memory-failure.c index f72d2fad0b90..421d7c9b30f4 100644 --- v4.2-rc2.orig/mm/memory-failure.c +++ v4.2-rc2/mm/memory-failure.c @@ -909,6 +909,15 @@ int get_hwpoison_page(struct page *page) * directly for tail pages. */ if (PageTransHuge(head)) { + /* + * Non anonymous thp exists only in allocation/free time. We + * can't handle such a case correctly, so let's give it up. + * This should be better than triggering BUG_ON when kernel + * tries to touch a "partially handled" page. + */ + if (!PageAnon(head)) + return 0; + if (get_page_unless_zero(head)) { if (PageTail(page)) get_page(page); @@ -1134,15 +1143,6 @@ int memory_failure(unsigned long pfn, int trapno, in= t flags) } =20 if (!PageHuge(p) && PageTransHuge(hpage)) { - if (!PageAnon(hpage)) { - pr_err("MCE: %#lx: non anonymous thp\n", pfn); - if (TestClearPageHWPoison(p)) - atomic_long_sub(nr_pages, &num_poisoned_pages); - put_page(p); - if (p !=3D hpage) - put_page(hpage); - return -EBUSY; - } if (unlikely(split_huge_page(hpage))) { pr_err("MCE: %#lx: thp split failed\n", pfn); if (TestClearPageHWPoison(p)) --=20 2.4.3 -- 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