Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5470382rwb; Tue, 1 Aug 2023 03:11:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlF9m/bOOoe1FEwybBDh1vq0YrKVaDZ3baUTJrv3Hiu7fM8wgUSownAssLvvAKyRdrJ2tgIR X-Received: by 2002:a05:6808:f89:b0:3a4:2826:4197 with SMTP id o9-20020a0568080f8900b003a428264197mr14683611oiw.37.1690884709703; Tue, 01 Aug 2023 03:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690884709; cv=none; d=google.com; s=arc-20160816; b=mnHRFe5Kok4JtBGJwrbrXpPXfL1dQZDLN/cRSmb1pxuYYwB3MUcK1L17uKQAqVTPA6 fPa5PCFFnlxzhky32C5PuFukhFFUjetPpGEhzmv4iD99VVlBo8RNh63fbHgbjWjjslvY qQGeUVwRQXWZPJbfk1kC0ny4xhwwO8+P8IMH716jwvzqB+z9dsWLnjKB5slJwzJ95fef hEgaN/vqYQ+5udgUNwVChbFMG6SGJrsFIhKvP0E+ZHxPJgp/LxY9C20gRrQRUZfK2/lI yFg7eR6+KU6F14PesSM2Zz9F2F4HoP9fHpHCn2xvDZGc3JuUqu3BvdgrW2H011qUEmxZ UaRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=fbbUx1ltMmG7PpjFYISi1cqMqxqnmwLF+JeOLQEkjek=; fh=8qEWLa8fLzKvJ47BV9nQALghCKFT+yPcDZwvfcNWELU=; b=CiYDRpTxEPswEaPsZafmWD4Y1vsi6PlZ1u34muEgQjVQLaGIsEhb/rcOrQhf4E8n2K P/CRPjgq00zOm4o9aN+hZHL5wWjpDytYBDG7jQTkD7M5iQk2GugLnz6lCi7qAM5dLuid 7OjD0hw5lmSRPccBQrrPkAMjMgYL+aGRWbL3wDCWAjqQwee/M+cgt2hpFCtimOTohOw+ SHRkzw1tFbT1vQ7jTW9Ow4kXd+uK8jqWpjtLBZVyLgoazzjVxPBk1xf8waByvkNIy1jB TjfVKeEtsChU9sotg62ZvtyNewdjsa4+UIFkKR7BOMXuAQp46oRGpxWKxuC8tsa+VWbS wOgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a17090aad8a00b0025945de4165si9081581pjq.141.2023.08.01.03.11.37; Tue, 01 Aug 2023 03:11:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232692AbjHAJSc (ORCPT + 99 others); Tue, 1 Aug 2023 05:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232868AbjHAJRz (ORCPT ); Tue, 1 Aug 2023 05:17:55 -0400 Received: from outbound-smtp27.blacknight.com (outbound-smtp27.blacknight.com [81.17.249.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B6C235A0 for ; Tue, 1 Aug 2023 02:16:45 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp27.blacknight.com (Postfix) with ESMTPS id 70D83CAD57 for ; Tue, 1 Aug 2023 10:08:14 +0100 (IST) Received: (qmail 25971 invoked from network); 1 Aug 2023 09:08:14 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.20.191]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 1 Aug 2023 09:08:14 -0000 Date: Tue, 1 Aug 2023 10:08:12 +0100 From: Mel Gorman To: Johannes Weiner Cc: Andrew Morton , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: compaction: fix endless looping over same migrate block Message-ID: <20230801090812.3o6utiufbwhgevom@techsingularity.net> References: <20230731172450.1632195-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20230731172450.1632195-1-hannes@cmpxchg.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, T_SPF_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 31, 2023 at 01:24:50PM -0400, Johannes Weiner wrote: > During stress testing, the following situation was observed: > > 70 root 39 19 0 0 0 R 100.0 0.0 959:29.92 khugepaged > 310936 root 20 0 84416 25620 512 R 99.7 1.5 642:37.22 hugealloc > > Tracing shows isolate_migratepages_block() endlessly looping over the > first block in the DMA zone: > > hugealloc-310936 [001] ..... 237297.415718: mm_compaction_finished: node=0 zone=DMA order=9 ret=no_suitable_page > hugealloc-310936 [001] ..... 237297.415718: mm_compaction_isolate_migratepages: range=(0x1 ~ 0x400) nr_scanned=513 nr_taken=0 > hugealloc-310936 [001] ..... 237297.415718: mm_compaction_finished: node=0 zone=DMA order=9 ret=no_suitable_page > hugealloc-310936 [001] ..... 237297.415718: mm_compaction_isolate_migratepages: range=(0x1 ~ 0x400) nr_scanned=513 nr_taken=0 > hugealloc-310936 [001] ..... 237297.415718: mm_compaction_finished: node=0 zone=DMA order=9 ret=no_suitable_page > hugealloc-310936 [001] ..... 237297.415718: mm_compaction_isolate_migratepages: range=(0x1 ~ 0x400) nr_scanned=513 nr_taken=0 > hugealloc-310936 [001] ..... 237297.415718: mm_compaction_finished: node=0 zone=DMA order=9 ret=no_suitable_page > hugealloc-310936 [001] ..... 237297.415718: mm_compaction_isolate_migratepages: range=(0x1 ~ 0x400) nr_scanned=513 nr_taken=0 > > The problem is that the functions tries to test and set the skip bit > once on the block, to avoid skipping on its own skip-set, using > pageblock_aligned() on the pfn as a test. But because this is the DMA > zone which starts at pfn 1, this is never true for the first block, > and the skip bit isn't set or tested at all. As a result, > fast_find_migrateblock() returns the same pageblock over and over. > > If the pfn isn't pageblock-aligned, also check if it's the start of > the zone to ensure test-and-set-exactly-once on unaligned ranges. > > Thanks to Vlastimil Babka for the help in debugging this. > > Fixes: 90ed667c03fe ("Revert "Revert "mm/compaction: fix set skip in fast_find_migrateblock""") > Signed-off-by: Johannes Weiner Acked-by: Mel Gorman -- Mel Gorman SUSE Labs