From patchwork Wed Jun 21 07:39:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Liu X-Patchwork-Id: 13286799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2676AEB64D8 for ; Wed, 21 Jun 2023 07:39:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B2FDF8D0002; Wed, 21 Jun 2023 03:39:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ADF6E8D0001; Wed, 21 Jun 2023 03:39:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CEAF8D0002; Wed, 21 Jun 2023 03:39:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8DD808D0001 for ; Wed, 21 Jun 2023 03:39:34 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5EE8A140774 for ; Wed, 21 Jun 2023 07:39:34 +0000 (UTC) X-FDA: 80925955068.21.5FBB3D5 Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.226]) by imf24.hostedemail.com (Postfix) with ESMTP id AD576180014 for ; Wed, 21 Jun 2023 07:39:30 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf24.hostedemail.com: domain of liuq131@chinatelecom.cn designates 42.123.76.226 as permitted sender) smtp.mailfrom=liuq131@chinatelecom.cn ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687333171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=vtTW+5CGIPXxWpOId8QWI7C8dXDnB9CdzN4pA0mQPqg=; b=RgqaqVY83jCSJqSKMe19GLiTtZVHkBA5vR+rLgdtRcMM9vygDTE99YIPQagoDnkN5fAICg jRcVPnsT2bUnCdHRdFPGm7oNAiPMe1PaSlSen/yqSh/CYlf73NecR1CEDM7WAXWa04icTA riLyUryUohmOLcRbBp/y9wAHLZU1gns= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf24.hostedemail.com: domain of liuq131@chinatelecom.cn designates 42.123.76.226 as permitted sender) smtp.mailfrom=liuq131@chinatelecom.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687333171; a=rsa-sha256; cv=none; b=tb4QrdfWYM3iTty6XWKocTVUEtqXK8P4HB2SGndCxrK7mR5fP9lypUz+XN1zipBxVFHJcd NnAYL7HuAmlrkm3M/ubkUAWiA/EicL8NZ6+/nXOwdx+yTK+yXUM6YPrOk4MY7NTMl1swja OwMb4W6YkbA0RZyBvOeFl6Wv0bHXBJk= HMM_SOURCE_IP: 172.18.0.218:48856.2131214271 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-36.111.64.85 (unknown [172.18.0.218]) by chinatelecom.cn (HERMES) with SMTP id A2234280099; Wed, 21 Jun 2023 15:39:22 +0800 (CST) X-189-SAVE-TO-SEND: +liuq131@chinatelecom.cn Received: from ([36.111.64.85]) by app0025 with ESMTP id 7601d43524a14bd38a38d662434cb33b for akpm@linux-foundation.org; Wed, 21 Jun 2023 15:39:25 CST X-Transaction-ID: 7601d43524a14bd38a38d662434cb33b X-Real-From: liuq131@chinatelecom.cn X-Receive-IP: 36.111.64.85 X-MEDUSA-Status: 0 From: liuq To: akpm@linux-foundation.org Cc: ying.huang@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, liuq Subject: [PATCH v2] mm/min_free_kbytes: modify min_free_kbytes calculation rules Date: Wed, 21 Jun 2023 15:39:12 +0800 Message-Id: <20230621073912.21747-1-liuq131@chinatelecom.cn> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: AD576180014 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cw94nqm1ogpf3srhnahz7b1fyobxuzku X-HE-Tag: 1687333170-27065 X-HE-Meta: U2FsdGVkX1/UcYP6CUrIfknrAKzT+Qw9cMwakKcht1zRjHfPbkthjN+zoIBMyCUu/Ksb55k0yKVqfakNl7VX+9GwM19ESPJCTkRvD/sIs2ltaD5e+tMCsn21ts6ZSPSNEv2OSj+ewaY7U7Mzh1O2dKggfxAFQ62aBpBK6lD55GTq7y+wKFOK/R+zZ5JHNkdLeyOCkPMvrdPnKAAvLMSQBA7UVmxd6YJSAGFvEnSmaGI7uCU6zapvptHoF0omFHXVPnQk6aL1JNsoTVuNi5X3eK3Zndj62eITP8vjsDAhpOSEvtkSfXpDfL0H8XD/soYsnKBpIcQ/dnT7szEJQfs9NByPA6csSHLvuIXCyfVW4GTjFrsDCSmDBy9y8yAhOqFon0/kwaTR7mkPDS1dMTyUfEZYKutRgUgP21RFMDbpvzdloGXFxGMXUM0/nLvqJaoXUZkJiZzDxX1DPFdL/wofzKLzyRMEouvDCuUzrtvjGVu8ad0ZC4MVBTMAD8qxm26Gx0Bc/dGD88iVhb5FVcM/LgYNfVH0INdrnmz0Ga4EQQNJ780bO9bgAjng8ye0CCQ7zWZWSsHBk4PFPBD2u+RppKyFn0bhjMw1OY0EkNKhVf09MwamQ21RXPja40E16tkTGulh615OY1g/eAfzA5CdEe/xRjMY/wygMtEsUfq20wOYzUkm1btf+3b5NGmYMmuePkhgq3SffGOZ3B4rfYaHORg6fP7y1za62MUBNIJxYAEZ8tVlOt5kbsQOpgRrc0rDc99sKRAl0NQh3sa/FIXoix6/2ATSEyy8ZySeYA616hAJv2d9rpT9B4PkqqNfaSuEu1aoonwXhLgyJ7/i43Lr1m9gr9+uu5e4v+qqEZQPA4TOxeo0xNcWAkjC6lQc8FtMmSUjYvNMLFfExN0FRl4EGGvdNlfQbpnW9XxcM44E8iZrd3gWEFJk4884MXu1QR3/0nSBJA9frv4E94wFanP cObmDe95 zQqokgiTMDCt33yhlPR8odQ4JZSJLFo+7jwXklvz68cfAmSTJe26JDZabSwEL/3GjVJX59RmVu/RkKEie7UAxcHKSJdvazs7X98t3VlaD7sGAetghTOhCaI9T391VlswHzLzcWHWnZZm/ceh2TLOaYQm+ZQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.189238, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The current calculation of min_free_kbytes only uses ZONE_DMA and ZONE_NORMAL pages,but the ZONE_MOVABLE zone->_watermark[WMARK_MIN] will also divide part of min_free_kbytes.This will cause the min watermark of ZONE_NORMAL to be too small in the presence of ZONE_MOVEABLE. __GFP_HIGH and PF_MEMALLOC allocations usually don't need moveable zone pages, so just like ZONE_HIGHMEM, cap pages_min to a small value in __setup_per_zone_wmarks. Signed-off-by: liuq --- mm/page_alloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 47421bedc12b..608384712a89 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6364,7 +6364,7 @@ static void __setup_per_zone_wmarks(void) /* Calculate total number of !ZONE_HIGHMEM pages */ for_each_zone(zone) { - if (!is_highmem(zone)) + if (!is_highmem(zone) || zone_idx(zone) != ZONE_MOVABLE) lowmem_pages += zone_managed_pages(zone); } @@ -6374,7 +6374,7 @@ static void __setup_per_zone_wmarks(void) spin_lock_irqsave(&zone->lock, flags); tmp = (u64)pages_min * zone_managed_pages(zone); do_div(tmp, lowmem_pages); - if (is_highmem(zone)) { + if (is_highmem(zone) || zone_idx(zone) == ZONE_MOVABLE) { /* * __GFP_HIGH and PF_MEMALLOC allocations usually don't * need highmem pages, so cap pages_min to a small