From patchwork Fri Mar 22 09:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13599847 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 1726AC54E71 for ; Fri, 22 Mar 2024 09:36:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B2356B0092; Fri, 22 Mar 2024 05:36:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 756966B008C; Fri, 22 Mar 2024 05:36:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61D2A6B0092; Fri, 22 Mar 2024 05:36:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 54AD76B008A for ; Fri, 22 Mar 2024 05:36:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 299121A0D4C for ; Fri, 22 Mar 2024 09:36:26 +0000 (UTC) X-FDA: 81924169572.05.91617B7 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf15.hostedemail.com (Postfix) with ESMTP id CB774A000A for ; Fri, 22 Mar 2024 09:36:23 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711100184; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hOgjlK55Rk2PYJt5Fh+4dQXPv5aYLN4GHj/g4tJVCB0=; b=H6aeMCmNl2vc/DChZVjn+RaWe2rgEkA21HApWtcINN/BMTnh4HglKuet/bqPhSFtZ0NwmH ryVszXXoNq9T2hG37gRowtGm8AA0UTNYOlv6VdCEf87k2O8uzPSyZf3vJTi3U01o364u07 LwpugjnTVQK4ZJuMjHWB/MEyxoBAflY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711100184; a=rsa-sha256; cv=none; b=LWioByxiyJ/GjJeu8ERHksoiRYw4p/Vz/RDpSOIv7wjGmeYczzt5jisUkzI9KaobgsX1xl kcKcvd4RQo55TEGJS2SZmiAYg3P7utDDrjBiKylR1UbB1zdkXCr3nXdeGT2EnZ5+et/sQv RSdYnD45JQG+zvNTjbvSyPjMswQC8ws= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4V1HGS0pCyzNm8T; Fri, 22 Mar 2024 17:34:24 +0800 (CST) Received: from dggpemd200004.china.huawei.com (unknown [7.185.36.141]) by mail.maildlp.com (Postfix) with ESMTPS id 8079A18007D; Fri, 22 Mar 2024 17:36:19 +0800 (CST) Received: from huawei.com (10.175.113.32) by dggpemd200004.china.huawei.com (7.185.36.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Fri, 22 Mar 2024 17:36:18 +0800 From: Liu Shixin To: Jan Kara , Matthew Wilcox , Andrew Morton , Alexander Viro , Christian Brauner CC: , , , Liu Shixin Subject: [PATCH v2 1/2] mm/readahead: break read-ahead loop if filemap_add_folio return -ENOMEM Date: Fri, 22 Mar 2024 17:35:54 +0800 Message-ID: <20240322093555.226789-2-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240322093555.226789-1-liushixin2@huawei.com> References: <20240322093555.226789-1-liushixin2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemd200004.china.huawei.com (7.185.36.141) X-Rspamd-Queue-Id: CB774A000A X-Rspam-User: X-Stat-Signature: fjukxjgpodmw9a36iwjwmxj6rjjbpshs X-Rspamd-Server: rspam03 X-HE-Tag: 1711100183-711047 X-HE-Meta: U2FsdGVkX1/qpdnP45rpvlHp+NLNpPUhu3hcYGBsZTUhgBbsLDsGPDlFriAds3PrBxvdXoYKyM2ahSNDhT6RXIbzwPwuzMZepgGjvNq8gz7e5Jau/l+FcEnUSYntvM8Pb2GxWmL75s0WIQGFNwcR6NJupMVyftFbOtoSC9UWmYmR7RdYNLquFgbhki1AEc2QFIZEmj//v6QJXS9iYX9eFsnMw9mfIsY2QWTyT9bH8PMOIzIWw6ZbJSwuDUv4M8TjYTpcpMocOztKxJ5MLPabl5M5crd5WfYvQY5QotNu+fvsTXDVRNaJCkcR1Z0bz6gwSurw0vrvrWbbO28ncpvfP7+Pus62ZX4PK5VtLRZrGs0mWWufd7rTeCUzT83mQkUweJt/KXE6oa0+vEAeOWeJ0GSh4ZzrKqi138n9HHeukgi+cZTY8jT3Im4joV/k2Z6VIBxwQ0A2rv5cPhJxfaKoCsOi2f7aJdHIsaidifIQp98JyAFi4XH9CRcxfMNNwxAjeHd9fPJS+qRACxE8aBg0HQtWW6wHKIbU+KkGeiLF7gIAtHPwLf5G1rHQPSAOFY2BQtg1o0n7czVcx1ALGgke7E2RqDysEjG42uljR068lKpmxvQ98pFgJPMXu1ToY3NVMAhGbd92fgrObSiU5ih8arDPhY1g9T3hmAVXf3NE6otAJpkUoPsNn5LXhb0GzmXJyCn13hKRe1PEpKqAl0BSsoFFhNs8r/NpIIVBgMpfVQ05zIs7ZtbVoCXm0YyF8ADgKwHb5IzTJ9PkP+Jap2Ox9f5K96B2iqAelDM1mmNdakphMcXzAdgHeDO7nIyo4Bm6+LqUM2Rpc7SLqlp98G0G33SO9jm6Zs8klpWKwXSHszLcyrTLVzk86m456c2QlZe0FLr+xFXLKI3l7nrVK3KNqPugqLq50yvJq8uM1AOQQkK7SU3bjX2KKKyp1kz8JMhE+wICQ4n0UaJ5NuzjQQg F0XJoONR 7sgYhf+YJEm9d3M5G6iEhS1F5RRsW8dVjK4iOjvYDoxrdWsGwBpCW86ixmKZiS6eerSKIZlsVJBmM5l/+8qDWF5Rm7ko9Kkh4K4HTHEneSs0lUsFL3Mm+cji23ATbFSxF3ohrSUGTSfs0VHxkgpOv0Gaq4it3wbjT60iys9a+w7VNqCQNZiVZH+xFU6AnI97JEG3Z 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: When filemap_add_folio() return -ENOMEM, break read-ahead loop like what filemap_alloc_folio() does. Signed-off-by: Liu Shixin Signed-off-by: Jinjiang Tu Reviewed-by: Jan Kara --- mm/readahead.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 2648ec4f0494..a8513ffbb17f 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -228,6 +228,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, */ for (i = 0; i < nr_to_read; i++) { struct folio *folio = xa_load(&mapping->i_pages, index + i); + int ret; if (folio && !xa_is_value(folio)) { /* @@ -247,9 +248,12 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, folio = filemap_alloc_folio(gfp_mask, 0); if (!folio) break; - if (filemap_add_folio(mapping, folio, index + i, - gfp_mask) < 0) { + + ret = filemap_add_folio(mapping, folio, index + i, gfp_mask); + if (ret < 0) { folio_put(folio); + if (ret == -ENOMEM) + break; read_pages(ractl); ractl->_index++; i = ractl->_index + ractl->_nr_pages - index - 1;