From patchwork Wed Nov 29 10:45:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13472608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDC85C4167B for ; Wed, 29 Nov 2023 10:45:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5738F6B03C5; Wed, 29 Nov 2023 05:45:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 523576B03C6; Wed, 29 Nov 2023 05:45:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EBBA6B03C7; Wed, 29 Nov 2023 05:45:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2D4066B03C5 for ; Wed, 29 Nov 2023 05:45:51 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0C20A1C03E2 for ; Wed, 29 Nov 2023 10:45:51 +0000 (UTC) X-FDA: 81510661302.17.4D1BAF2 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf05.hostedemail.com (Postfix) with ESMTP id 44E4B100015 for ; Wed, 29 Nov 2023 10:45:49 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=et+vxhgy; spf=pass (imf05.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701254749; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=0WUGmqoJPaeTzET/O78MEEgB8PQJztuihLmKtgPXGxM=; b=okWTwVt9bwqHzSLzzpWI5ZbHDmjG8EjK6Eq/0cVJWygd8VyKClhCCDJBaB2K92hHIs3F8N nc8B0VXtvacLvBxQ6ckMpIShxkrKwlEYyeaHqHAkaNmVF+MIXyACYS/y0wBLF7YYKw3Uzp Ok0PC3LvnxoOwUSJhjEz4y+1XCWx48Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701254749; a=rsa-sha256; cv=none; b=70cEoButVExlV4ear7cnV944JnlqfJFBOw4QMkIO9GlbqH1CLSu9VZTkk71dj81mqNPFOn bIjF9aPoMxEvVr226xaAMOHJKhTCpyXFEmP8ZsGua9Z/r4EzepHSBoM506gHvbbMvnaEXK UtMxSk/+D0SN9GvUBhZeShsn31BZxlU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=et+vxhgy; spf=pass (imf05.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6cddb35ef8bso117612b3a.2 for ; Wed, 29 Nov 2023 02:45:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701254748; x=1701859548; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=0WUGmqoJPaeTzET/O78MEEgB8PQJztuihLmKtgPXGxM=; b=et+vxhgyPdX+NQ8PPyKOgzsMeuRfqPYsiPK3PgSLQXoeoPhP3QuxvJW57crp5mMcL8 DAYfHFZM2HphkWhTbO3MBj7hyFcqkKjR7HsRqGExbSNWJO5ovlgCRIOPCMHS2RpDI3gA x4OVK76/rdzMezLkoJ9/PkFIvesb3ho08WVEaF9Ae7mdBC5/G2To+0O9hKw+3DHfTIFf 6/PVIS3mAehDldzvKCnci/xame4CM8YxAcnajZxdODN9OZI7Vp9yoEH41tEVCnGQ7udy ZIUFYA0FSKf+Im+Bx0sGe1iR9NffGEUcCYAUxuqT3PTBG++BuMVt6g9XGoqEqvK4T1uL jQbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701254748; x=1701859548; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0WUGmqoJPaeTzET/O78MEEgB8PQJztuihLmKtgPXGxM=; b=kopMN19FhB9pQbERy8a06X/SxgwGx9rTNKw7FJEpM+U349Fdh47DT6h2pwSboYFNk7 ZDuROk5g83QN4x3ZQ2e3AVOgRVBhNFgShkaG6y+K8a4Xn+zmVBdufQJOpzuot4I9fzzK E1PdIcwr3W9lsx6Np0Bu8B0F9CRo4bo0kB9CK5Km9sP4J7HKtX9JU7oDM0/7NczIlyQL qQ0/hqNY/jf39CgG6t9DVHbjWZTt+uslUAgfTVeeuppzSMv2bDJp/qGI3mHKgJn6m5ON tVuQuhjexoDSD7exM6OSSpp/5wfZRZP20agfL833ICv9fHkKZgo6WT5yadTgbLR99IbJ z8eQ== X-Gm-Message-State: AOJu0Yxo+bSZjMDepwoFckYmkIy93vQkkIUAFg3iJ2otnKmbSoRWWdEL FWRw/wibGFHGxxVfGyxPwG0= X-Google-Smtp-Source: AGHT+IHysOytrkTST2jcGXPY02XcKwCnysM0RueAvsHVUcsNAXvv5s58XHBB2X2LY1B+xAL/f+cnQQ== X-Received: by 2002:a05:6a20:a10a:b0:18a:e176:87e9 with SMTP id q10-20020a056a20a10a00b0018ae17687e9mr15899897pzk.15.1701254747980; Wed, 29 Nov 2023 02:45:47 -0800 (PST) Received: from barry-desktop.. (47-72-151-223.dsl.dyn.ihug.co.nz. [47.72.151.223]) by smtp.gmail.com with ESMTPSA id 18-20020aa79112000000b0068fcb70ccafsm10425917pfh.129.2023.11.29.02.45.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 02:45:47 -0800 (PST) From: Barry Song <21cnbao@gmail.com> X-Google-Original-From: Barry Song To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: david@redhat.com, shikemeng@huaweicloud.com, willy@infradead.org, mgorman@techsingularity.net, hannes@cmpxchg.org, baolin.wang@linux.alibaba.com, linux-kernel@vger.kernel.org, Barry Song , Zhanyuan Hu Subject: [RFC PATCH] mm: compaction: avoid fast_isolate_freepages blindly choose improper pageblock Date: Wed, 29 Nov 2023 23:45:30 +1300 Message-Id: <20231129104530.63787-1-v-songbaohua@oppo.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 44E4B100015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ie7rwu7cduruahbwuau4ubn7wdn6dzjd X-HE-Tag: 1701254749-355403 X-HE-Meta: U2FsdGVkX18GT0LvU+VdknoMDrzSekuwlZm5xOtL+bbnotJT7zVj1+kKb0vhkZWD6Fvg+YNS2MnAId5shY9PLR2OF3YNCSk3IT9/ORrUAAtU1+dyL9y3zPZan7w9UohZWUb8pPtq74bIWP2DcmgclXYqwoIfgJzNkgN3MKwlrhWlfu/FFr4/jeuK416Dj3xMrTjzgbpIWrPC3Y8TVSokEBYfeA0mqEYk3RKuOa6qb0yThsTEFtcy3tw7xqsj6086J3+FYZijmdIL1b9uJ9KBdZ0OjbRk/hgq0laDAIpxL2NC52sFqB3ZMbr2bFjujZcJ9dwlTHYOJm79/28AwFwmNQm0gzfo+8Q8pl6JXO7emZWFjjqHW3FXzH3QAWBoLlvTO56QLkwrheq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KY7X3zi6hSjPWXMpWY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000126, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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; } } } } In contrast, slow path is skipping unsuitable pageblocks in a decent way. I don't know if it is an intended design or just an oversight. But it seems more sensible to skip unsuitable pageblock. Reported-by: Zhanyuan Hu Signed-off-by: Barry Song --- mm/compaction.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index 01ba298739dd..98c485a25614 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1625,6 +1625,12 @@ static void fast_isolate_freepages(struct compact_control *cc) cc->total_free_scanned += nr_scanned; if (!page) return; + /* + * Otherwise, we can blindly choose an improper pageblock especially + * while using the min mark + */ + if (!suitable_migration_target(cc, page)) + return; low_pfn = page_to_pfn(page); fast_isolate_around(cc, low_pfn);