Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7483250pxb; Thu, 18 Feb 2021 11:12:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzV2TmfamoeeyhBuiG+SWyGwDW+88sJxaOW7vtlxGgaoeqPMuHHcfSFfO6AwJjyUw7U1rGL X-Received: by 2002:a50:8ad3:: with SMTP id k19mr5550709edk.11.1613675570360; Thu, 18 Feb 2021 11:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613675570; cv=none; d=google.com; s=arc-20160816; b=XhzADV3g8VwlGMY8qhgx3ps9Jl30OI+I1wUJ7WBuQ98yAA3foom2JlPh5rvzQ+AyS3 O8ZjN6GenvuqxV7u9K9ShfszI/82m5V0FdPmLP1eWl1XUg/GFvj3WSMyTJnlfZ0YgE/a oZiry1qDRhES5P82m+jDYKmLliATRKVyNF+Dn+hRG8KyPg9MquFN2Fp0Ez/EI9yr34k4 VGIvFpLYN5vC6stsaARg4HavL5P3/9/vaqELdd69Y/rfiadkDK3DaQlwjn0jxuyePzyO CSCNeXfKE+SdalMgGfyz1C9kqu2yb7D1JxvonF87UjKyWHOsrs0SmAYCPQKA6oaxNfCE JYVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=KpLKjm3ucFUJqeCZJ6PrbcWSlTVmNQ7G7NjgekQwpnk=; b=QsMBqsTz3VzZtk756F5lcc3Ku+atgmhVQiQMiyVzYFyvpCqxNPJRkA8sNNjBVIPE2l q4sz2+t4fzKaqSdgr8VgjfGqSyPbUzQ4STe2t3yznL5ANoUvN1cA5OGjVXbe0rTsjgK3 PPnuMODejTfXulcjcoyHejTsHTEkEsfE2oSFRucMdd31gAoCtl+qb3U6HfdqCSCvJw8P RitX6cO/DUdhJjXKjs0ImHkZ5Hk/T9ftsJNhmXd3O48akKJywrOl0g0XnxwgeivXqzSD WoTs59AtMARY/QXUZIQnYTLOKP8k5HEjjJBB/symHxs3wecBIigdTHIVS3U+8YoeypSF gdQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si4630927edm.154.2021.02.18.11.12.13; Thu, 18 Feb 2021 11:12:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231396AbhBRTK7 (ORCPT + 99 others); Thu, 18 Feb 2021 14:10:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:53732 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234560AbhBRRng (ORCPT ); Thu, 18 Feb 2021 12:43:36 -0500 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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...