Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5296610rdb; Wed, 13 Dec 2023 05:03:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYg1aF45bHX71afnZiIpe3v2CyHEB+OcWxlRlWuf5TJ1t4t+xOqEoznxk8jvi9d2AI94KP X-Received: by 2002:a05:6a00:1143:b0:6ce:51ec:5fb7 with SMTP id b3-20020a056a00114300b006ce51ec5fb7mr4099237pfm.28.1702472584212; Wed, 13 Dec 2023 05:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702472584; cv=none; d=google.com; s=arc-20160816; b=L1lQSpZvMnMdsMvtCaKMaRnP2KXNh4bGDUBZ/BkHArBFfs/Clu9SLQErEEb7Iw6oHn J+MaSc1UT1ZEEvDZ89cp7rvIjwwE0LUuly70h9Yjfn+9IZgJ3lsAgp4oP753oqeTl4P0 75d18+NosI69PrmUeJtvIsLYh3ghjRYRDtzEEEH6v/LzdPdDmjRMCfJ7KcKaA3GmOE3N ftL6El5iMBd5u7oPg0Fs34I2CPGJHUrDW12YAM/cT480rTQHNIaXtP8dutY+RRMfj6fZ V4WgY+gbLdvmBC1sD2haDoyEKTaT3aZuR9gz+pilhRMRSd89TtxLFJ3kunDefikadUbf Dc7Q== 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=nsQBSl56PklqNA6dLVaNE0KpVItfXaH+zi6wx8BS+qM=; fh=wjnIQJS02hyD2wvGjbsM/TPlN0Ce3cnQo93+Bdkrcaw=; b=QDQ5z4JtucRGdyHwR9b4Nrm17c5+mCg96yK7cx2zdE009YrFSTluEN66YhD2mSLFS9 qGUn26sN92/0uGqjCNXO2k4GfKE4wsYezNZ2LbD5sPn1PK25tUjeAOL8MPpwnG6ifajE YRm57lIYLf1V2WaWj28aDq0CW5t/J4hOq1A4YC5gK/+YMnMwJrpf3OxgvtkKYVrKUsB2 3uAo87VKMCKvcB9z5MlmhRTotzL4DV0nj+4scLrjjyGR4ZBv8vXvZx+t7qn6miCHONR7 ykVDT6vday4CuDzmKUuKU7EM7WeNHSHTOCugMMDNxnGkKCdLQOr/AwYafYMV0NT5uVTV yA5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id g6-20020a056a0023c600b006cd82b4d0c4si9420751pfc.89.2023.12.13.05.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 05:03:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 823768221110; Wed, 13 Dec 2023 05:02:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379081AbjLMNCk (ORCPT + 99 others); Wed, 13 Dec 2023 08:02:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379027AbjLMNCj (ORCPT ); Wed, 13 Dec 2023 08:02:39 -0500 Received: from outbound-smtp61.blacknight.com (outbound-smtp61.blacknight.com [46.22.136.249]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85C5B10C8 for ; Wed, 13 Dec 2023 05:02:35 -0800 (PST) Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp61.blacknight.com (Postfix) with ESMTPS id DA549FAC6E for ; Wed, 13 Dec 2023 13:02:33 +0000 (GMT) Received: (qmail 17601 invoked from network); 13 Dec 2023 13:02:33 -0000 Received: from unknown (HELO mail.blacknight.com) (mgorman@techsingularity.net@[81.17.254.22]) by 81.17.254.26 with ESMTPA; 13 Dec 2023 13:02:33 -0000 Date: Wed, 13 Dec 2023 13:02:31 +0000 From: Mel Gorman To: Barry Song <21cnbao@gmail.com> Cc: akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, david@redhat.com, hannes@cmpxchg.org, huzhanyuan@oppo.com, linux-kernel@vger.kernel.org, shikemeng@huaweicloud.com, v-songbaohua@oppo.com, willy@infradead.org Subject: Re: [PATCH] mm: compaction: avoid fast_isolate_freepages blindly choose improper pageblock Message-ID: <20231213130231.ksban2ovad4q4rxj@techsingularity.net> References: <20231206110054.61617-1-v-songbaohua@oppo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20231206110054.61617-1-v-songbaohua@oppo.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 05:02:53 -0800 (PST) On Thu, Dec 07, 2023 at 12:00:54AM +1300, Barry Song wrote: > Testing shows fast_isolate_freepages can blindly choose an unsuitable > pageblock from time to time particularly while the min mark is used > from XXX path: > if (!page) { > cc->fast_search_fail++; > if (scan_start) { > /* > * Use the highest PFN found above min. If one was > * not found, be pessimistic for direct compaction > * and use the min mark. > */ > if (highest >= min_pfn) { > page = pfn_to_page(highest); > cc->free_pfn = highest; > } else { > if (cc->direct_compaction && pfn_valid(min_pfn)) { /* XXX */ > page = pageblock_pfn_to_page(min_pfn, > min(pageblock_end_pfn(min_pfn), > zone_end_pfn(cc->zone)), > cc->zone); > cc->free_pfn = min_pfn; > } > } > } > } > > The reason is that no code is doing any check on the min_pfn > min_pfn = pageblock_start_pfn(cc->free_pfn - (distance >> 1)); > > In contrast, slow path of isolate_freepages() is always skipping unsuitable > pageblocks in a decent way. > > This issue doesn't happen quite often. When running 25 machines with 16GiB > memory for one night, most of them can hit this unexpected code path. > However the frequency isn't like many times per second. It might be one > time in a couple of hours. Thus, it is very hard to measure the visible > performance impact in my machines though the affection of choosing the > unsuitable migration_target should be negative in theory. > > I feel it's still worth fixing this to at least make the code theoretically > self-explanatory as it is quite odd an unsuitable migration_target can be > still migration_target. > > Reported-by: Zhanyuan Hu > Signed-off-by: Barry Song Acked-by: Mel Gorman -- Mel Gorman SUSE Labs