From patchwork Sun Jun 20 14:57:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wonhyuk Yang X-Patchwork-Id: 12333431 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=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 98653C48BDF for ; Sun, 20 Jun 2021 14:57:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 225B86109E for ; Sun, 20 Jun 2021 14:57:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 225B86109E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 380C66B006E; Sun, 20 Jun 2021 10:57:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 330F46B0070; Sun, 20 Jun 2021 10:57:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AAD96B0072; Sun, 20 Jun 2021 10:57:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0062.hostedemail.com [216.40.44.62]) by kanga.kvack.org (Postfix) with ESMTP id DDAFE6B006E for ; Sun, 20 Jun 2021 10:57:49 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7BCD419470 for ; Sun, 20 Jun 2021 14:57:49 +0000 (UTC) X-FDA: 78274406658.08.B1727B6 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf10.hostedemail.com (Postfix) with ESMTP id F371B4211089 for ; Sun, 20 Jun 2021 14:57:46 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id x16so11667972pfa.13 for ; Sun, 20 Jun 2021 07:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8eNQDrVmib7Eum4fwnfyLr1xflb+ZB0OYjNTl4mOrc8=; b=dzbafNxXxrksl6RqCqrm5FjcVNs5vExrQnB6ZI7J562V91IuOONtUhHVj6PcI67Qdh 1XZbI6LOcO2bt5rkzJWYAv+rXMQfoEl8rnpJ/IX7y9YQ7P68PItJRq/Cy4y8cpEahCyq g9WHMBV9JwX1XYt3fNcsROP+7HSVNPG91UiqvXgAkhjKVcFi+hevBDROMLzY+cNYfHaj g+jzKmgO1ugu4f1JzuTYaKwA7qqnQdjXCEd63F8/10jJabKKSJZ+ew+/yGcYRo+2vyke VzK1xK4g03lHdufK0XuSB41tRZYe0ZViF5VI86BhUiY3bKpVz7iNMOB9brE8HNFwkHLB TN/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8eNQDrVmib7Eum4fwnfyLr1xflb+ZB0OYjNTl4mOrc8=; b=jlaqQAyrZuQaGxzUz6shIsL0KXeFdwOVDV9x/+XuRsN9jnOxBSocEY+YUZWVjNsyXO RPOWXzqgcjQYQ5A6O8qcBl+xhrREs7BZx6I67avCg82Ls0MMuyzg9pmhJl9KRuYW1Qpf hs1NmnudA3BdASGbXyAtIdn7Tt90LpW+8d4gwOWSFtUX3NEZELtZqjhfptEMZxRo+Ww6 ZgkIOBzLHFPcbU6di1uwJSbk+3jwJCCmJ4431KJwhoJ7SUjboE9qtMOzMDphLlC/i6ka aYcsotGDRVsjzeW/3vJebL6/EwZYfimCYZDo1rfqQJLO1R16RIMGq7bYVZECqjtlIgIG wFIA== X-Gm-Message-State: AOAM530VEEJ6I5ei/4xgXS4zvi37vdXJQJGSTa5iNNyxUWkgfMlb4lj/ V9PNOsvim3C6K6v15nkTEGfyFPxjf9AcrXWMU7Q= X-Google-Smtp-Source: ABdhPJz5IJgL7HARKYiraY00f/UHU8jyzE884M/A/VKf7vzmIPyq8INkWW1QxapIuI7CV+RWAK1ROA== X-Received: by 2002:a05:6a00:b95:b029:2ec:81eb:518d with SMTP id g21-20020a056a000b95b02902ec81eb518dmr15155711pfj.61.1624201067887; Sun, 20 Jun 2021 07:57:47 -0700 (PDT) Received: from dewh-local.. ([125.131.156.99]) by smtp.gmail.com with ESMTPSA id s22sm12707155pfg.197.2021.06.20.07.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jun 2021 07:57:47 -0700 (PDT) From: Wonhyuk Yang To: linux-mm@kvack.org Cc: Mel Gorman , Andrew Morton , Vlastimil Babka , Wonhyuk Yang Subject: [PATCH] mm, compaction: fix 'limit' in fast_isolate_freepages Date: Sun, 20 Jun 2021 23:57:42 +0900 Message-Id: <20210620145742.54565-1-vvghjk1234@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=dzbafNxX; spf=pass (imf10.hostedemail.com: domain of vvghjk1234@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=vvghjk1234@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: cah1n6u3wdtbup46dzear1579zy4m4ir X-Rspamd-Queue-Id: F371B4211089 X-Rspamd-Server: rspam06 X-HE-Tag: 1624201066-609036 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: Because of 'min(1, ...)', fast_isolate_freepages set 'limit' to 0 or 1. This takes away the opportunities of find candinate pages. Also, even if 'limit' reaches zero, it scan once. It is not consistent. So, modify the minimum value of 'limit' to 1. Fixes: 5a811889de10f ("mm, compaction: use free lists to quickly locate a migration target") Signed-off-by: Wonhyuk Yang --- mm/compaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 84fde270ae74..2e41e7ab1f55 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1380,7 +1380,7 @@ static int next_search_order(struct compact_control *cc, int order) static unsigned long fast_isolate_freepages(struct compact_control *cc) { - unsigned int limit = min(1U, freelist_scan_limit(cc) >> 1); + unsigned int limit = max(1U, freelist_scan_limit(cc) >> 1); unsigned int nr_scanned = 0; unsigned long low_pfn, min_pfn, highest = 0; unsigned long nr_isolated = 0; @@ -1456,7 +1456,7 @@ fast_isolate_freepages(struct compact_control *cc) high_pfn = pfn; /* Shorten the scan if a candidate is found */ - limit >>= 1; + limit = max(1U, limit >> 1); } if (order_scanned >= limit) @@ -1496,7 +1496,7 @@ fast_isolate_freepages(struct compact_control *cc) * to freelist_scan_limit. */ if (order_scanned >= limit) - limit = min(1U, limit >> 1); + limit = max(1U, limit >> 1); } if (!page) {