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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A79F9C433F5 for ; Thu, 12 May 2022 02:27:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240782AbiELC1y (ORCPT ); Wed, 11 May 2022 22:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240794AbiELC1t (ORCPT ); Wed, 11 May 2022 22:27:49 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF31B3EB95 for ; Wed, 11 May 2022 19:27:47 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KzFyc5y0Zz1JBxk; Thu, 12 May 2022 10:26:32 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 12 May 2022 10:27:45 +0800 Subject: Re: [PATCH] mm, compaction: fast_find_migrateblock() should return pfn in the target zone To: Rei Yamamoto CC: , , , , , , References: <07e0ceb8-a637-b011-bbf6-ba760a0b12e4@huawei.com> <20220512014736.16376-1-yamamoto.rei@jp.fujitsu.com> From: Miaohe Lin Message-ID: <4cf33f9c-89bc-f845-10d7-2aa62a20f5e5@huawei.com> Date: Thu, 12 May 2022 10:27:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220512014736.16376-1-yamamoto.rei@jp.fujitsu.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/5/12 9:47, Rei Yamamoto wrote: > On Wed, 11 May 2022 17:26:16 Miaohe Lin wrote: >> On 2022/5/11 15:07, Rei Yamamoto wrote: >>> On Wed, 11 May 2022 14:25:34 Miaohe Lin wrote: >>>> On 2022/5/11 12:43, Rei Yamamoto wrote: >>>>> Prevent returning a pfn outside the target zone in case that not >>>>> aligned with pageblock boundary. >>>>> Otherwise isolate_migratepages_block() would handle pages not in >>>>> the target zone. >>>>> >>>> >>>> IIUC, the sole caller isolate_migratepages will ensure the pfn won't outside >>>> the target zone. So the below code change might not be necessary. Or am I miss >>>> something ? >>> >>> While block_start_pfn is ensured, this variable is not used as the argument for >>> isolate_migratepages_block(): >>> ----- >>> static isolate_migrate_t isolate_migratepages(struct compact_control *cc) >>> { >>> : >>> low_pfn = fast_find_migrateblock(cc); >>> block_start_pfn = pageblock_start_pfn(low_pfn); >>> if (block_start_pfn < cc->zone->zone_start_pfn) >>> block_start_pfn = cc->zone->zone_start_pfn; <--- block_start_pfn is ensured not outside >>> the target zone >>> : >>> block_end_pfn = pageblock_end_pfn(low_pfn); >>> : >>> 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) { >>> : >>> if (isolate_migratepages_block(cc, low_pfn, block_end_pfn, <--- low_pfn is passed as >>> the argument >> >> Sorry, I think you're right. And could you please add the runtime effect of this issue? >> >> Anyway, this patch looks good to me now. Thanks! > > Thank you for your review. > The runtime effect is that compaction become unintended behavior. > For example, pages not in the target zone are added to cc->migratepages list in isolate_migratepages_block(). > As a result, pages migrate between nodes unintentionally. Many thanks for clarifying. :) Is this worth a Fixes tag or even CC stable? Thanks! > > Thanks, > Rei > . >