Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4149030rwb; Tue, 6 Sep 2022 03:23:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR6oNIK86inDgPesZm91oeyte3KLs9QF1I8ZjOtwL99se6z0rbWlx6hGPlkLsgoOeZ4TYNNH X-Received: by 2002:a05:6402:1ad1:b0:44e:8dfb:2d04 with SMTP id ba17-20020a0564021ad100b0044e8dfb2d04mr6693534edb.400.1662459826091; Tue, 06 Sep 2022 03:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662459826; cv=none; d=google.com; s=arc-20160816; b=IbNXmIASoAm1F35fT5vMO2oBRyQ1pdgmdFsJc1ckhKmmG0eQMy05il7tORcZ8HDSQ/ q3Et0R9cT0nsDGhnyVConAwZpoGgY1Uw9h9j3gT2HSF8KvitAGP6Bgis7JI+5pLv1/O9 rIx5RzWPIGLSw8quAQAx8cXrvJAv2kLFgaJbBkPIpPyHJtEc0DSYq1sqtFyMgJ49d6G3 FVmSOYzB2TMoaI1OJ5Q5h0SC4mqGBDZiFN8cnIypaEVzmZGLLPUtiJHk5kLEhdyABZX8 oKG924oNIuHn3G8KFGJ7OM0kAF2+M2re0u358YM6uZjNygXHBkZoCkrwMg9rS84KjA02 iYgg== 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:to:content-language:subject:cc:user-agent:mime-version :date:message-id; bh=Do43KjkPXRWa3agvIJuG+TlazDnFlvMqe2beiZS7Jt4=; b=nlZiPg9xtW8zWgBIg/3Fr5GOY3+u5+5KydGlGkcBpREf2P4RrVFNsvoZv7B605qhnh YU25xzdetQUipfJY+OceVEcVHH1PFKMH38GdAG8KHjYZOBhqr8o6MXLbCOZeHUQz2UnA vNW4nMwADKRc5C/ITjS2FAmDLljWvyz8nDO7gXfpWjkZ0LJLxMVjgXzGahHCWwJrwN01 ryOiG9ZRZ2Ha+dxZJtOaeGKC0YKC8G61pacOVa6Anh7RkyJi1vnRyYdkx9J/WSzHpd5a 7cUZUfWRFMw8xg7Bw/dBhHoZrQEbC5Mmc/OU0G5g3CfgQKe1HiJeu7rd+WQnavMAA1wH lCig== 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 gn17-20020a1709070d1100b007413ed9efb1si11091699ejc.543.2022.09.06.03.23.20; Tue, 06 Sep 2022 03:23:46 -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 S234204AbiIFKMa (ORCPT + 99 others); Tue, 6 Sep 2022 06:12:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233830AbiIFKM2 (ORCPT ); Tue, 6 Sep 2022 06:12:28 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D18511E3EC for ; Tue, 6 Sep 2022 03:12:26 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MMLgn34dCzkWy2; Tue, 6 Sep 2022 18:08:37 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 6 Sep 2022 18:12:24 +0800 Received: from [10.174.178.120] (10.174.178.120) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 6 Sep 2022 18:12:23 +0800 Message-ID: Date: Tue, 6 Sep 2022 18:12:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 CC: , , , , , , , , , , , , , , , , , Subject: Re: [PATCH -next v3 1/2] mm: Cap zone movable's min wmark to small value Content-Language: en-US To: References: <20220905032858.1462927-1-mawupeng1@huawei.com> <20220905032858.1462927-2-mawupeng1@huawei.com> <20220905092619.2533krnnx632hswc@suse.de> From: mawupeng In-Reply-To: <20220905092619.2533krnnx632hswc@suse.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.120] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-6.0 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 2022/9/5 17:26, Mel Gorman wrote: > On Mon, Sep 05, 2022 at 11:28:57AM +0800, Wupeng Ma wrote: >> From: Ma Wupeng >> >> Since min_free_kbytes is based on gfp_zone(GFP_USER) which does not include >> zone movable. However zone movable will get its min share in >> __setup_per_zone_wmarks() which does not make any sense. >> >> And like highmem pages, __GFP_HIGH and PF_MEMALLOC allocations usually >> don't need movable pages, so there is no need to assign min pages for zone >> movable. >> >> Let's cap pages_min for zone movable to a small value here just link >> highmem pages. >> > > I think there is a misunderstanding why the higher zones have a watermark > and why it might be large. > > It's not about a __GFP_HIGH or PF_MEMALLOC allocations because it's known > that few of those allocations may be movable. It's because high memory > allocations indirectly pin pages in lower zones. User-mapped memory allocated > from ZONE_MOVABLE still needs page table pages allocated from a lower zone > so there is a ratio between the size of ZONE_MOVABLE and lower zones > that limits the total amount of memory that can be allocated. Similarly, > file backed pages that may be allocated from ZONE_MOVABLE still requires > pages from lower memory for the inode and other associated kernel > objects that are allocated from lower zones. > > The intent behind the higher zones having a large min watermark is so > that kswapd reclaims pages from there first to *potentially* release > pages from lower memory. By capping pages_min for zone_movable, there is > the potential for lower memory pressure to be higher and to reach a point > where a ZONE_MOVABLE page cannot be allocated simply because there isn't > enough low memory available. Once the lower zones are all unreclaimable > (e.g. page table pages or the movable pages are not been reclaimed to free > the associated kernel structures), the system goes OOM. This i do agree with you, lower zone is actually "more important" than the higher one. But higher min watermark for zone movable will not work since no memory allocation can use this reserve memory below min. Memory allocation with specify watermark modifier(__GFP_ATOMIC ,__GFP_HIGH ...) can use this in slowpath, however the standard movable memory allocation (gfp flag: GFP_HIGHUSER_MOVABLE) does not contain this. Second, lowmem_reserve_ratio is used to "reserve" memory for lower zone. And the second patch introduce per zone watermark_scale_factor to boost normal/movable zone's watermark which can trigger early kswapd for zone movable. > > It's possible that there are safe adjustments that could be made that > would detect when there is no choice except to reclaim zone reclaimable > but it would be tricky and it's not this patch. This patch changelog states > > However zone movable will get its min share in > __setup_per_zone_wmarks() which does not make any sense. > > It makes sense, higher zones allocations indirectly pin pages in lower > zones and there is a bias in reclaim to free the higher zone pages first > on the *possibility* that lower zone pages get indirectly released later. > In our Test vm with 16G of mirrored memory(normal zone) and 256 of normal momory(Movable zone), the min share for normal zone is too few since the size of min watermark is calc by zone dma/normal while this will be shared by zones(include zone movable) based on managed pages. Node 0, zone DMA min 39 low 743 high 1447 Node 0, zone Normal min 180 low 3372 high 6564 Node 1, zone Movable min 3728 low 69788 high 135848