Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp499244pxj; Thu, 27 May 2021 05:27:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy4mwMn5VtvtdOHoeu/LgT9yhmZFw97R8V24KCzp7NmFPyNvz+GNDQ65V6PBdHGP8yxE4N X-Received: by 2002:a17:906:f2ca:: with SMTP id gz10mr3599067ejb.317.1622118447928; Thu, 27 May 2021 05:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622118447; cv=none; d=google.com; s=arc-20160816; b=hXukmYEDVwcMLLe8Bwvibz+1ckes89bBcsBd7UOig2kA15/ZMnuJ/49cXqNTuQgOYI nBw5EoooSrkclHtW/cJWJDM9xVe2Sz/y0MU5Id9gg9eoHuIFxi8XZ1TtosRl5B9zoq0j NbMD42zAWPeffsG9UGlwuUHPnYdwVKW8IaQjPxwfip4rYLTBeXMCPLwcymasGA6ss3AN 4JzyhaMQKViTWKQ7HjjYJ2LCR8raQfeNGvMIcw98Ae33cM7lER2vhTsngj3zBpCA0nKo Z+4smRNFtv8pwJZpNY9llHzB9is2i75Wo1/2eaGn1/6/UiSEH7r1NHae1Ok374uHvf9O SDNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=PrFbZTkFz8e58etzs7fi1NswPkp2p00JA0FvEjqC0ns=; b=sULaJwRfpr+EP9RV9u9bvNKNa4hFUvhUoDMQXKzitIvSlMXJ+AvrgQsaDeCUhl1+pO IuRfk/wsdziKYgIq9lCfD0kxF9RjnYF9yMc+P6QdbOHOlYTSvsoT4pXWioUB31LjaFKt BYvsvOsECwgjiFBNsCVh8ZevK/vs7CCA6Zp3inoPIIXfYf2wDSI3Ob7PtPjN5bfTKhIy /KRtOUkVcxGrysoZ94njItfsaCSFb5j2oC8T4qFkt2j3g1T5CD9GVnz6YpY7TleXNHog F8zWKfosBe/A51lFb9h84TVAO13iwuai5sVLvvxh/lX9ag/zWG2rBdoAZMWggu0rdDAD D/TQ== 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 jz8si1825593ejc.34.2021.05.27.05.27.02; Thu, 27 May 2021 05:27:27 -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 S235358AbhE0M0C (ORCPT + 99 others); Thu, 27 May 2021 08:26:02 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:5115 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235335AbhE0MZ6 (ORCPT ); Thu, 27 May 2021 08:25:58 -0400 Received: from dggeml716-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FrRks5nz6zYnT6; Thu, 27 May 2021 20:21:41 +0800 (CST) Received: from dggpemm500009.china.huawei.com (7.185.36.225) by dggeml716-chm.china.huawei.com (10.3.17.127) 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 20:24:21 +0800 Received: from huawei.com (10.175.113.32) 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 20:24:21 +0800 From: Liu Shixin To: Andrew Morton , yangerkun , Kefeng Wang CC: , , Liu Shixin Subject: [PATCH] mm/page_alloc: fix counting of managed_pages Date: Thu, 27 May 2021 20:57:07 +0800 Message-ID: <20210527125707.3760259-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.18.0.huawei.25 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.113.32] 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 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; - } } } } -- 2.18.0.huawei.25