Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932468AbcKRRSG (ORCPT ); Fri, 18 Nov 2016 12:18:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41416 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932392AbcKRRRu (ORCPT ); Fri, 18 Nov 2016 12:17:50 -0500 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= To: akpm@linux-foundation.org, , linux-mm@kvack.org Cc: John Hubbard , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Dan Williams , Ross Zwisler Subject: [HMM v13 03/18] mm/ZONE_DEVICE/free_hot_cold_page: catch ZONE_DEVICE pages Date: Fri, 18 Nov 2016 13:18:12 -0500 Message-Id: <1479493107-982-4-git-send-email-jglisse@redhat.com> In-Reply-To: <1479493107-982-1-git-send-email-jglisse@redhat.com> References: <1479493107-982-1-git-send-email-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 18 Nov 2016 17:17:45 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1027 Lines: 35 Catch page from ZONE_DEVICE in free_hot_cold_page(). This should never happen as ZONE_DEVICE page must always have an elevated refcount. This is to catch refcounting issues in a sane way for ZONE_DEVICE pages. Signed-off-by: Jérôme Glisse Cc: Dan Williams Cc: Ross Zwisler --- mm/page_alloc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0fbfead..09b2630 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2435,6 +2435,16 @@ void free_hot_cold_page(struct page *page, bool cold) unsigned long pfn = page_to_pfn(page); int migratetype; + /* + * This should never happen ! Page from ZONE_DEVICE always must have an + * active refcount. Complain about it and try to restore the refcount. + */ + if (is_zone_device_page(page)) { + VM_BUG_ON_PAGE(is_zone_device_page(page), page); + page_ref_inc(page); + return; + } + if (!free_pcp_prepare(page)) return; -- 2.4.3