From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 329FCC433E0 for ; Thu, 18 Feb 2021 17:42:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A437364E3E for ; Thu, 18 Feb 2021 17:42:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A437364E3E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1DA306B0006; Thu, 18 Feb 2021 12:42:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18AD56B006C; Thu, 18 Feb 2021 12:42:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C63D6B006E; Thu, 18 Feb 2021 12:42:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id EC7536B0006 for ; Thu, 18 Feb 2021 12:42:48 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B40CC180CE73D for ; Thu, 18 Feb 2021 17:42:48 +0000 (UTC) X-FDA: 77832108816.06.rule45_210335f27657 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 93DFE10064F37 for ; Thu, 18 Feb 2021 17:42:48 +0000 (UTC) X-HE-Tag: rule45_210335f27657 X-Filterd-Recvd-Size: 3371 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Feb 2021 17:42:47 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A15FFAE03; Thu, 18 Feb 2021 17:42:46 +0000 (UTC) Subject: Re: [PATCH] mm, compaction: make fast_isolate_freepages() stay within zone To: linux-mm@kvack.org, Mel Gorman , Andrew Morton Cc: linux-kernel@vger.kernel.org, Andrea Arcangeli , David Hildenbrand , Michal Hocko , Mike Rapoport , stable@vger.kernel.org, Qian Cai , David Rientjes References: <20210217173300.6394-1-vbabka@suse.cz> From: Vlastimil Babka Message-ID: <17a70bb4-5f61-d462-d722-cef8e1010351@suse.cz> Date: Thu, 18 Feb 2021 18:42:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210217173300.6394-1-vbabka@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2/17/21 6:33 PM, Vlastimil Babka wrote: > Compaction always operates on pages from a single given zone when isolating > both pages to migrate and freepages. Pageblock boundaries are intersected with > zone boundaries to be safe in case zone starts or ends in the middle of > pageblock. The use of pageblock_pfn_to_page() protects against non-contiguous > pageblocks. > > The functions fast_isolate_freepages() and fast_isolate_around() don't > currently protect the fast freepage isolation thoroughly enough against these > corner cases, and can result in freepage isolation operate outside of zone > boundaries: > > - in fast_isolate_freepages() if we get a pfn from the first pageblock of a > zone that starts in the middle of that pageblock, 'highest' can be a pfn > outside of the zone. If we fail to isolate anything in this function, we > may then call fast_isolate_around() on a pfn outside of the zone and there > effectively do a set_pageblock_skip(page_to_pfn(highest)) which may currently > hit a VM_BUG_ON() in some configurations > - fast_isolate_around() checks only the zone end boundary and not beginning, > nor that the pageblock is contiguous (with pageblock_pfn_to_page()) so it's > possible that we end up calling isolate_freepages_block() on a range of pfn's > from two different zones and end up e.g. isolating freepages under the wrong > zone's lock. > > This patch should fix the above issues. Sorry, totally forgot these: Reported-by: Qian Cai Reported-by: Andrea Arcangeli > Fixes: 5a811889de10 ("mm, compaction: use free lists to quickly locate a migration target") > Cc: > Signed-off-by: Vlastimil Babka Also thanks David and Mel for the acks! Thanks to Mike I was able to boot v5.11 in qemu with memmap containing a type 20 hole as Andrea reported, but can't reproduce the bug so far (i.e. without this patch, with DEBUG_VM enabled) using transhuge-stress; might need some more nuanced workload...