Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753416AbbHJL4Y (ORCPT ); Mon, 10 Aug 2015 07:56:24 -0400 Received: from blu004-omc1s38.hotmail.com ([65.55.116.49]:51061 "EHLO BLU004-OMC1S38.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752666AbbHJL4U (ORCPT ); Mon, 10 Aug 2015 07:56:20 -0400 X-TMN: [i0DIwMa7trckH2rVbyTLAehkZdyiBqib] X-Originating-Email: [wanpeng.li@hotmail.com] Message-ID: From: Wanpeng Li To: Andrew Morton CC: Naoya Horiguchi , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wanpeng Li Subject: [PATCH v2 3/5] mm/hwpoison: introduce put_hwpoison_page to put refcount for memory error handling Date: Mon, 10 Aug 2015 19:28:21 +0800 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439206103-86829-1-git-send-email-wanpeng.li@hotmail.com> References: <1439206103-86829-1-git-send-email-wanpeng.li@hotmail.com> X-OriginalArrivalTime: 10 Aug 2015 11:56:18.0792 (UTC) FILETIME=[915F7680:01D0D363] MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1958 Lines: 62 Introduce put_hwpoison_page to put refcount for memory error handling. Suggested-by: Naoya Horiguchi Signed-off-by: Wanpeng Li --- include/linux/mm.h | 1 + mm/memory-failure.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 554b0f0..c0a0b9f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2103,6 +2103,7 @@ extern int memory_failure(unsigned long pfn, int trapno, int flags); extern void memory_failure_queue(unsigned long pfn, int trapno, int flags); extern int unpoison_memory(unsigned long pfn); extern int get_hwpoison_page(struct page *page); +extern void put_hwpoison_page(struct page *page); extern int sysctl_memory_failure_early_kill; extern int sysctl_memory_failure_recovery; extern void shake_page(struct page *p, int access); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e0eb7ab..fa9aa21 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -922,6 +922,27 @@ int get_hwpoison_page(struct page *page) } EXPORT_SYMBOL_GPL(get_hwpoison_page); +/** + * put_hwpoison_page() - Put refcount for memory error handling: + * @page: raw error page (hit by memory error) + */ +void put_hwpoison_page(struct page *page) +{ + struct page *head = compound_head(page); + + if (PageHuge(head)) { + put_page(head); + return; + } + + if (PageTransHuge(head)) + if (page != head) + put_page(head); + + put_page(page); +} +EXPORT_SYMBOL_GPL(put_hwpoison_page); + /* * Do all that is necessary to remove user space mappings. Unmap * the pages and send SIGBUS to the processes if the data was dirty. -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/