From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:53302 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751105AbdKEPYJ (ORCPT ); Sun, 5 Nov 2017 10:24:09 -0500 Subject: Patch "fs/hugetlbfs/inode.c: fix hwpoison reserve accounting" has been added to the 4.13-stable tree To: mike.kravetz@oracle.com, akpm@linux-foundation.org, aneesh.kumar@linux.vnet.ibm.com, gregkh@linuxfoundation.org, khandual@linux.vnet.ibm.com, mhocko@kernel.org, n-horiguchi@ah.jp.nec.com, torvalds@linux-foundation.org Cc: , From: Date: Sun, 05 Nov 2017 16:24:19 +0100 Message-ID: <15098954592114@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled fs/hugetlbfs/inode.c: fix hwpoison reserve accounting to the 4.13-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: fs-hugetlbfs-inode.c-fix-hwpoison-reserve-accounting.patch and it can be found in the queue-4.13 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From ab615a5b879292e83653be60aa82113f7c6f462d Mon Sep 17 00:00:00 2001 From: Mike Kravetz Date: Thu, 2 Nov 2017 15:59:41 -0700 Subject: fs/hugetlbfs/inode.c: fix hwpoison reserve accounting From: Mike Kravetz commit ab615a5b879292e83653be60aa82113f7c6f462d upstream. Calling madvise(MADV_HWPOISON) on a hugetlbfs page will result in bad (negative) reserved huge page counts. This may not happen immediately, but may happen later when the underlying file is removed or filesystem unmounted. For example: AnonHugePages: 0 kB ShmemHugePages: 0 kB HugePages_Total: 1 HugePages_Free: 0 HugePages_Rsvd: 18446744073709551615 HugePages_Surp: 0 Hugepagesize: 2048 kB In routine hugetlbfs_error_remove_page(), hugetlb_fix_reserve_counts is called after remove_huge_page. hugetlb_fix_reserve_counts is designed to only be called/used only if a failure is returned from hugetlb_unreserve_pages. Therefore, call hugetlb_unreserve_pages as required and only call hugetlb_fix_reserve_counts in the unlikely event that hugetlb_unreserve_pages returns an error. Link: http://lkml.kernel.org/r/20171019230007.17043-2-mike.kravetz@oracle.com Fixes: 78bb920344b8 ("mm: hwpoison: dissolve in-use hugepage in unrecoverable memory error") Signed-off-by: Mike Kravetz Acked-by: Naoya Horiguchi Cc: Michal Hocko Cc: Aneesh Kumar Cc: Anshuman Khandual Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/hugetlbfs/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -855,9 +855,12 @@ static int hugetlbfs_error_remove_page(s struct page *page) { struct inode *inode = mapping->host; + pgoff_t index = page->index; remove_huge_page(page); - hugetlb_fix_reserve_counts(inode); + if (unlikely(hugetlb_unreserve_pages(inode, index, index + 1, 1))) + hugetlb_fix_reserve_counts(inode); + return 0; } Patches currently in stable-queue which might be from mike.kravetz@oracle.com are queue-4.13/fs-hugetlbfs-inode.c-fix-hwpoison-reserve-accounting.patch queue-4.13/userfaultfd-hugetlbfs-prevent-uffdio_copy-to-fill-beyond-the-end-of-i_size.patch