Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp609313rwd; Mon, 12 Jun 2023 19:53:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zvxt/oG+c8AnsTQHCCTUGhx/GRq6eRbdNPp2futGfgwQ9SXRvrRAFJceR0/7Zpy76RU6a X-Received: by 2002:a17:906:da87:b0:974:1c91:a752 with SMTP id xh7-20020a170906da8700b009741c91a752mr10821282ejb.5.1686624820060; Mon, 12 Jun 2023 19:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686624820; cv=none; d=google.com; s=arc-20160816; b=DCGQ8WIwiCeDwle0zLzCleQv/pbJWgoCZUP888s4lBj2yknLfPs/Fg38TLHQEaoDev yuAelpT3NvRaSWj7NOcGSKyUXCawhyWqfAp5vhVwF/g4G2WSCs+LmFi92lc1kXZIWHf6 m602sAUlG4n/35u87R0pfxhRtuMtEWI6dOFSwps8BWHHCHb5JnIzcg3Yvs0tzTT/oi8U 1mFAOQmNqJ22nVPDeT2Gr64tp8DfbktfJYwJqSJJ95M6zp1kIUxGcGz/GFGeBZ3Uer2i Fo8jKv9qy79J7coeVU5ng4En92dewfnGbju39Y1zDbD35ShUMtZvHt2e9QZ9IzgJaMGs WyVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=T8hiqc33k74I8IOoT0NeZkKnHUHeYF7RXjqLWrqMm7Q=; b=fNnqL+bK9EDr9oezfK/PBYSrLryOwDtWzC81WU6bTMY1kn4UzR9Gt0zQNElDfAx7ML jMFDej75i0adIZTn+4x1HGODOm5zQo2HDr9zixpnV+rKn50OzbQIk7TIH5aFO8adm8O6 Zlgl4ackJFv/GngnFtmOpE05JLaK8qDpodQR2Fpu/9t0n4MKeW3IQGU3tgC3dSOPNIwX AOPcW5QQBGQ2U5ZOeBl1oeMzp/b9ZN7ptUm9Mm3hmaco+6rAK8YINDntDbeQxXxgvePT ehZpshJ7JfjmP92cmSPiMZocm+3Lz0OPaPVFhFLCYP0pwRpgzho5m3o1cnO7gtV5CPcl 1RaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020a170906170a00b0096f8fc8e668si5873607eje.673.2023.06.12.19.53.15; Mon, 12 Jun 2023 19:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235251AbjFMBxP (ORCPT + 99 others); Mon, 12 Jun 2023 21:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238874AbjFMBxL (ORCPT ); Mon, 12 Jun 2023 21:53:11 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3684D19A7 for ; Mon, 12 Jun 2023 18:53:06 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QgBQC0R56zTlNd; Tue, 13 Jun 2023 09:52:35 +0800 (CST) Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 13 Jun 2023 09:53:03 +0800 Message-ID: <99dabd49-16c7-2858-e502-1bb390e13859@huawei.com> Date: Tue, 13 Jun 2023 09:53:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH -next 1/2] mm: compaction: convert to use a folio in isolate_migratepages_block() Content-Language: en-US To: Matthew Wilcox CC: , , , , References: <20230612143414.186389-1-wangkefeng.wang@huawei.com> From: Kefeng Wang In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/6/12 22:41, Matthew Wilcox wrote: > On Mon, Jun 12, 2023 at 10:34:13PM +0800, Kefeng Wang wrote: >> @@ -959,7 +960,8 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, >> * Hugepage was successfully isolated and placed >> * on the cc->migratepages list. >> */ >> - low_pfn += compound_nr(page) - 1; >> + folio = page_folio(page); >> + low_pfn += folio_nr_pages(folio) - 1; >> goto isolate_success_no_list; > > Why is this safe? That is, how do we know that the folio can't be > dissolved under us at this point, then reallocated and hit the > VM_BUG_ON_PGFLAGS(PageTail(page), page) in folio_flags() when we > test folio_test_large()? This is successfully isolated path, after isolate_hugetlb(), the folio reference is incremented, so I think the folio can't be dissolved here, correct me if I am wrong. > >> @@ -1132,30 +1137,30 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, >> * and it's on LRU. It can only be a THP so the order >> * is safe to read and it's 0 for tail pages. >> */ > > ^^^ This comment needs to be updated too. will update > >> - mod_node_page_state(page_pgdat(page), >> - NR_ISOLATED_ANON + page_is_file_lru(page), >> - thp_nr_pages(page)); >> + lruvec_del_folio(lruvec, folio); >> + mod_node_page_state(folio_pgdat(folio), >> + NR_ISOLATED_ANON + folio_is_file_lru(folio), >> + folio_nr_pages(folio)); > > node_stat_mod_folio() > ok Thanks >