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 X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9C3AC43331 for ; Tue, 24 Mar 2020 14:22:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9332620788 for ; Tue, 24 Mar 2020 14:22:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZRSjoqSA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9332620788 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4666E6B0005; Tue, 24 Mar 2020 10:22:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4169B6B0007; Tue, 24 Mar 2020 10:22:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 353F86B0008; Tue, 24 Mar 2020 10:22:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id 1B5446B0005 for ; Tue, 24 Mar 2020 10:22:49 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id EB99A87D3 for ; Tue, 24 Mar 2020 14:22:48 +0000 (UTC) X-FDA: 76630472016.12.rail13_6fd68a50b712b X-HE-Tag: rail13_6fd68a50b712b X-Filterd-Recvd-Size: 3952 Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by imf20.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Mar 2020 14:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585059767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=l3Lz3/NpN+EM4WUox3xNHgHxlnh2gL9sfw46cjDTFYo=; b=ZRSjoqSA6eoOr6E6lFp9NcMUatJvixZK2aHPRhfcnfgMYugkHllDV+48JM6MQpRPA4M7xr 13HTJtGxlPHhiQxdcKILS2m07zcUYCFAJ5YScsDn1DSBFXtKL7tMmG9JDfmqguE6qtRK3f PtUNqwdOQy2Q99kn5kOBLIRBcGi922o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-jkE5FCHvPOSeM9Tz3mtRwQ-1; Tue, 24 Mar 2020 10:22:44 -0400 X-MC-Unique: jkE5FCHvPOSeM9Tz3mtRwQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACD3A800D5E; Tue, 24 Mar 2020 14:22:42 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-69.pek2.redhat.com [10.72.12.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03AFD5C1B2; Tue, 24 Mar 2020 14:22:39 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, iamjoonsoo.kim@lge.com, hannes@cmpxchg.org, mhocko@kernel.org, vbabka@suse.cz, bhe@redhat.com Subject: [PATCH 2/5] mm/page_alloc.c: clear out zone->lowmem_reserve[] if the zone is empty Date: Tue, 24 Mar 2020 22:22:26 +0800 Message-Id: <20200324142229.12028-3-bhe@redhat.com> In-Reply-To: <20200324142229.12028-1-bhe@redhat.com> References: <20200324142229.12028-1-bhe@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When requesting memory allocation from a specific zone is not satisfied, it will fall to lower zone to try allocating memory. In this case, lower zone's ->lowmem_reserve[] will help protect its own memory resource. The higher the relevant ->lowmem_reserve[] is, the harder the upper zone can get memory from this lower zone. However, this protection mechanism should be applied to populated zone, but not an empty zone. So filling ->lowmem_reserve[] for empty zone is not necessary, and may mislead people that it's valid data in that zone. Node 2, zone DMA pages free 0 min 0 low 0 high 0 spanned 0 present 0 managed 0 protection: (0, 0, 1024, 1024) Node 2, zone DMA32 pages free 0 min 0 low 0 high 0 spanned 0 present 0 managed 0 protection: (0, 0, 1024, 1024) Node 2, zone Normal per-node stats nr_inactive_anon 0 nr_active_anon 143 nr_inactive_file 0 nr_active_file 0 nr_unevictable 0 nr_slab_reclaimable 45 nr_slab_unreclaimable 254 Here clear out zone->lowmem_reserve[] if zone is empty. Signed-off-by: Baoquan He --- mm/page_alloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c0c788798d8b..138a56c0f48f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7840,8 +7840,10 @@ static void setup_per_zone_lowmem_reserve(void) idx--; lower_zone = pgdat->node_zones + idx; - if (!sysctl_lowmem_reserve_ratio[idx]) { + if (!sysctl_lowmem_reserve_ratio[idx] || + !zone_managed_pages(lower_zone)) { lower_zone->lowmem_reserve[j] = 0; + continue; } else { lower_zone->lowmem_reserve[j] = managed_pages / sysctl_lowmem_reserve_ratio[idx]; -- 2.17.2