From patchwork Sun Nov 5 12:50:50 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: 13445718 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 CD9E3C4332F for ; Sun, 5 Nov 2023 12:51:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 463106B0172; Sun, 5 Nov 2023 07:51:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 414016B0174; Sun, 5 Nov 2023 07:51:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F0FA8D0002; Sun, 5 Nov 2023 07:51:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 08DAC6B0170 for ; Sun, 5 Nov 2023 07:51:43 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BDA5F160417 for ; Sun, 5 Nov 2023 12:51:42 +0000 (UTC) X-FDA: 81423887244.09.B34AFD1 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf08.hostedemail.com (Postfix) with ESMTP id 93CDB160002 for ; Sun, 5 Nov 2023 12:51:40 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=NorFpvXY; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf08.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699188700; 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=alGu7DSQCg8vRy4ahagVkIN6teU4ANxGr1I6alpYOtM=; b=fm3idJqt2si7Jobmj+xEeZFGjD4fgbj7c7AbEeTfiohnc2DdsXdmrkfkuGMi8lZ9Uhkpsf xllC8A60edVPIdnG8xN8kedl262KKEcfhog2/KFhB2G2+56G6lKxvGUwiWpCEeeXWzEW8Q zMmqgjTqxa9oS16aoggq8fT3w544M/g= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=NorFpvXY; dmarc=pass (policy=none) header.from=quicinc.com; spf=pass (imf08.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699188700; a=rsa-sha256; cv=none; b=HvvdxDkQT9cVBx9mWXdgaoCBjPUkJlX4IXkvaCdzXDi2JNd3ZWBeeCi0jEJtMHI7sw0gc2 CaD/rceWSQWiSTgXATDlwyRddUIgyrTj6e9JVD85NEdoXq2dXtThfNm1Ft/IVpw3Pv9jkp KajTefdmPmnC03DcGeqk9pvTh0sRoWk= Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A5CpdQj008163; Sun, 5 Nov 2023 12:51:39 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=alGu7DSQCg8vRy4ahagVkIN6teU4ANxGr1I6alpYOtM=; b=NorFpvXY9dJEINV4nDW+arIx2FvGaQ0ea+EEAsFvd1nWcHxgAeC50zlXKugod0ACOJrG KYrcGYZ8lTov3U74LwpkCciOalMukfFL85nMmWTijoL+Bu0kVrXYyICFTLaH8odZsSaq SyC5vkwYgiivFqaDV/JQwb8BJuo1Cr9463PWOjnr67/RWheQnakY1XWVkMTwNOSLtpaA Evq9t5f/2wryeHPvDSwx5BCG08GdUlKO82ktTGu8pVvhyuU047ydGDexwz3TidITMNz7 c2RWPwrrcHhxvke3mSf35op21s2JqBhWAOLYtHUjtAATrNUjlNFcLT7iqa7qUXO46eWs IQ== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3u5ek4hyjp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 05 Nov 2023 12:51:39 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3A5CpcAl021658 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 5 Nov 2023 12:51:38 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:34 -0800 From: Charan Teja Kalla To: , , , , , , CC: , , Charan Teja Kalla Subject: [PATCH V3 3/3] mm: page_alloc: drain pcp lists before oom kill Date: Sun, 5 Nov 2023 18:20:50 +0530 Message-ID: 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: ihGUMcrRY_x_DBJoNrNbYLsj8TJYXiz1 X-Proofpoint-ORIG-GUID: ihGUMcrRY_x_DBJoNrNbYLsj8TJYXiz1 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 phishscore=0 impostorscore=0 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 clxscore=1015 spamscore=0 mlxlogscore=549 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311050112 X-Rspamd-Queue-Id: 93CDB160002 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 3jmx8n4t76aaogrecsxpucufbf3e8j33 X-HE-Tag: 1699188700-491172 X-HE-Meta: U2FsdGVkX1+FccEhI2G+JyjAwt+Aq5KoTATkGUOEXnOTZikFovsA82pCiHb+yUcMcrzUEeboMZfmIpZJGiJpMcjYrXae5BrLEkoxygm1v4h0CygAKHbqHX90gpHayNCZkfqQcr9EIZ6XDm+L1KIgcVzdVSF5FdYUFa2IB3kESg2xwSWmEI4XJUoEPCkifbdUhf9/VvFf2B48hVqg+6VCYnfSQk8C20+dliCQ8zLzPAK0MEXfVMyZ3CDIa03yLU9LoeJftcF2EtyQCifTXdnpOIoFRlQttn8tvWY7wBp9GJC9FsrAiuEOQHVWFT91X+Ybnkcm/TvXiedM+VpBfnFrraUDvUTswADfhs0+0gzDaqPsjKTNEFQDLOsQZ/uaE2soh3ws9nzMYcEC1F8Bimy2BaomKYEE2csnOPT573yWZTUYa/7ZqXBV9eNjUFwbF3Vcpi2r8mF+tA7eLx0b8/zfyrMMzApVlyh2vGV72JQnv4ravKgCNwJuOCJbTzDlUBXDsrKv8wFoN/Anvm7Pw3YssQsm5vMSrR53LpSNJLDluP3UGbyH9XaCuJwsurQrRwKJHh8IltB5B9eKQNOUFiRgOe937w5H1Qy04GzLq2lHaHRNMdFa89sFy+A5dPedR80Vy3P8uUAu3G+noUAOBubEINqGHGGmcXIUJbwM62qDZ6C/Lk9eYpToUUFYgRQlwsS2J4eRXSXKmMmZHBlK2bO+QGPiOebYFE+UDF8Yv2rkLPk3d6swimhCcJnJN6eY39rqMqPksoYOaSbMiHNHNjk85tIjPV0c8thFabpxthNBQ+oVSBZLRSoyw3//WcIEYJi0Fd6A3Sig9AYZmDXN1x9IBq43SgjUgsb3ndkLquGMsTQLTkm2T9XA4aPxcI2HMXaeNhfKi7bMRq7Q4tHPnWSYjwV/NuSr2RKhPMCWI3KPzDP3TO6rV2ldnNGRUHnh3BVe5Bn+HQB4LbI5zALuLrT dyMsBf0a 51DcgnsJ5q6D3NB4CUSanZP78ojlGdFciIGDctVv+MfrGcRJ042XJW2y+gi2TRU27lMHaEf3qHDGn6yY3nf7ZMDFGEnz5tIWqb0Es/RMAs9Y77N9fpnu7OnwB6PDc6cxwuOblzlT+C43emg7TwlbVVgL8W/JKL7yJXdLiDi1LE+uYe09IsJUG9Rgs68zcOGGr/VHs1KZIlIZhY4Ln7WEl2e9wDw1qgkKtdoUBOXl7o/4nIaLV6yzKvTp2Aqbm5jqjUhAuSCiEPM5Qy40qFX0854O49Kq6lCHQltPu+cMs3uL3J6M= 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: pcp lists are drained from __alloc_pages_direct_reclaim(), only if some progress is made in the attempt. struct page *__alloc_pages_direct_reclaim() { ..... *did_some_progress = __perform_reclaim(gfp_mask, order, ac); if (unlikely(!(*did_some_progress))) goto out; retry: page = get_page_from_freelist(); if (!page && !drained) { drain_all_pages(NULL); drained = true; goto retry; } out: } After the above, allocation attempt can fallback to should_reclaim_retry() to decide reclaim retries. If it too return false, allocation request will simply fallback to oom kill path without even attempting the draining of the pcp pages that might help the allocation attempt to succeed. VM system running with ~50MB of memory shown the below stats during OOM kill: Normal free:760kB boost:0kB min:768kB low:960kB high:1152kB reserved_highatomic:0KB managed:49152kB free_pcp:460kB Though in such system state OOM kill is imminent, but the current kill could have been delayed if the pcp is drained as pcp + free is even above the high watermark. Fix this missing drain of pcp list in should_reclaim_retry() along with unreserving the high atomic page blocks, like it is done in __alloc_pages_direct_reclaim(). Signed-off-by: Charan Teja Kalla --- mm/page_alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b91c99e..8eee292 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3857,8 +3857,10 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, cond_resched(); out: /* Before OOM, exhaust highatomic_reserve */ - if (!ret) - return unreserve_highatomic_pageblock(ac, true); + if (!ret) { + ret = unreserve_highatomic_pageblock(ac, true); + drain_all_pages(NULL); + } return ret; }