From patchwork Fri Dec 13 08:16:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhouzihan30 <15645113830zzh@gmail.com> X-Patchwork-Id: 13906647 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 7B272E7717D for ; Fri, 13 Dec 2024 08:17:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEA4C6B007B; Fri, 13 Dec 2024 03:17:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9A076B0082; Fri, 13 Dec 2024 03:17:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C61546B0083; Fri, 13 Dec 2024 03:17:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A4A856B007B for ; Fri, 13 Dec 2024 03:17:22 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 58C371A04E7 for ; Fri, 13 Dec 2024 08:17:22 +0000 (UTC) X-FDA: 82889230872.29.83FF5DE Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by imf15.hostedemail.com (Postfix) with ESMTP id A653BA0004 for ; Fri, 13 Dec 2024 08:16:49 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=QrcgBpMm; spf=pass (imf15.hostedemail.com: domain of 15645113830zzh@gmail.com designates 209.85.210.194 as permitted sender) smtp.mailfrom=15645113830zzh@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734077816; a=rsa-sha256; cv=none; b=4vgjsJ3DkZHQWjgtt8L/gM55S1BgkteGLJ4gIVxcgqkCBPyvXzzCmaBkTl77ZBB2Qkqdnj hxCnjHIy485sIprlQKQobB0ar8TOS2drzChZGb7u0aZ3Mong/Jj8tWayHcKJ1KjObCAO89 fUxcEt6jIQM6ZxjSl3+iNjJBrtXXkkw= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=QrcgBpMm; spf=pass (imf15.hostedemail.com: domain of 15645113830zzh@gmail.com designates 209.85.210.194 as permitted sender) smtp.mailfrom=15645113830zzh@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734077816; h=from:from: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:dkim-signature; bh=+aW5Mr9qE0qfjhgTO9mJhgzzfKvLM/ZWs/peRYXQh9c=; b=ITAfSq6zymSMIoMY7rvhxYjqryqqY7uWXoQQdPgcaa3MfeHcToLQnSkdI83x1Kk0ph/x/r Lsgqv74blDypZT297cbHEmJ1yey3BR2CG9gg77RV1lgRNfsRWYHOadKFp38WZSl1hE/Uxp Iv0vmdsTmMgujP2HNR7zjsNzfXb346g= Received: by mail-pf1-f194.google.com with SMTP id d2e1a72fcca58-7265c18d79bso1697496b3a.3 for ; Fri, 13 Dec 2024 00:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734077839; x=1734682639; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+aW5Mr9qE0qfjhgTO9mJhgzzfKvLM/ZWs/peRYXQh9c=; b=QrcgBpMmZDqimPw5f82yt1+OAXEvDv5tcp4WDjkWZfs/ZZ5pGib+U8kmPAx9rs3SgP 7HtFWE0DnAPVuVEiTzitj8dh8UzIB8nLkrlWBTBabFiCckAH/OgLWtjSHI55ilN1BVKZ RReWUXF9sklW2h/pWFowKg0tQy5Mim3hJGuNFjTpvZAzq1QhoF5XVIFZGUrN3kUSmhPI O7vxkyvBZ5M6fbQbURrUdaAtqM6RvsiBCD1ebQZmq7bkQI9ck2Syi4NerniFh+sJssEK sl3Zucp7slKd+DE1SnraPFa8HetyhKm4BxkQ+vaMNdvwllvcpQgiVUnFqrWfkD2uXnTT JYeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734077839; x=1734682639; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+aW5Mr9qE0qfjhgTO9mJhgzzfKvLM/ZWs/peRYXQh9c=; b=BWt6PBEQWFs+iHB7IQKSUvZ+9kT/I1PX/6dJ28n6jORNAit735lwCXswNmbn4cj9Ic X0UIPHgTUMPIoR5SYyh+s1s6iSIkBiP8+1/LZvA/gubiRw6CSR8mHtiivOM/oDFnlWIW pRc8yyarO5ZzhC52QC91fBFZeq16wMKSw8g6Z2WSvlJgO2Pd7t0dwGVQwL9b1c6dWMe0 xvExac6QOShowxg4lexnm+S0kipOqiDn8+CRFsUs34tg+AV0EAf5Lspr4T7vx0x0vwF6 Xwq9AutN09sBgKKtzcQVsTWJkyPtKpm+UxtmNqHdrSRgjOQr5NbrS2XQH86XU7eEB8XH pOyw== X-Forwarded-Encrypted: i=1; AJvYcCXWOk+4YBcwm1nLJgcwkSaTyx2yTUOBH7Sm9cVPeUypdOwwsgQFHfRt6NXrvgpKZyPzDq0IvhuP/A==@kvack.org X-Gm-Message-State: AOJu0Yy+nFTy/2HV9+OTTpBS3sj/RQv8AG7tnuxh09m926Bumxl9jZlO mqCwFO6DzQ8YrprIsFSAVB01ss+dfSF+Y73KBLvGiJXgdeXkPn35 X-Gm-Gg: ASbGncsvdea4UiY8sGH+QnxhBlxU62YDEn1GwIZulmevJj/cd4vhHTtDPAUY2eYPSuy Zzd2r0ux5ZqsYuedurbTp9Ixlf27bJVgGsZHsypfu76xDhR2HBiKQFxgJDTnYmSCoiX2jaWpUNU f540g8O0/6lDtYHi96rJDCfbiHfDh+vgqthbvCtjSsnY3LJGuUpqCpW/nz9xUmvHoc5loteLLYd ebN1x4oJYn31PC0wf1CX5+5z8uJN5ThNNKcUO7iMie84JOqWjaHwsNG X-Google-Smtp-Source: AGHT+IH8cuOL6gMPiRHYoBhv4wc/6qGhYbStcloPbWzZYYMeqZLoWaVKg5i2liQS8cUlDs9g0QtsQg== X-Received: by 2002:a05:6a00:2341:b0:728:e1e3:3d88 with SMTP id d2e1a72fcca58-7290c15d7bfmr2514688b3a.7.1734077838960; Fri, 13 Dec 2024 00:17:18 -0800 (PST) Received: from localhost.localdomain ([192.169.96.197]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd4ec342b2sm7860660a12.70.2024.12.13.00.17.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 13 Dec 2024 00:17:18 -0800 (PST) From: zhouzihan30 <15645113830zzh@gmail.com> X-Google-Original-From: zhouzihan30 To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, zhouzihan30 , yaowenchao1 Subject: [PATCH V1] mm: fix bug in some memory information update Date: Fri, 13 Dec 2024 16:16:19 +0800 Message-Id: <20241213081618.53458-1-zhouzihan30@jd.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Rspamd-Queue-Id: A653BA0004 X-Stat-Signature: mfkujcsmdkn1h4pmqkuyejbh73cuoi6u X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1734077809-960346 X-HE-Meta: U2FsdGVkX1/msT2r3aBGcYrPJ8krlzKGAgnlnzWqAuXiSbzkqfpHIdmjs9b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u1lRvHfcdrPILghYQ9b2LxB6YtJxCpfP6lkwv4vf7AgznSd96FzahXvei9D0HPjPZWYnMHVB3sDTVc/1Jy0HpgmLtxGFwumuz+U4wze34Ydm9rqA1/wo5tdD5lpLDsoJMuN8cd/8ZPVl9GAOwa8i5GBim8BZDFm8dSo88IyYgK8bi5bAEQZq8h7wSe0e23YbycoSP0= X-Bogosity: Unsure, tests=bogofilter, spamicity=0.494645, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In the kernel, the zone's lowmem_reserve and _watermark, and the global variable 'totalreserve_pages' depend on the value of managed_pages, but after running adjust_managed_page_count, these values didn't updated, which caused some problems. For example, in a system with six 1GB large pages, we found that the value of protection in zoneinfo (zone->lowmem_reserve), is not right. Its value seems calculated from the initial managed_pages, but after the managed_pages changed, was not updated. Only after reading the file /proc/sys/vm/lowmem_reserve_ratio, updates happen. read file /proc/sys/vm/lowmem_reserve_ratio: lowmem_reserve_ratio_sysctl_handler ----setup_per_zone_lowmem_reserve --------calculate_totalreserve_pages protection changed after reading file: [root@test ~]# cat /proc/zoneinfo | grep protection protection: (0, 2719, 57360, 0) protection: (0, 0, 54640, 0) protection: (0, 0, 0, 0) protection: (0, 0, 0, 0) [root@test ~]# cat /proc/sys/vm/lowmem_reserve_ratio 256 256 32 0 [root@test ~]# cat /proc/zoneinfo | grep protection protection: (0, 2735, 63524, 0) protection: (0, 0, 60788, 0) protection: (0, 0, 0, 0) protection: (0, 0, 0, 0) lowmem_reserve increased also makes the totalreserve_pages increased, which causes a decrease in available memory. The one above is just a test machine, and the increase is not significant. On our online machine, the reserved memory will increase by several GB due to reading this file. It is clearly unreasonable to cause a sharp drop in available memory just by reading a file. In this patch, we update reserve memory when update managed_pages, The size of reserved memory becomes stable. But it seems that the _watermark should also be updated along with the managed_pages. We have not done it because we are unsure if it is reasonable to set the watermark through the initial managed_pages. If it is not reasonable, we will propose new patch. Signed-off-by: zhouzihan30 Signed-off-by: yaowenchao1 --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b6958333054d..b23e128afbcd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5826,10 +5826,13 @@ __meminit void zone_pcp_init(struct zone *zone) zone->present_pages, zone_batchsize(zone)); } +static void setup_per_zone_lowmem_reserve(void); + void adjust_managed_page_count(struct page *page, long count) { atomic_long_add(count, &page_zone(page)->managed_pages); totalram_pages_add(count); + setup_per_zone_lowmem_reserve(); } EXPORT_SYMBOL(adjust_managed_page_count);