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: 161643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2105841vqu; Sun, 5 Nov 2023 04:52:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkDihPuqw3TLhGh6JVYeyu/arzRliCgQ1/z1NsUT0fXW2Z2xcCdeN9rKkYSIDc09scDU6S X-Received: by 2002:a05:6808:d49:b0:3b2:e0f0:e53d with SMTP id w9-20020a0568080d4900b003b2e0f0e53dmr31880112oik.37.1699188732731; Sun, 05 Nov 2023 04:52:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699188732; cv=none; d=google.com; s=arc-20160816; b=LugWJjhxSzlxFXD/goVL814HRHjWPcZ+jG0SyU4jGa0b5gYLQkV0cwz+DxjeEq5xVt G57KpllYTi8+YBglcWlxCBSdnaZWPVBLHnN4k/9qkRTOcFxBZJiVKP+Sni/Y3oPHCIge u8EDWogWX97njXKrFtsPqca5/Qma+r9wcrhSi6cOtkf7+3cokHENmu2Y0F+6L6XcZCvO vcIjH5hzrXqkfRAC4+jI/y9jI9I8Er7kF9xQY85Edg3noDZZdo47AtqYuQCJdN/3wB0S y7tpmTWIbkYiyjIaguCcMW6DZFD7pEj802oPSbRuC7/BJWTG3w0fdLrYtIWs7iJ9aJt4 w0bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=L7T8n6YctyotXTtcQwgsAPEnOMWU1sAeWRbOtIyFLJc=; fh=OEZ1X2ugt64Sg3RaiLhA7IjZ0579kVxN/CI/M7AE/gY=; b=j0eU7d46JOfYIw+utZzi6zplkwacyCmYchT7NXaydbJg6Q+kBZzuuw/S23uvyV5oyg DDKKRAeWoa41nlMprcPmZqWDFEhop1zGdR0r1LibARqtnS7PuAmLxzrSPTsDb3zdhZoL PE+PrSbDc0TTyZFhb1ZH5ZYorDunFxZ+5jRS01PqjDgRtTZvMBvVAG/bnHnq80hODMaJ 6WDTcRMfXkWgqXGVPP+uLY2RlN0d+B2RxDx9FfOfQMcVzM5Oiu3nuPa6KpXURZO2gLXy zwkqSXmHJ8e2lWox94QDpZVNDfvCxpFVbkqTcmMywlshfTkZWT6WpjMd6lNAI7u6uv/I hWGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kYZutI9d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id fa30-20020a056a002d1e00b006be30cdc3d8si5819748pfb.163.2023.11.05.04.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 04:52:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=kYZutI9d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A531D804ACF0; Sun, 5 Nov 2023 04:52:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbjKEMwF (ORCPT + 34 others); Sun, 5 Nov 2023 07:52:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbjKEMwC (ORCPT ); Sun, 5 Nov 2023 07:52:02 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E11DD45 for ; Sun, 5 Nov 2023 04:51:54 -0800 (PST) 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 05 Nov 2023 04:52:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781728524306825323 X-GMAIL-MSGID: 1781728524306825323 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;