From patchwork Sun Nov 5 12:50:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charan Teja Kalla X-Patchwork-Id: 13445717 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 A8D35C4332F for ; Sun, 5 Nov 2023 12:51:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A03D6B0101; Sun, 5 Nov 2023 07:51:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 32E776B011E; Sun, 5 Nov 2023 07:51:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17B446B011F; Sun, 5 Nov 2023 07:51:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0318C6B0101 for ; Sun, 5 Nov 2023 07:51:40 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D952E1A0203 for ; Sun, 5 Nov 2023 12:51:39 +0000 (UTC) X-FDA: 81423887118.04.06F0A3D Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf10.hostedemail.com (Postfix) with ESMTP id A5F7DC0009 for ; Sun, 5 Nov 2023 12:51:37 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=kYZutI9d; spf=pass (imf10.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699188697; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=L7T8n6YctyotXTtcQwgsAPEnOMWU1sAeWRbOtIyFLJc=; b=ifGpmnFCK280GkrhhLYn/ORtokV9Tzdq1DS7IZfUVFUupvWmENlPWRNl3Cfh3z5xUWWJpj LcSpgv1AxoIdrqukZSfcnpfiV+fLHmS951HddAx/gI/EGzCJA5l6zlvuKV+vBBe8xMmQ0V YJ8rqdfGy7isME3jUWaz36eaPmG1YIw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699188697; a=rsa-sha256; cv=none; b=Dd4l5lId8wSv8/r7Ay+2lfypaOumEWBA4rDhIj/5aItsFjB7kqeK852hHbWpuHKewkZhDO aYdEq6+1LmvbVfeEc9LWQjQKFSakxmq1nUARmV2cvsv0IoEQySQjaXo29oBnD40PeNscZC WM2l8zMqFvlo9ZAfk1ZYpQ4laPzuzsY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=kYZutI9d; spf=pass (imf10.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.168.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A5CoBU8015431; Sun, 5 Nov 2023 12:51:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=qcppdkim1; bh=L7T8n6YctyotXTtcQwgsAPEnOMWU1sAeWRbOtIyFLJc=; b=kYZutI9dgILFSgSbTs+KKpLizroDx766+HIgl9KQTLIyYh9Ej/kMvLdg0P0EehgyqicR wrJ6NbbIUo4MJ5h2f0Y3+eAFsHf8Ap/sAApc4tkX02yXKSw5Sl7FozftEqPtCFimOHcW fHlPe4xDeFPDverK0tTlWIQ9l7p4E8LAFbv2KPU/P9i+W4gT5PfKsHtH5W7hMRpkG57p jaAu71CdPf1C8tQe6qDQ72dY0o1oEu8OYL8N0QcFkYTVz1fuMJ3BsyECVciX+5Ps6OY3 DOLcgdaoJa+MmzSUZUC84s/DqHOz7sX4FNox0sBTJW4qEWWuewVIZh46CzpcYtxbieCu pQ== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3u5efyj0k2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 05 Nov 2023 12:51:35 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3A5CpYtL021095 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 5 Nov 2023 12:51:34 GMT Received: from hu-charante-hyd.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.39; Sun, 5 Nov 2023 04:51:30 -0800 From: Charan Teja Kalla To: , , , , , , CC: , , Charan Teja Kalla Subject: [PATCH V2 2/3] mm: page_alloc: correct high atomic reserve calculations Date: Sun, 5 Nov 2023 18:20:49 +0530 Message-ID: <905d99651423ee85aeb7a71982b95ee9bb05ee99.1699104759.git.quic_charante@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: DZYnG6HqyGY33Ef0z35NJ3u-Y8Sot20S X-Proofpoint-ORIG-GUID: DZYnG6HqyGY33Ef0z35NJ3u-Y8Sot20S X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-05_10,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=565 priorityscore=1501 malwarescore=0 mlxscore=0 clxscore=1015 phishscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311050112 X-Rspamd-Queue-Id: A5F7DC0009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5qca6bmkia3ejyysjoxbg453sztdiswi X-HE-Tag: 1699188697-295776 X-HE-Meta: U2FsdGVkX19PqeHlY3P203hAm2rg0zoZsYsfsaPIKnIWx9T5WBanYTR3X3Lmk6KJ8kdOfrVgWWv2ItytarNhArb+8gaKX0ChDU25EDlLOlqvJ54UkiVc3jxjCRz+zCcUQAmgknu8a7lZ8XnimlML1ODwzzkWVAit4VJkp634bkqVN5hzZtnFWekEX1y3Orh3sUpMksmGH/VM0SA7RkW6K4CVUpknXjQRft7B3/sAFF/M+p6RhSbaIZLEj+SMTCXS/2424OEn4OtwvIvxJaRoVnXrvv0rcxvJ964dNYYMjH75xnIcYd7lWDjwGKwNbAm05MaDeAblk4vPgT1+DpCElHrRFcpdvpxa1RKqCiQ/S16AvVJ6w6C15CoR4HJ0ug9DBNh+VHb64tfi6CxlOFoFtpP2j12DoSqSlJaA78kiLJLaEO4r7/+9qaZKyOQwGzbugo/jcWGm/RY03WVZD9sslGZfr+8Na2y60KknMTTCiYP8osqlckT7RmqH19g/oKVhUTFBAs7LWg31Zj/H8UW3gzH+LfUA1KcfSGAhMscTUFmU7siw4Q2xrCnsuxCW3UwLcZ8TcWjzMTOI0iEXLP45bqy4kQsFR0kGgHE8GMlKB1XkzTDnlh5aCt99a6mIceh8apwam3wHW+Gz4QU8iOfsST0jExHWnQYXR8mR7/eOTWUBYyP2DLguF4hq+XVeeRVxGnkLShv1iyu0X82OIzYFFTbIq21mIHGFyFLUICIFomWcoA6UONLSGJwMR9oPYD8/i8xh3CAL4vzRdrt/lGpTbjbq1k8nVvYFhdpxIPs7gyTxK8ciAxoqk1unQhTlwMiKck3zumsRgCO8nIkJUnRioy4Gk8ng/dXO5BSQyjo+FgA0yNXTdjviffyd3iP0vx7Qp1dyXXLK0LffGpC79Bal/nMk3ArKDD2nIIN6yJf789OUSrKYhr7HJtJjcgZDNDgvw2y23BmNDEivAR/h7Cz +Wys9L0C Y6xKiUSUtHT/S59zhhXMfe48/FSRhLUCYvasR+l95Y1weGEYD5FG5jY1hntFPn1HUv9McwXszK1CCQkS/KaJITALYK9EcXWfQ/Z9UF6O+fhWnJppH/SykkEnFnYGzLLhDC2Bm53tkhPDrsHb2ZaxRK3vUoKmNGelwmWJHjozNwgKT/NaaUdOk+V4YXHFD71mICzdKPVORxIRwZs2ByGHetaFG5pxrYwXY3oqVIjGeB/EvA7r3qzE7YsbiL8N4vwZazShZa6zKsFwqE50sLnToQENlmJMhLGmufLoAm7sGu1DGDMM= 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: List-Subscribe: List-Unsubscribe: reserve_highatomic_pageblock() aims to reserve the 1% of the managed pages of a zone, which is used for the high order atomic allocations. It uses the below calculation to reserve: static void reserve_highatomic_pageblock(struct page *page, ....) { ....... max_managed = (zone_managed_pages(zone) / 100) + pageblock_nr_pages; if (zone->nr_reserved_highatomic >= max_managed) goto out; zone->nr_reserved_highatomic += pageblock_nr_pages; set_pageblock_migratetype(page, MIGRATE_HIGHATOMIC); move_freepages_block(zone, page, MIGRATE_HIGHATOMIC, NULL); out: .... } Since we are always appending the 1% of zone managed pages count to pageblock_nr_pages, the minimum it is turning into 2 pageblocks as the nr_reserved_highatomic is incremented/decremented in pageblock sizes. Encountered a system(actually a VM running on the Linux kernel) with the below zone configuration: Normal free:7728kB boost:0kB min:804kB low:1004kB high:1204kB reserved_highatomic:8192KB managed:49224kB The existing calculations making it to reserve the 8MB(with pageblock size of 4MB) i.e. 16% of the zone managed memory. Reserving such high amount of memory can easily exert memory pressure in the system thus may lead into unnecessary reclaims till unreserving of high atomic reserves. Since high atomic reserves are managed in pageblock size granules, as MIGRATE_HIGHATOMIC is set for such pageblock, fix the calculations for high atomic reserves as, minimum is pageblock size , maximum is approximately 1% of the zone managed pages. Signed-off-by: Charan Teja Kalla Acked-by: Mel Gorman --- mm/page_alloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e07a38f..b91c99e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1883,10 +1883,11 @@ static void reserve_highatomic_pageblock(struct page *page, struct zone *zone) unsigned long max_managed, flags; /* - * Limit the number reserved to 1 pageblock or roughly 1% of a zone. + * The number reserved as: minimum is 1 pageblock, maximum is + * roughly 1% of a zone. * Check is race-prone but harmless. */ - max_managed = (zone_managed_pages(zone) / 100) + pageblock_nr_pages; + max_managed = ALIGN((zone_managed_pages(zone) / 100), pageblock_nr_pages); if (zone->nr_reserved_highatomic >= max_managed) return;