From patchwork Fri Nov 24 11:05:52 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: 13467535 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 76F03C61D97 for ; Fri, 24 Nov 2023 11:06:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12FDE6B06AC; Fri, 24 Nov 2023 06:06:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DE6B6B06AE; Fri, 24 Nov 2023 06:06:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE9EC6B06B2; Fri, 24 Nov 2023 06:06:29 -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 DB2AD6B06AC for ; Fri, 24 Nov 2023 06:06:29 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A7D2AC18B6 for ; Fri, 24 Nov 2023 11:06:29 +0000 (UTC) X-FDA: 81492569298.24.269F72A Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by imf09.hostedemail.com (Postfix) with ESMTP id 1896E140018 for ; Fri, 24 Nov 2023 11:06:25 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=Ox4aOybw; spf=pass (imf09.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=1700823986; 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=XevrrF9/BcNyXtfgPOZjSxlAUBouemoME5zNztn1Vg8=; b=4iKQIdUrOISNigEyBurnQXCk8I6s+akUUCY5d4ekpcwwtL5umDOQFJnD9ndYedtiUl9rmx U+H9GbYfO/T+LbEZCSzpZg3aeIvvuR7yz/sVr5LGJnj81IpeALtJIvEK20bZfZWd8De5jI 4KBT+Ys6jYos5k/6lXvFJtf792fVqYE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700823986; a=rsa-sha256; cv=none; b=bfDXsZaVxDQhSlwDn1MawQ16ul/OHGuB8QAnleTZ+vTIZFDnMeNwdY/PxyQeNuZBMBvZkE 63oaFL5REEFYrbxNjhpOaiI3cXkv0RVbaieqIwLROyyp937TRqhASMss0PZA0y99h3qxbL jVpZg59KKqNIc0PKLKp9S3H9F9a22A8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=Ox4aOybw; spf=pass (imf09.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 (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3AO66F0G031216; Fri, 24 Nov 2023 11:06:23 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=XevrrF9/BcNyXtfgPOZjSxlAUBouemoME5zNztn1Vg8=; b=Ox4aOybwvkKC9GaMCV5HxQUruXA0yH6ef3yTi+Aul6L6RXTbWCdwnkRypAI8345YZycw yJvH3cLs/qnracKLrtjT/T/D4InOgWFrJMWYVgvlKNuOfBteTP97NMiJ7Kral8hU1LP1 GL1CckUcqJqRxW2uVg370rQxlbSy5U9JdiIJjE9TJGVP7gfm44AzAyTrUNLvLB42Oex/ x2i1D1ZfVRQ6qXci0dPDdio2iIGn6t4qCBJ1ov2e8+rSjvqPtzemEELdqOQKt+27ZfEe 28m12XHFxGouOry5v9vkWt6yW2/Li7IyV3qKBXkQ4zBCz2/jYxMGibTvNZ+eCobSYFbw tQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3ujp8x0ub6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 11:06:23 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3AOB6NYA001785 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Nov 2023 11:06:23 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.40; Fri, 24 Nov 2023 03:06:19 -0800 From: Charan Teja Kalla To: , , , , , , CC: , , Charan Teja Kalla Subject: [PATCH V3 1/2] mm: page_alloc: correct high atomic reserve calculations Date: Fri, 24 Nov 2023 16:35:52 +0530 Message-ID: <1660034138397b82a0a8b6ae51cbe96bd583d89e.1700821416.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: vvC70aAGvT9o9sBR5JZxO4PBCB_o6bew X-Proofpoint-ORIG-GUID: vvC70aAGvT9o9sBR5JZxO4PBCB_o6bew 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-23_15,2023-11-22_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 mlxlogscore=638 clxscore=1015 spamscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 bulkscore=0 mlxscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311060000 definitions=main-2311240086 X-Rspamd-Queue-Id: 1896E140018 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: gy8wcbr1atm7d6wzts4bhhdzn815yezo X-HE-Tag: 1700823985-565816 X-HE-Meta: U2FsdGVkX19W5lx7gzgKXG/NKLMj2jX/aI2rlr1fTBYcZPVSns1qyS9xL8F+2CASsPYDR4kish4MMD/YJAsegfHUMJw5OEoxr0bun6uqDO2mlu9xy4BVsCcVxzcdHj93OJeFC4bzvDeVMBPEhXq6KKuBbs7PJeiOWDH7Xrpap9WwXqcVceY9D81FDuL6r9QoBeKpoiDgd2LRgV0OiXsTBaYHLigOz1Q8ue0whkj92Lp1lwkU3lw8H+PhQlxwF83+nEL+SjeKy0b+oW/77BzotbVrOP2f5P4FftqhKS9JUStdeXv3rPznAroRbk5MWMhJ9uneuJFLtA4P/zrGSHigJnuorCyCIVSrM9woDsJanLDTbdTP9SZFvEFLxTZ5UxLcNJ7oTMv14T1TC+3Tj+qtU3Zwo3DVsQBwrTNHLoGiRqU1rc679GvSZjbamDLyeAodFuWu+AK+BU7W/s656oRYH/TNjASsFIVpnHbp9w+FS+BFADzcJAWEb5tCZ/kYt/PN77+Ia9y+8Jf5LdL+HMTgWJ/HS6H6SEFjtKtzpGFRSNFEh75ZNGnDQKV+5NOxe9YgbmiiES7CWIAsq82/Mg0bjIQvoDSF+4Nm6yovV4ZEcoonwEF3QJvHUn695pHy7WKW/mA3oGaOUmiCKknAoaZyfCOcTrmfRMAoend6FazO8N/n46MODdAhMjROMFQnwhxMOvZQXFz7XXXTlt7Xh3F/07yofoMe7jIfH6iz7noe/0OQJdxmXfBSJrKgKZ33bJgGAtstr0QAmp3aB/ZjLfrjB0KUXo9AUggSvI3KWkkLDEZPSe8aAd9Q/386DHhpZpdGADQRo0Xv4bBVSXBoZ8h3fe3sHHHmDHKeKxZhiR4gk4RMTojyKeGG0PbfDGXgP2ibbtVGRG4ox07Q4Ya1g9r28JRAp85vn8pgQw0FkJftfu3lgDKv83tfwALtyHFwfPoBcQML6G3zIw3Re6rFM8/ 3F9mQnXo kDsYy5oyjEJ0nizo0z5kgsF81trvkU/T0Exc+HeuOrcHKqflRVPE+wngVHr5zLgS5LIRoVsmvMnSyMJB2Ey55RICGLQphU8OcZXgkuZVlLvXQD9EtJURqK7wR2y6eGmkEB39pLV5n8M+6r0YxHlElsfIsm5OFylmhCZE8iK7J9skupYV5HC98Zuczcvt62whEKgK8b4P+j/2zNkrVYRTdeuuYvm1g2LSx6gU14ZTk//1ADrSghodaEMO8AYaBEDZVqUm8EyZjIS+vEU2QWcqJT9IdC9YEnXt9GQvgxgr7pAgCWvRlZf6zWRZJUjOe83LH2+uDVD3jgTp7yUK+cBaNeRFi9ZN2yz9v2UsG5UG9OKb7+ak= 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. Acked-by: Mel Gorman Signed-off-by: Charan Teja Kalla Acked-by: David Rientjes --- 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 733732e..a789dfd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1884,10 +1884,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;