Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1003476lqp; Fri, 22 Mar 2024 02:37:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpuepkXVF5bbOPxmidiHWC7UqTYISCSDY9lD9KEDx8hvI7b3V2eVdc11b3/r9MTOXH9m15JAkoqktxzgnerRrmEspB41b6MFw92GnVbw== X-Google-Smtp-Source: AGHT+IEGM7zSXXCTvj5VqosvuLQSLFcaET/2PZC9RiuhOVtNVqBHuxa4hKnql/Y48vHT9YaX/XrV X-Received: by 2002:a05:620a:137b:b0:789:ea9f:76c0 with SMTP id d27-20020a05620a137b00b00789ea9f76c0mr1766982qkl.56.1711100223678; Fri, 22 Mar 2024 02:37:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711100223; cv=pass; d=google.com; s=arc-20160816; b=n8RwiZ3HB4lpZjiX5o1Y4EXj9QGvQfUv/FCitCCzaGc/tm23t3r1ds4AIjv5utpUx1 U+1N58ZBr6Vh8cYJMC83ce2YRN5N8EweeONVUMznLE4x39XWbebOh1R9QX27ThwKsAat 8p4CXQ4MdMjoexvvUUEzjcW6rxdy2inLb/7SxkJkAHyAZNuuDonIevexrmFO4Zfc3CGU nFiUkyvppiZDstGGrkoBQfv50XmVgPQD2j50uVRyCHyTkL2FBv4mujkujhLBaP66vU5s pwCaVqTrMnOQutdoBZjwIP8bKfkTwTGCmqyLZijXkaGTKbC225HzrsEk5nhgxb2woOdX NGFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=hOgjlK55Rk2PYJt5Fh+4dQXPv5aYLN4GHj/g4tJVCB0=; fh=JPsdd6h06AA815xES2bFeKm85BIKkA8uK8zn2NVxFhA=; b=dZUYJEkDjAqGZd4k5t03Lrbq7n3sfwTP5DcSmHnQq4Qz3lCdMyxSiUKLogq0NkGHmk 712fF7X0a55W3Zx5BptwrKypsXQxERVc7i6Q7CucoeiyqPaDkfnVUfVRsmuKzwiq3Kwe C6ILOX8pbM7RHNS8yWvRNsH/isFf7oIRgpdODuat1zz7n3MSdXEL7ed4zmvkj7417+vn GzyGL40bGyQHei54Ig6/N648A7GE5vbYT9sOpi0GE+dRkJuOwXxgItwU3V+X3FMWpv85 5Kf4m6Mb3PrkJzIN98SE9sxLdEUYEFt7BvodAUM38IUZ10MR54ceLU8UNTJANwytsyaQ Gz6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-111227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111227-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y9-20020a05620a09c900b0078a153aa230si1592311qky.202.2024.03.22.02.37.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 02:37:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-111227-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111227-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 893431C239B1 for ; Fri, 22 Mar 2024 09:36:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 072E438DE4; Fri, 22 Mar 2024 09:36:27 +0000 (UTC) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F987224FA; Fri, 22 Mar 2024 09:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711100186; cv=none; b=Zn1wrNqbPB/UYYREAQFvHrqMXv5slP6jIaBun+yvG/tkbXJWaSmRU9qWxSmzgkHr4SeTi3Ba4hXg7Eshafsl5FRPqrYy7FC7eCEAkVkErJZHOPQXq97Ksiws4mF4ybV1WjxcU9vx1KwUd9STgqdGkAeJ7bOrDNbU08MYfZttmyY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711100186; c=relaxed/simple; bh=Un5FAxnjdEo99yKEgJewvVt9ACNBktRqYLuELAqgtSM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MDQL5J8qtin6fQzThqm2RrJiE6OOKdcNI237C/bIIM2HQP4aXpj9j4JUGx4/2kl+ykZUjhwqnt4XRDNgE65/HLf4/06t8B5gVDBzQ8iGXPEvtMeV6a/cePuk1i3XkFA8WcOqqdkG2ip9Vg2Od3L2zQPWLOl8FZR24C7GMQCyR5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemd200004.china.huawei.com (7.185.36.141) 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; -- 2.25.1