From patchwork Sat Jan 23 15:43:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wonhyuk Yang X-Patchwork-Id: 12041719 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 681D4C433DB for ; Sat, 23 Jan 2021 15:43:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EEE2523340 for ; Sat, 23 Jan 2021 15:43:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEE2523340 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 007996B0005; Sat, 23 Jan 2021 10:43:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EFA496B0007; Sat, 23 Jan 2021 10:43:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE93B6B0008; Sat, 23 Jan 2021 10:43:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id C69866B0005 for ; Sat, 23 Jan 2021 10:43:23 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 89747364E for ; Sat, 23 Jan 2021 15:43:23 +0000 (UTC) X-FDA: 77737459086.19.year75_5a0aef127575 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 6CBCD1ACC29 for ; Sat, 23 Jan 2021 15:43:23 +0000 (UTC) X-HE-Tag: year75_5a0aef127575 X-Filterd-Recvd-Size: 4786 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Sat, 23 Jan 2021 15:43:22 +0000 (UTC) Received: by mail-pl1-f172.google.com with SMTP id u11so4959112plg.13 for ; Sat, 23 Jan 2021 07:43:22 -0800 (PST) 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=g7rSut8M12UI/8Jufjep0A79fNAKKAr1pvc3Gl/0lTw=; b=LBD/ULtdVJX496qoU4dyqAIWhXyV+YGRleeXOWXuHMKsS1a5R7vsElnhSRuc5+Ed5x mQ+XzY/FDllM7QhQejheVNlCO0KjRRRlExqjFoFRNCB0M8cP1/shYl3ELv+30Oz+netf XQwNYL4WwZrrkS+WNhzdcoNXFRBLaMKirOk6wPxOMD+Eq2/g81x7FXTmOxVVGx0OiK3V cjEj++TuqMH0CT3/GU5jLW1PNL8aCnAxls38R/CokCIQ3fKDJkdmgAHgKhqsW8nZ/1T2 uamuXJIiIPjs95k8GyBPgORAWKXmIdEE8IFbVWalzTNGyQvQNkirXfxFgk9JkAwSvXLT LlIQ== 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=g7rSut8M12UI/8Jufjep0A79fNAKKAr1pvc3Gl/0lTw=; b=Y9b0hEA2/2umnLeh0GushdEaNy9DXMOnkI/1Pl3xXD0UmZFps9t3mlS6GUqcNSOVab jzC/P52+CepET6VB2SWTZ6xgV02bBQAKX4BAzOw4gTfGrwxubJDC2bMmmfTEYjYAt5bW nk0Xx3A3S+Oxyv3KUplI+0QNxTydByW3k5dXJpgYHnAhuVGMhMFFQo2MlyemTUmel+0p X6utTVpCxx94WPL9aRZocWnT+VNIFmMwhmbcC6tCHFoXC934jgwLFUhRS9a6Sfo+d7nA Tgtgyeen9z68LCrcKfuK0UVkANejPv8UavboY4QDSAIAvMpU4+a+GnN5WvdoxrWWq9py fndA== X-Gm-Message-State: AOAM532awA6u4zd1ogw5ghUqFEv91wwcpjKzWEggJZeC9E/HFSUET7Vo UxztgEe48f+gTMoV3oEADEw= X-Google-Smtp-Source: ABdhPJxYyCI3VueHfXL5Tt2BLhP61txDYmFBiAJtrvBUvQ6EwRrOZdfZJw4BxQYxzd0h8YVy53MbXg== X-Received: by 2002:a17:902:edcb:b029:df:cce5:1105 with SMTP id q11-20020a170902edcbb02900dfcce51105mr10495158plk.2.1611416602104; Sat, 23 Jan 2021 07:43:22 -0800 (PST) Received: from DESKTOP-FCFI5AT.localdomain ([125.131.156.99]) by smtp.gmail.com with ESMTPSA id x125sm8675631pfd.17.2021.01.23.07.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Jan 2021 07:43:21 -0800 (PST) From: Wonhyuk Yang To: Andrew Morton Cc: Mel Gorman , Vlastimil Babka , linux-mm@kvack.org, Wonhyuk Yang Subject: [PATCH] mm/compactoin: Fix edge case of fast_find_migrateblock() Date: Sun, 24 Jan 2021 00:43:20 +0900 Message-Id: <20210123154320.24278-1-vvghjk1234@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000023, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: In the fast_find_migrateblock(), It iterate freelist to find proper pageblock. But there are two edge cases. First, if the page we found is equal to cc->migrate_pfn, it is considered that we didn't found suitable pageblock. Second, if the loop was terminated because order is less than PAGE_ALLOC_COSTLY_ORDER, it could be considered that we found suitable one. Fixes: 70b44595eafe9 ("mm, compaction: use free lists to quickly locate a migration source") Signed-off-by: Wonhyuk Yang Acked-by: Vlastimil Babka --- mm/compaction.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index e5acb9714436..46f49e6b7d1a 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1742,8 +1742,8 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) distance >>= 2; high_pfn = pageblock_start_pfn(cc->migrate_pfn + distance); - for (order = cc->order - 1; - order >= PAGE_ALLOC_COSTLY_ORDER && pfn == cc->migrate_pfn && nr_scanned < limit; + for (order = cc->order - 1, pfn = high_pfn; + order >= PAGE_ALLOC_COSTLY_ORDER && pfn == high_pfn && nr_scanned < limit; order--) { struct free_area *area = &cc->zone->free_area[order]; struct list_head *freelist; @@ -1785,7 +1785,6 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) } if (nr_scanned >= limit) { - cc->fast_search_fail++; move_freelist_tail(freelist, freepage); break; } @@ -1799,9 +1798,10 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) * If fast scanning failed then use a cached entry for a page block * that had free pages as the basis for starting a linear scan. */ - if (pfn == cc->migrate_pfn) + if (pfn == high_pfn) { + cc->fast_search_fail++; pfn = reinit_migrate_pfn(cc); - + } return pfn; }