From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758042AbdJMMAe (ORCPT ); Fri, 13 Oct 2017 08:00:34 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:49518 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753413AbdJMMAY (ORCPT ); Fri, 13 Oct 2017 08:00:24 -0400 X-Google-Smtp-Source: ABhQp+Q7j0uHY6LYo7CFAe6eW+bYU+fFrq8J1FS1jHgaMb7alE71OOKD14L+wSh0pJcYCFXvP5b0iQ== From: Michal Hocko To: Cc: Michael Ellerman , Vlastimil Babka , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , LKML , Michal Hocko Subject: [PATCH 2/2] mm, page_alloc: fail has_unmovable_pages when seeing reserved pages Date: Fri, 13 Oct 2017 14:00:13 +0200 Message-Id: <20171013120013.698-2-mhocko@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171013120013.698-1-mhocko@kernel.org> References: <20171013115835.zaehapuucuzl2vlv@dhcp22.suse.cz> <20171013120013.698-1-mhocko@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Hocko Reserved pages should be completely ignored by the core mm because they have a special meaning for their owners. has_unmovable_pages doesn't check those so we rely on other tests (reference count, or PageLRU) to fail on such pages. Althought this happens to work it is safer to simply check for those explicitly and do not rely on the owner of the page to abuse those fields for special purposes. Please note that this is more of a further fortification of the code rahter than a fix of an existing issue. Signed-off-by: Michal Hocko --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ad0294ab3e4f..a8800b0a5619 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7365,6 +7365,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, page = pfn_to_page(check); + if (PageReferenced(page)) + return true; + /* * Hugepages are not in LRU lists, but they're movable. * We need not scan over tail pages bacause we don't -- 2.14.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 643286B025E for ; Fri, 13 Oct 2017 08:00:25 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id u138so9384160wmu.2 for ; Fri, 13 Oct 2017 05:00:25 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n128sor315958wma.79.2017.10.13.05.00.24 for (Google Transport Security); Fri, 13 Oct 2017 05:00:24 -0700 (PDT) From: Michal Hocko Subject: [PATCH 2/2] mm, page_alloc: fail has_unmovable_pages when seeing reserved pages Date: Fri, 13 Oct 2017 14:00:13 +0200 Message-Id: <20171013120013.698-2-mhocko@kernel.org> In-Reply-To: <20171013120013.698-1-mhocko@kernel.org> References: <20171013115835.zaehapuucuzl2vlv@dhcp22.suse.cz> <20171013120013.698-1-mhocko@kernel.org> Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org Cc: Michael Ellerman , Vlastimil Babka , Andrew Morton , KAMEZAWA Hiroyuki , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Igor Mammedov , Vitaly Kuznetsov , LKML , Michal Hocko From: Michal Hocko Reserved pages should be completely ignored by the core mm because they have a special meaning for their owners. has_unmovable_pages doesn't check those so we rely on other tests (reference count, or PageLRU) to fail on such pages. Althought this happens to work it is safer to simply check for those explicitly and do not rely on the owner of the page to abuse those fields for special purposes. Please note that this is more of a further fortification of the code rahter than a fix of an existing issue. Signed-off-by: Michal Hocko --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ad0294ab3e4f..a8800b0a5619 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7365,6 +7365,9 @@ bool has_unmovable_pages(struct zone *zone, struct page *page, int count, page = pfn_to_page(check); + if (PageReferenced(page)) + return true; + /* * Hugepages are not in LRU lists, but they're movable. * We need not scan over tail pages bacause we don't -- 2.14.2 -- 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