From mboxrd@z Thu Jan 1 00:00:00 1970 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 03C94EB64DD for ; Tue, 1 Aug 2023 08:15:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 55A598E0003; Tue, 1 Aug 2023 04:15:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 50B118E0002; Tue, 1 Aug 2023 04:15:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FA4C8E0003; Tue, 1 Aug 2023 04:15:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2D1578E0002 for ; Tue, 1 Aug 2023 04:15:10 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D6D87120495 for ; Tue, 1 Aug 2023 08:15:09 +0000 (UTC) X-FDA: 81074825538.27.DA7E2FD Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) by imf18.hostedemail.com (Postfix) with ESMTP id 1E8DD1C0002 for ; Tue, 1 Aug 2023 08:15:06 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf18.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.112 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690877708; a=rsa-sha256; cv=none; b=LeGDxF29wA/WvpU7dl/aicOPZZXpwpjnQ44K2uRPfapjpDdt8qp788wtBB/+4LR2kP/jHH I9n4OPdp4Rlj/vb0XzoDehh5TsA6eqWX6GSmyiw9MEk4NDTLuPho5N4PI62/sG245vBxhp 9C7DAZ0X0Lcn+OpiHFx0knSI6wHpocg= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf18.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.112 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690877708; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VkZsgPiool8gHXE/N40kk/pyPAgd37AqnpHtHLp39uM=; b=mePFI+WgK+FtU8E9XHKzyd/TcAiSwcscnq3h0cZfOwqwE1JER1MpZM6sbghCxLnGqd4/dV CdP+a86Zh9d6xc5mHp4Py8+FxIaGc+q/lrB97kw9ZC7GCaVXrHDsVlX8btRd44gKTQkZ6E OosktQ97d/9v6QfIRVvfhHEGLHaI5mw= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R831e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VopS8qt_1690877699; Received: from 30.97.48.66(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0VopS8qt_1690877699) by smtp.aliyun-inc.com; Tue, 01 Aug 2023 16:15:00 +0800 Message-ID: <266af290-fede-88a8-5cb2-0d03f551bee4@linux.alibaba.com> Date: Tue, 1 Aug 2023 16:15:27 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 4/8] mm/compaction: remove stale fast_find_block flag in isolate_migratepages To: Kemeng Shi , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, mgorman@techsingularity.net, willy@infradead.org, david@redhat.com References: <20230728171037.2219226-1-shikemeng@huaweicloud.com> <20230728171037.2219226-5-shikemeng@huaweicloud.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1E8DD1C0002 X-Stat-Signature: 78dd4j315d4kazry6smapjtskerb6mym X-Rspam-User: X-HE-Tag: 1690877706-28859 X-HE-Meta: U2FsdGVkX18autQyi645Mx9dKikZntbyVpSQkWp0SILKii1dpJPo6ujT94CaesNQBkulPcwkgh12bMtZf0o6IGmaIqGCrAczhvlpRhAIuw7M922Bhle9zD3sqYZr+u01Zz0HoCl+nIKO8bo2XRo7agPljM63ayDxe5pd6TgsVP2BImHb+xjpCdDhNXkdgzm2AtZLwWyensAWqPmZbrjz0dHpfTWES5/p3QhphIW9aJzYfnSRiC+Xomt8v1BzwTAkrAuZAnWkmPokjFhHA7T96FYxIFhBrNwGmUTD194Cue69jfYqlRzTBAr0A+bfvayVUGc32drH3+Bb56TKIpggbkQr90mUA8gtU97y5V6OfpVxBtAFGf5AvkDT3a3auVMp3q8gJUR8xlT1z6eQiptS44VFsymQiWXCqhVRJXi5QzJUkVZtxZlsvZox73X49pDxNVyWmTTlYeKVqsvftQy+IHZ8yw9NCUoyMACjDsYPE+m+xRgmBe/r9BnsD7K3wiZKdV3Q+mvG8IopTnrmFzSogmeOlU/B29Con4dW+nC7e2vGH0Mf7ghGTYpOaY6TcJ8P2Vd+/74MifmVGFVaLkrru8ZapyfB7H8vcjXWiG1BmSXIe5AvsMstsDqqPE3L+/vJPugQF2Gnj1pa3YNJvX7bM2qhAhZuZJ8iuqkVsh7mM9LxFzIgEXsu++k+JbATM9nwTdm7jb0XaxS+tiE9jNwhqHYNnninx+C/OgwFbFdrBwzMThSm++VDcjU9sGJWNVwAP9PXSJBjJ3fduwZqlyR83CSUXGdwiJN7PwXM29Dp92gIdD7oxpNZtjuMfW9WCXlW1WMMUzstBN0UCGzjbr1wDjfVqYVIHbm9m9oH+Q3y6VI+6CALAEAsUhieXAOmiWGhJhs7YW89pihHNgvLuWtaf7HFAxUqwJBNjIXdqWdIiZzxTuqGVFdyRQM4rwiK5spG9b+wuJR/8dkhUSEzYDQ QMTr/LTl NO7x6Fn5yyd+OhqsgTw9WCSI8WhN4hVi0bV/fo945HbnIFYpmK1KKeQsSCJ071UqtFgzIesAS1iUyjdX/X8hBZjuDhbxtcg6f9TbCvWNGEIdPl6JheZ7xiZvSg2P03vMLWKgZyKMtQtomDOvY1lzpMm2ZZeT8TNt4QhDbOGlEWl8rVFx+wcKK4KxqTcaUg9r5oa6f 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: On 8/1/2023 11:48 AM, Kemeng Shi wrote: > > > on 8/1/2023 11:34 AM, Baolin Wang wrote: >> >> >> On 8/1/2023 11:24 AM, Kemeng Shi wrote: >>> >>> >>> on 8/1/2023 10:42 AM, Baolin Wang wrote: >>>> >>>> >>>> On 7/29/2023 1:10 AM, Kemeng Shi wrote: >>>>> In old code, we set skip to found page block in fast_find_migrateblock. So >>>>> we use fast_find_block to avoid skip found page block from >>>>> fast_find_migrateblock. >>>>> In 90ed667c03fe5 ("Revert "Revert "mm/compaction: fix set skip in >>>>> fast_find_migrateblock"""), we remove skip set in fast_find_migrateblock, >>>>> then fast_find_block is useless. >>>>> >>>>> Signed-off-by: Kemeng Shi >>>>> --- >>>>>    mm/compaction.c | 12 +----------- >>>>>    1 file changed, 1 insertion(+), 11 deletions(-) >>>>> >>>>> diff --git a/mm/compaction.c b/mm/compaction.c >>>>> index ad535f880c70..09c36251c613 100644 >>>>> --- a/mm/compaction.c >>>>> +++ b/mm/compaction.c >>>>> @@ -1949,7 +1949,6 @@ static isolate_migrate_t isolate_migratepages(struct compact_control *cc) >>>>>        const isolate_mode_t isolate_mode = >>>>>            (sysctl_compact_unevictable_allowed ? ISOLATE_UNEVICTABLE : 0) | >>>>>            (cc->mode != MIGRATE_SYNC ? ISOLATE_ASYNC_MIGRATE : 0); >>>>> -    bool fast_find_block; >>>>>          /* >>>>>         * Start at where we last stopped, or beginning of the zone as >>>>> @@ -1961,13 +1960,6 @@ static isolate_migrate_t isolate_migratepages(struct compact_control *cc) >>>>>        if (block_start_pfn < cc->zone->zone_start_pfn) >>>>>            block_start_pfn = cc->zone->zone_start_pfn; >>>>>    -    /* >>>>> -     * fast_find_migrateblock marks a pageblock skipped so to avoid >>>>> -     * the isolation_suitable check below, check whether the fast >>>>> -     * search was successful. >>>>> -     */ >>>>> -    fast_find_block = low_pfn != cc->migrate_pfn && !cc->fast_search_fail; >>>>> - >>>>>        /* Only scan within a pageblock boundary */ >>>>>        block_end_pfn = pageblock_end_pfn(low_pfn); >>>>>    @@ -1976,7 +1968,6 @@ static isolate_migrate_t isolate_migratepages(struct compact_control *cc) >>>>>         * Do not cross the free scanner. >>>>>         */ >>>>>        for (; block_end_pfn <= cc->free_pfn; >>>>> -            fast_find_block = false, >>>>>                cc->migrate_pfn = low_pfn = block_end_pfn, >>>>>                block_start_pfn = block_end_pfn, >>>>>                block_end_pfn += pageblock_nr_pages) { >>>>> @@ -2007,8 +1998,7 @@ static isolate_migrate_t isolate_migratepages(struct compact_control *cc) >>>>>             * before making it "skip" so other compaction instances do >>>>>             * not scan the same block. >>>>>             */ >>>>> -        if (pageblock_aligned(low_pfn) && >>>>> -            !fast_find_block && !isolation_suitable(cc, page)) >>>>> +        if (pageblock_aligned(low_pfn) && !isolation_suitable(cc, page)) >>>> >>>> I do not think so. If the pageblock is found by fast_find_migrateblock(), that means it definitely has not been set the skip flag, so there is not need to call isolation_suitable() if fast_find_block is true, right? >>>> >>>> >>> Actually, found pageblock could be set skip as: >>> 1. other compactor could mark this pageblock as skip after zone lock is realeased >>> in fast_find_migrateblock. >> >> Yes, but your patch also can not close this race window, that means it can also be set skip flag after the isolation_suitable() validation by other compactors. >> > Yes, I think it's still worth to remove a lot of fast_find_block relevant check and reduce > code complexity with one redundant isolation_suitable which may skip some block with luck. >>> 2. fast_find_migrateblock may uses pfn from reinit_migrate_pfn which is previously found >>> and sacnned. It could be fully sacnned and marked skip after it's first return from >> >> Right, but now the 'fast_find_block' is false, and we will call isolation_suitable() to validate the skip flag. >> > Right, sorry for missing that. > > But it's ok to keep the fast_find_block if you insist and I will just correct the stale Yes, I still prefer to keep the fast_find_block, since I did not see this patch can fix any real issue and might have a side effect for fast-find-pageblock(?). > comment that "fast_find_migrateblock marks a pageblock skipped ..." in next version. Sure, please do it.