From patchwork Sun Nov 5 12:50:48 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: 13445716 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 96230C4332F for ; Sun, 5 Nov 2023 12:51:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 044766B00BA; Sun, 5 Nov 2023 07:51:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F0EA46B00BC; Sun, 5 Nov 2023 07:51:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D88BE6B00BE; Sun, 5 Nov 2023 07:51:35 -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 C468D6B00BA for ; Sun, 5 Nov 2023 07:51:35 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9C3251204C0 for ; Sun, 5 Nov 2023 12:51:35 +0000 (UTC) X-FDA: 81423886950.23.5387224 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by imf27.hostedemail.com (Postfix) with ESMTP id 7B4C84001F for ; Sun, 5 Nov 2023 12:51:33 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=lgOUV9fg; spf=pass (imf27.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.180.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=1699188693; 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=12MQflBjL4Gqb+axG0wpE/BY/zW7nOj/OH6uPabUueU=; b=E98iwpKXM+rsPhH0LQa/x2FQQ7d1NlPzz3zES4IOtCROKCTqKNzQPFu58QhNe3WGfONo/U s/C4L7BIawxk3GTURUhoqiH7bd7imZS4fhIvJsI4t+9Gdiq8Ie5nqmiF79C5ORltUxFtR9 9VCIADj9COPcnevgDromeHndHgbW1PY= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=quicinc.com header.s=qcppdkim1 header.b=lgOUV9fg; spf=pass (imf27.hostedemail.com: domain of quic_charante@quicinc.com designates 205.220.180.131 as permitted sender) smtp.mailfrom=quic_charante@quicinc.com; dmarc=pass (policy=none) header.from=quicinc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699188693; a=rsa-sha256; cv=none; b=IufilLraZkVcrKP748mdU6JgC1n84oTpNiJW0TMoFRMqzrziVHnTuJBr7QdWfd4vPsQeCY nHP4xAUW6XkdmyE0ljEYbdzl92nl8ddptuVEp/IyLen5SMVfaLzefB+Ap+1vFE2AKifr8m Uiz/OgmkgCZTdh4P6usrzA9/mbOJBzM= Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A5CZlcl017538; Sun, 5 Nov 2023 12:51:32 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=12MQflBjL4Gqb+axG0wpE/BY/zW7nOj/OH6uPabUueU=; b=lgOUV9fg8MXUnJKK390DF9w4DEC3UYUf3R8T/5B0Yku5IaEQML0p+XHMpsdnIX5ou7gt zyrgzHIelzSz2D/TpmXKCzHryPjAMJeVZWO5+vi659QGPuC9GizMBK/YJMTW3bR1u5I3 rqdMtL0s6eijef4oi0SMIisCkCsZThLTPEc4q4CNGHpE3cOAAnPdwLce7qqICnynGdZ6 JDN/jz82MWxuBDTFEXoXoNHuCHj+WEkoK0QQCe+j2YcAUr4sGog7WhZcI0UIBMFUPnnA +I3dnlH7sKU3O+9EMpp6vMipafKW2ee0kKe3XzwjC0Zd+ByE1UHDM6SjtrMvwUQKSTwE rA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3u5ernhya0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 05 Nov 2023 12:51:31 +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 3A5CpUxM030773 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 5 Nov 2023 12:51:30 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:27 -0800 From: Charan Teja Kalla To: , , , , , , CC: , , Charan Teja Kalla Subject: [PATCH V2 1/3] mm: page_alloc: unreserve highatomic page blocks before oom Date: Sun, 5 Nov 2023 18:20:48 +0530 Message-ID: <301b193fcc3e1f91ef30f19ceca06dd6e00b35e1.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-ORIG-GUID: W1coWO3tY08OTjTt_w7lR7qf7TvlIyC7 X-Proofpoint-GUID: W1coWO3tY08OTjTt_w7lR7qf7TvlIyC7 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 bulkscore=0 phishscore=0 priorityscore=1501 mlxlogscore=926 malwarescore=0 spamscore=0 mlxscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311050112 X-Rspamd-Queue-Id: 7B4C84001F X-Rspam-User: X-Stat-Signature: xftepawic4yjjke1t8xcpjaaqb3b7gh1 X-Rspamd-Server: rspam01 X-HE-Tag: 1699188693-938633 X-HE-Meta: U2FsdGVkX19q61fzpX5h1Ypk/GWQWKvqcXu8XVxwVgPnd5j0vsZl1QDTA943uyPWESWYzq8T2Znyf42O5OjSnUchLmXRMKigHpo+psYZr3CrKwTtHOvVv+Kf+gENKqParemmaGS6g6AtAhMZWdysqMWhF5Um5yp0ElRcNwB5wq2iwrB/6ZqJCOJAPSDgLBz2LDXFuR0S5177gW+edCPxqjHYZ5nijO9vpUFFCtAQVxX7JJRBpoC9DcRF7Bqg+WTv8XZP6l9507prXMct+kXgywDTHMUxew9EIZNxmYrqNNeFlnj9m5kcZ5hjFZNY1X05Jfk/N9JfNAaU/2CT9Yh0HU4U4vbrxd31rb6hyELnoMxDJAexJvwnCo26/NjCXFtHjIxcBTBx/xM7BGlsloyJOBPIfhn6pjM9N7Yo5Sj9TNkYa7S4LAwFxdj7ofSYJsB/HY7a3W5q1xwrtWHlfgA+k7jm4OmgJc+6kM2SHf2fNu6LxDJ+qUpepMG67H0DNMBO8sR3wT+fOH5+HFoBWSnpFu4X1t/XVFY2m3pd2nxJzx6H0M/xT1PhLhuyf+TbkCb7v58E38aB30RCO11pcWW7sxi4nyA1ZAZpwVJYhUwQzLvMO+hBeLgm3e4XjlZpZLQ13B6nJVAm/fujnr1Y1zKU9qZqkC5VDPuZKdBqULlNoE1bQ4Z4FopVC+BoUyNT7jhj/CojU/oFOJHMd33NXtlhf0LBfcnJk08Uz4ZftTa/x8lI6Gs2OKtBOGLlBuZ7fd8aPWQGzTdqJBoV/E/6YApF/6dYNHgn/F8uG5hPi7XGZLdHogvBKDhgL72D92ll9SNtpwTojQXQKWL2PuPmhoanFZjJ0mMq9nguSgGHskx9qDya45Hs9FBL9ajIGZWN02VnKdAKB6cZArSvBJOaKRMHeYaXa7VlDrknHA66FwQFcmB+tmEQnlH4kBln8y2koHT4KSsZflLjft+xoSYr8BI Nv84jHrj TAVjPLWJHc3h2ThUYpAjeso0MKQEqc5/2W6jZYtojpiQOUKNnDGgVVpJZ0fGCMXdfP/xV9FI9WxqQW2orBEBWqOl7ZtFMX5eSxIpdkRTzml/RwCoyct/JPk56MBXDM1UyhBp/8SjtERjmZxO5mDKU2F2ByZ5735Te4erSobcAT9KDuejsBYOvyzkjRV2krBWibmoJuoh33DXpKRg/VPdNOL/xu3c/ykJRRheWeB4+77xzISLGVvUQ7Jws1w5cQkSzxVUNK5KVI/1s5AVxAvLfaoSQfx1ybUhykJhvsWxIUyqUJeLxhs6FqRTlcXoDd5PTdicMfU90B2G9+bYH03wcOJBqwK1RYoz7I9Ly 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: __alloc_pages_direct_reclaim() is called from slowpath allocation where high atomic reserves can be unreserved after there is a progress in reclaim and yet no suitable page is found. Later should_reclaim_retry() gets called from slow path allocation to decide if the reclaim needs to be retried before OOM kill path is taken. should_reclaim_retry() checks the available(reclaimable + free pages) memory against the min wmark levels of a zone and returns: a) true, if it is above the min wmark so that slow path allocation will do the reclaim retries. b) false, thus slowpath allocation takes oom kill path. should_reclaim_retry() can also unreserves the high atomic reserves **but only after all the reclaim retries are exhausted.** In a case where there are almost none reclaimable memory and free pages contains mostly the high atomic reserves but allocation context can't use these high atomic reserves, makes the available memory below min wmark levels hence false is returned from should_reclaim_retry() leading the allocation request to take OOM kill path. This can turn into a early oom kill if high atomic reserves are holding lot of free memory and unreserving of them is not attempted. (early)OOM is encountered on a VM with the below state: [ 295.998653] Normal free:7728kB boost:0kB min:804kB low:1004kB high:1204kB reserved_highatomic:8192KB active_anon:4kB inactive_anon:0kB active_file:24kB inactive_file:24kB unevictable:1220kB writepending:0kB present:70732kB managed:49224kB mlocked:0kB bounce:0kB free_pcp:688kB local_pcp:492kB free_cma:0kB [ 295.998656] lowmem_reserve[]: 0 32 [ 295.998659] Normal: 508*4kB (UMEH) 241*8kB (UMEH) 143*16kB (UMEH) 33*32kB (UH) 7*64kB (UH) 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 7752kB Per above log, the free memory of ~7MB exist in the high atomic reserves is not freed up before falling back to oom kill path. Fix it by trying to unreserve the high atomic reserves in should_reclaim_retry() before __alloc_pages_direct_reclaim() can fallback to oom kill path. Fixes: 0aaa29a56e4f ("mm, page_alloc: reserve pageblocks for high-order atomic allocations on demand") Reported-by: Chris Goldsworthy Suggested-by: Michal Hocko Signed-off-by: Charan Teja Kalla Acked-by: Michal Hocko --- mm/page_alloc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 95546f3..e07a38f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3809,14 +3809,9 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, else (*no_progress_loops)++; - /* - * Make sure we converge to OOM if we cannot make any progress - * several times in the row. - */ - if (*no_progress_loops > MAX_RECLAIM_RETRIES) { - /* Before OOM, exhaust highatomic_reserve */ - return unreserve_highatomic_pageblock(ac, true); - } + if (*no_progress_loops > MAX_RECLAIM_RETRIES) + goto out; + /* * Keep reclaiming pages while there is a chance this will lead @@ -3859,6 +3854,11 @@ should_reclaim_retry(gfp_t gfp_mask, unsigned order, schedule_timeout_uninterruptible(1); else cond_resched(); +out: + /* Before OOM, exhaust highatomic_reserve */ + if (!ret) + return unreserve_highatomic_pageblock(ac, true); + return ret; }