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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 8B210C433E0 for ; Wed, 17 Feb 2021 18:17:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 523D364DFF for ; Wed, 17 Feb 2021 18:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234777AbhBQSRp (ORCPT ); Wed, 17 Feb 2021 13:17:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233242AbhBQSRk (ORCPT ); Wed, 17 Feb 2021 13:17:40 -0500 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69FBEC061574 for ; Wed, 17 Feb 2021 10:17:00 -0800 (PST) Received: by mail-pg1-x52a.google.com with SMTP id a4so7408511pgc.11 for ; Wed, 17 Feb 2021 10:17:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=Gi5brysudot778XfmQVyx+aFXT8IJ2mHpa0FTPkL6QA=; b=JDl2MhLCKhOanylnBiOEISbmJ/fonCREql9eNZHng2H7QwzVFaolfNg+s/F0hE+eQI cir2nRyVipOFEdPTN776AvYbVQCj4y+QZ1IfarCboeoTw30HyqCHN28Cklg5UeKtQzO3 K+nUCfCVrBslJkoW4kIw6wJDhHd5BTn7DGOb+XZJTcNK1leoU0WHZ6+oshreIlUjc46A BEdYP0Wh1g76zpGnNwbZPPyzYIyQKDBaUpHuUgsWMRdgpuvBl4+9+rXzvFC3qc6Oh1o1 UnplyjT1+j5iWUEHy1a2es5vbA27tH0vPIXN6VJotGrnqYQOWnpg8DhwV94t+buCqPn2 ilwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=Gi5brysudot778XfmQVyx+aFXT8IJ2mHpa0FTPkL6QA=; b=SojAoWlQIbOZUX8wMlCc4/Bx9HdsmXwLd6OEmQhkbwDwerANnMQCSvuaZmYECCBZs+ phkyzufhvsih8ijQEYM3hr9rwXy3w/aw1rwFvABb4RuvWWV+dpcUNE03qpkOV+zae0MI W19K5IotHoAF6MeLTG/9CF5Cp0Bgq4ZG7U+bQQXICk/nuQOkR7yBNKErxkbzbI2b2gMu 1hHGc72kDwUu5hxtJh71Jz9b/PvE+JFZKRbcZlsgh24U078q0aaCQA20aFToW+qyNJCB 6Qfdo/MMHmqOssl7pOiWqpWzBufwmLJJPbgSpPmN9ItU0/h590wg1LiEGuzgUszx3zjw wjXA== X-Gm-Message-State: AOAM532ysv+5lJpJ/X0aN0rRn164d2KMwUVkKJ6+JOCLBSLjPgtcY5Zj lRWcrfrJIAdkwUwZ41RZT7A6hg== X-Google-Smtp-Source: ABdhPJwkPj5MkgTeombBs7pS0/rjx65B5ONZ/wzcQkeUkP51XCckDsu8TF+UwXtCGcplyrsMAymmSQ== X-Received: by 2002:a63:a0d:: with SMTP id 13mr560363pgk.130.1613585819166; Wed, 17 Feb 2021 10:16:59 -0800 (PST) Received: from [2620:15c:17:3:984e:d574:ca36:ce3c] ([2620:15c:17:3:984e:d574:ca36:ce3c]) by smtp.gmail.com with ESMTPSA id j73sm3295845pfd.170.2021.02.17.10.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 10:16:58 -0800 (PST) Date: Wed, 17 Feb 2021 10:16:57 -0800 (PST) From: David Rientjes To: Vlastimil Babka cc: linux-mm@kvack.org, Mel Gorman , Andrew Morton , linux-kernel@vger.kernel.org, Andrea Arcangeli , David Hildenbrand , Michal Hocko , Mike Rapoport , stable@vger.kernel.org Subject: Re: [PATCH] mm, compaction: make fast_isolate_freepages() stay within zone In-Reply-To: <20210217173300.6394-1-vbabka@suse.cz> Message-ID: References: <20210217173300.6394-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 17 Feb 2021, 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. > > Fixes: 5a811889de10 ("mm, compaction: use free lists to quickly locate a migration target") > Cc: > Signed-off-by: Vlastimil Babka Acked-by: David Rientjes 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=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL 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 6CB39C433DB for ; Wed, 17 Feb 2021 18:17:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DF6FB64E4B for ; Wed, 17 Feb 2021 18:17:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF6FB64E4B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 150B06B0006; Wed, 17 Feb 2021 13:17:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1002A6B006C; Wed, 17 Feb 2021 13:17:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2FBF6B006E; Wed, 17 Feb 2021 13:17:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0197.hostedemail.com [216.40.44.197]) by kanga.kvack.org (Postfix) with ESMTP id DA75B6B0006 for ; Wed, 17 Feb 2021 13:17:01 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9229075A0 for ; Wed, 17 Feb 2021 18:17:01 +0000 (UTC) X-FDA: 77828566242.23.hair18_03005e82764e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 733AC37604 for ; Wed, 17 Feb 2021 18:17:01 +0000 (UTC) X-HE-Tag: hair18_03005e82764e X-Filterd-Recvd-Size: 4817 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 17 Feb 2021 18:17:00 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id m6so8949732pfk.1 for ; Wed, 17 Feb 2021 10:17:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=Gi5brysudot778XfmQVyx+aFXT8IJ2mHpa0FTPkL6QA=; b=JDl2MhLCKhOanylnBiOEISbmJ/fonCREql9eNZHng2H7QwzVFaolfNg+s/F0hE+eQI cir2nRyVipOFEdPTN776AvYbVQCj4y+QZ1IfarCboeoTw30HyqCHN28Cklg5UeKtQzO3 K+nUCfCVrBslJkoW4kIw6wJDhHd5BTn7DGOb+XZJTcNK1leoU0WHZ6+oshreIlUjc46A BEdYP0Wh1g76zpGnNwbZPPyzYIyQKDBaUpHuUgsWMRdgpuvBl4+9+rXzvFC3qc6Oh1o1 UnplyjT1+j5iWUEHy1a2es5vbA27tH0vPIXN6VJotGrnqYQOWnpg8DhwV94t+buCqPn2 ilwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=Gi5brysudot778XfmQVyx+aFXT8IJ2mHpa0FTPkL6QA=; b=sMY78x1ZOHDiDWDK4QXOzDUPl+ITd6+wOfjeSw1SGksUxiYVrB1okidQiWEQYv59MD 42r9lxiGUUpkZ/L5ir5Xa7UKknKtnokYYmWbnhO+ZEf7jkfbkv5qj7MPD7AJf4rOJ431 /oux7ZSIzvRLhcuSVksEiiUGzOEDESwdJMzd8HarygS1AMjcYFeQE6znaX0jfQwNx6j+ tBu37LyfXh2jA4yXYNrv3Hqgr7JCsI6iMgU1rK9pNKgGorEm/BTvS6u0CJqMNXuZHRcd cQtx7MZ74Ccm9+bVOy9XQghi+oBtbTX4+SUFqSkYqnXvHdJmCEkYV5iYYrCxGYd8HpyM asrQ== X-Gm-Message-State: AOAM533aPUyFjTu1J+b/lEYUvXXzHEoKdfxGdcIB3JUM8QI695Yg4XS5 7PJ2Sjr+0ZT3VCPRdY/f1hPxPQ== X-Google-Smtp-Source: ABdhPJwkPj5MkgTeombBs7pS0/rjx65B5ONZ/wzcQkeUkP51XCckDsu8TF+UwXtCGcplyrsMAymmSQ== X-Received: by 2002:a63:a0d:: with SMTP id 13mr560363pgk.130.1613585819166; Wed, 17 Feb 2021 10:16:59 -0800 (PST) Received: from [2620:15c:17:3:984e:d574:ca36:ce3c] ([2620:15c:17:3:984e:d574:ca36:ce3c]) by smtp.gmail.com with ESMTPSA id j73sm3295845pfd.170.2021.02.17.10.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 10:16:58 -0800 (PST) Date: Wed, 17 Feb 2021 10:16:57 -0800 (PST) From: David Rientjes To: Vlastimil Babka cc: linux-mm@kvack.org, Mel Gorman , Andrew Morton , linux-kernel@vger.kernel.org, Andrea Arcangeli , David Hildenbrand , Michal Hocko , Mike Rapoport , stable@vger.kernel.org Subject: Re: [PATCH] mm, compaction: make fast_isolate_freepages() stay within zone In-Reply-To: <20210217173300.6394-1-vbabka@suse.cz> Message-ID: References: <20210217173300.6394-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 Wed, 17 Feb 2021, 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. > > Fixes: 5a811889de10 ("mm, compaction: use free lists to quickly locate a migration target") > Cc: > Signed-off-by: Vlastimil Babka Acked-by: David Rientjes