From patchwork Sun Jun 25 03:16:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiang Liu X-Patchwork-Id: 13291828 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 302E1EB64DA for ; Sun, 25 Jun 2023 03:17:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C7BD8D0001; Sat, 24 Jun 2023 23:17:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 677518D0002; Sat, 24 Jun 2023 23:17:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 597048D0001; Sat, 24 Jun 2023 23:17:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4A6D98D0001 for ; Sat, 24 Jun 2023 23:17:19 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0BE861A0346 for ; Sun, 25 Jun 2023 03:17:19 +0000 (UTC) X-FDA: 80939809398.04.7F9246A Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.226]) by imf27.hostedemail.com (Postfix) with ESMTP id D3D1440009 for ; Sun, 25 Jun 2023 03:17:15 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.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=1687663037; 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=tcdxbrCXkp98Ye8TteiY9tzcWpilnp3hMMC4cgZtblM=; b=eWiBPKGw7xFOiYVwr+Rxxj93SToxFXXl81EgFxZ7fwQzcxTgYBrGIgl3HmRkuh/DYvKCPC uVTqZngN1PcN7trqT5LhoPJ7TcJk9gh53roYam/0A4EYm1s8/w+Qy1+XYdtt+Q3c65XBPr IgROZtc/LcRdLwLLWEn9cgbilPDHukA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf27.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=1687663037; a=rsa-sha256; cv=none; b=6/GQpeAnQ/SfM+1UNNR9mipdRbrWfzB7EBhuku1645/F3kDbI2gnmimNrbN8q1yWvvNgst HunynmZmXExDQ0nHV/diMwhZHB7j/HHi3tvKEdzr0yzUolHt03uoy14iFSa5hE+heP7igw PPvWjcf4XFx/JV6wdAi4L8kmQFoRkgU= HMM_SOURCE_IP: 172.18.0.188:58134.1536611199 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-36.111.64.85 (unknown [172.18.0.188]) by chinatelecom.cn (HERMES) with SMTP id B9DB32800C3; Sun, 25 Jun 2023 11:17:05 +0800 (CST) X-189-SAVE-TO-SEND: +liuq131@chinatelecom.cn Received: from ([36.111.64.85]) by app0023 with ESMTP id 5532cf49ba864d7eb912378703cac591 for ying.huang@intel.com; Sun, 25 Jun 2023 11:17:09 CST X-Transaction-ID: 5532cf49ba864d7eb912378703cac591 X-Real-From: liuq131@chinatelecom.cn X-Receive-IP: 36.111.64.85 X-MEDUSA-Status: 0 From: liuq To: ying.huang@intel.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, liuq Subject: [PATCH v5] mm/page_alloc: fix min_free_kbytes calculation regarding ZONE_MOVABLE Date: Sun, 25 Jun 2023 11:16:56 +0800 Message-Id: <20230625031656.23941-1-liuq131@chinatelecom.cn> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D3D1440009 X-Stat-Signature: 5w48fhnxhb3nd6mhe53f97ozy4twuq3d X-HE-Tag: 1687663035-570135 X-HE-Meta: U2FsdGVkX1+ASqhyFVuTt7BcxZCV75fC7lB5KJuixOwl9O6HVYVterRqMq6eLB+j/1lUjgE0CHA35rt9okAKMDqD/ZnrDWyFPeWVLkuVMkgAXjV4eyEBZ3Um/TT1Hoh6QuwE+DObOcj0DCwO2kzyjimvz/J3zSLqaAcJcAaNqSODPipNwAjPv+/vHp88Y5B30hU0JtIvh4yxXOGbGn4L7Su7Y7xhJoHFFRMEj0+hiGo0IoUGpzfKzqEiWwpFiqnJxQEzHXzFQ0ufcpn3mR+we3rwALC8nVMtABUkrTBB4qJAr+lAMqP669RKw0lJl1sMaSNss4foB1BAiRFbovoCqLF1+BSSGydtZQrFS5SzGo8T7mIQEjO9+8CJTowDjCECrenQmMCxfQIdR7D8bpFZHYvwb5cXSPhhzT61H0p8muxnh5U89YXlJWoSFHDLFsxhFaXiM5qDoxZWeSGCkowqclo+sMckbliFg0Ve4IS67K+Uzh969LFYCx0iHQTHZa+HkfK1xWDJ8ahGo8gDM2xDL9FZx2aTiP08WMYK9cn7feifjpBjE3dCVgskAtMckurN16PffPQihEpwNuqPsBBceVB2A6ANyx1ZFCCdtvNwF11lsLijL9GMgV9wsGn1s6ZNkw8W9XSBEBnngAnwl3+rJpC85Pn6CAmPzMrIrCkzXLay2fz1Grvv9Kxcof3e4ozEIOAIUrvhkSAFQ2lb8v+sdp4VbylsJjTnve7wAet8rkFf1unbWtrpwfMjHrxm+s85l1/zVHxpqKWfHs4ZGNL1c19q2/xEEMOJBC9LwqoGUozZUKpyLKb/DYarXZ43pBBZfbTdHCG7FURTmGCbfCoHXTIt/a5zZrrSaJygiRhiesuqcFOQSMMngPWokcMp2J4mFYzmWHiMTO830ElsBjYirr33TiQh6uweob0ByJJngPVUGWxVVelMbPOWnzFqjXm3/xqA0Xif8c1DOmBdqpC CUxb220i WHW/E3hm7VXjRs0gjJNEqyr3tmHZERxuUTGS9/pWjUNiVZVGx5h3MLvcfqmPl0aDVbqDAb3utaHF8CdDa+x79+XlWnjdP3LGJPrHU3GjdAm+gW/Wshf71cVgAqLg2phXS95QCsHH2R8JW/hqiWngmknVemA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.023653, 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 movable zone pages, so just like ZONE_HIGHMEM, cap pages_min to a small value in __setup_per_zone_wmarks(). On my testing machine with 16GB of memory (transparent hugepage is turned off by default, and movablecore=12G is configured) The following is a comparative test data of watermark_min no patch add patch ZONE_DMA 1 8 ZONE_DMA32 151 709 ZONE_NORMAL 233 1113 ZONE_MOVABLE 1434 128 min_free_kbytes 7288 7326 Signed-off-by: liuq Reviewed-by: "Huang, Ying" --- 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 47421bedc12b..590ed8725e09 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6362,9 +6362,9 @@ static void __setup_per_zone_wmarks(void) struct zone *zone; unsigned long flags; - /* Calculate total number of !ZONE_HIGHMEM pages */ + /* Calculate total number of !ZONE_HIGHMEM and !ZONE_MOVABLE 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,15 +6374,15 @@ 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 - * value here. + * need highmem and movable zones pages, so cap pages_min + * to a small value here. * * The WMARK_HIGH-WMARK_LOW and (WMARK_LOW-WMARK_MIN) * deltas control async page reclaim, and so should - * not be capped for highmem. + * not be capped for highmem and movable zones. */ unsigned long min_pages;