Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp538851pxj; Thu, 27 May 2021 06:17:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy0ZCFZL6EsyXpE57Ozh7OBqJ3CDEAtist4KcCxG9ao1z62ZGfJQhZjcAsVocNEWgXyK7r X-Received: by 2002:aa7:de8b:: with SMTP id j11mr4081358edv.363.1622121475838; Thu, 27 May 2021 06:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622121475; cv=none; d=google.com; s=arc-20160816; b=TuoJGhNJi8+HNNSDv0VR/8+qBksj02hqgN+5J0E4WKQbOUypGJ42An3Lh2caTZnMOa eR8SsFLnVPy4wkwff3e70R26le8htKGgRjQBb4KHO9ur6EdBpAGz1HmcqOBi51x0w0Jn 95/j72xLsBCzjKhsd04s7C2ozV+XjaLXIgFOWxb7MpR1IJEZQz4+W1O2xpCah/zFYhA1 AnXxWpjHjftGtJzdYzlcQHPZViZi3KjLWSdvABuCxcWlyFajDjQM/2tetqeBZjHZERZk zuDn40eZvf1bbnf+8JLKwJdQBW35aVfhFOlDxW6jrph2MzlkpaCrzG0rcGHOV4FSFoHI VV4Q== 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 :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=/F4TpXRVOUm4TudYJCGLGngqK+8s5mjNI+ShbK5srV8=; b=lWy1FImx1YdJeo38OeK2ajdMpguSwKVSy1FYoLJoX95sHoo3RIbRcPZPkTXpR4C5Aw +ka9g6GHG10T1nD6o7rXJ37lKGtHgIrmMZ0PNB4y9OoP5D7Gq7crssLBbHOAig2PxzHV QVkjSCGLvxq5T4Y15mtxxsS492a7Cq5fELvAh7K2oc6ecWNufVxJFn2FIjqOvQYoy0I7 lLFOGyfIKIiNmLfsQFelUHdl2hTOdcSZyOR5glSYotOV2I15vq1zfi0FuYu9h1m2McWe PHSgioTNsL68DjE6mHMKd+fohOFNeKmMDFI5G++VKCeyhVPbR30AWFEF0ATb394GiXQY ZWKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ov19si2047173ejb.437.2021.05.27.06.17.31; Thu, 27 May 2021 06:17:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236306AbhE0NPu (ORCPT + 99 others); Thu, 27 May 2021 09:15:50 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:2502 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235996AbhE0NPu (ORCPT ); Thu, 27 May 2021 09:15:50 -0400 Received: from dggeml759-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4FrSrP6fbMzYr0r; Thu, 27 May 2021 21:11:33 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggeml759-chm.china.huawei.com (10.1.199.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 27 May 2021 21:14:13 +0800 Received: from [10.174.179.24] (10.174.179.24) by dggpemm500009.china.huawei.com (7.185.36.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 27 May 2021 21:14:13 +0800 Subject: Re: [PATCH] mm/page_alloc: fix counting of managed_pages To: Andrew Morton , yangerkun , Kefeng Wang , Baoquan He References: <20210527125707.3760259-1-liushixin2@huawei.com> CC: , From: Liu Shixin Message-ID: <8ee4df3e-11f4-d826-e7cd-13e305024d9f@huawei.com> Date: Thu, 27 May 2021 21:14:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20210527125707.3760259-1-liushixin2@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.24] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500009.china.huawei.com (7.185.36.225) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + Baoquan On 2021/5/27 20:57, Liu Shixin wrote: > The commit f63661566fad (mm/page_alloc.c: clear out zone->lowmem_reserve[] > if the zone is empty) clear out zone->lowmem_reserve[] if zone is empty. > But when zone is not empty and sysctl_lowmem_reserve_ratio[i] is set to zero, > zone_managed_pages(zone) is not counted in the managed_pages either. This is > inconsistent with the description of lowmen_reserve, so fix it. > > Fixes: f63661566fad ("mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty") > Reported-by: yangerkun > Signed-off-by: Liu Shixin > --- > mm/page_alloc.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index aaa1655cf682..49a2efce5a84 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -8061,14 +8061,14 @@ static void setup_per_zone_lowmem_reserve(void) > unsigned long managed_pages = 0; > > for (j = i + 1; j < MAX_NR_ZONES; j++) { > - if (clear) { > - zone->lowmem_reserve[j] = 0; > - } else { > - struct zone *upper_zone = &pgdat->node_zones[j]; > + struct zone *upper_zone = &pgdat->node_zones[j]; > + > + managed_pages += zone_managed_pages(upper_zone); > > - managed_pages += zone_managed_pages(upper_zone); > + if (clear) > + zone->lowmem_reserve[j] = 0; > + else > zone->lowmem_reserve[j] = managed_pages / ratio; > - } > } > } > }