Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760256AbcLBLCs (ORCPT ); Fri, 2 Dec 2016 06:02:48 -0500 Received: from outbound-smtp06.blacknight.com ([81.17.249.39]:40038 "EHLO outbound-smtp06.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750862AbcLBLCq (ORCPT ); Fri, 2 Dec 2016 06:02:46 -0500 Date: Fri, 2 Dec 2016 11:02:42 +0000 From: Mel Gorman To: Michal Hocko Cc: Hillf Danton , "'Vlastimil Babka'" , "'Andrew Morton'" , "'Christoph Lameter'" , "'Johannes Weiner'" , "'Jesper Dangaard Brouer'" , "'Linux-MM'" , "'Linux-Kernel'" Subject: Re: [PATCH 1/2] mm, page_alloc: Keep pcp count and list contents in sync if struct page is corrupted Message-ID: <20161202110242.tjy7fj55naubx6bk@techsingularity.net> References: <20161202002244.18453-1-mgorman@techsingularity.net> <20161202002244.18453-2-mgorman@techsingularity.net> <01d601d24c4e$dca6e190$95f4a4b0$@alibaba-inc.com> <55e1d640-72cf-d7b5-695b-87863ca7a843@suse.cz> <01f201d24c7e$ac04ed40$040ec7c0$@alibaba-inc.com> <20161202100411.GG6830@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20161202100411.GG6830@dhcp22.suse.cz> User-Agent: Mutt/1.6.2 (2016-07-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1216 Lines: 33 On Fri, Dec 02, 2016 at 11:04:11AM +0100, Michal Hocko wrote: > On Fri 02-12-16 17:30:07, Hillf Danton wrote: > [...] > > > >> @@ -2217,13 +2217,14 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, > > > >> else > > > >> list_add_tail(&page->lru, list); > > > >> list = &page->lru; > > > >> + alloced++; > > > >> if (is_migrate_cma(get_pcppage_migratetype(page))) > > > >> __mod_zone_page_state(zone, NR_FREE_CMA_PAGES, > > > >> -(1 << order)); > > > >> } > > > >> __mod_zone_page_state(zone, NR_FREE_PAGES, -(i << order)); > > > > > > > > Now i is a pure index, yes? > > > > > > No, even if a page fails the check_pcp_refill() check and is not > > > "allocated", it is also no longer a free page, so it's correct to > > > subtract it from NR_FREE_PAGES. > > > > > Yes, we can allocate free page next time. > > No we cannot. The page is gone from the free list. We have effectively > leaked it. And deliberately so. It's in an unknown state, possibly due to memory corruption or a use-after free bug. The machine can continue limping on with warnings in the kernel log but the VM stops going near the page itself as much as possible. -- Mel Gorman SUSE Labs