Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp323753rdb; Thu, 1 Feb 2024 09:26:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+R18GIsUWN1Pmfdghdt2HZDXh3IvjhTpHxrdHWhn+sXrh7vl2nh3sDrvVDup2g1G12TZK X-Received: by 2002:a05:6402:78e:b0:55f:b005:57a1 with SMTP id d14-20020a056402078e00b0055fb00557a1mr2042782edy.14.1706808378572; Thu, 01 Feb 2024 09:26:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706808378; cv=pass; d=google.com; s=arc-20160816; b=A57S7sb1IdrIaD08KtJvohnIUqbtWXohHxve/9fyVhQS2fl8SLDHSinVUg6oQuXO1k UALV181JIayQO4NAGLgVzCquvEHgogaQBZgtQFmHNC/7KpHv/ex4zlwG4tUNL/zEVaC0 ZVXp0ceL34GsY4MGtKQbuFnrxSX3HAFJskg6e97xqfJaBLxZpRfaI8Pn8+wc1nCQWeYi OKUG7utkPhFbXD0ZOT64TdzxS7+TFgTXjJOVckeVBg6PNofmJEwTXtWM0Ow4L4FE4ZvJ RjQl+Ry8bRFo8ehXqBU0eKDLbuo5/EYZlIxF9Br4ZeFGo+rmNxDs8Rp+6Fw77SVyniwc x6BQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tYvzDfQFwKusRhTebIY0H6L6hobYf0zaXRaAkQ0RHv0=; fh=+K6rQCiikZXB4amk+V7RUIsXiVewobaghSkas/BqU9o=; b=Y8R499xRLgmsMwaUUSkda/0y9iYr0/YStaR+ASSIeo/R/Y6qUeN4QgHiinAEJ3Nk60 N/gKvrO+NfeQfptduInM8hw8kri2OsWqbiTFHKWc1eLlCvkc3Rv2T41AToFccw02XmYr 1O4IrCLfYP3GOSh2iu07DrPsoRyuMSBNfNnVuL2YIKyntAN9oZ/TesefaLeSlCWnaRh5 obl6rtka3gnYjknSmAPxPsSpuIsNFgfBepw30aH7dJSpdQel3dq+/QdspzZNN5d7zvJj a7Xxi3jO1rwRIGFn9AS6izX+JtsvPJMrWgg/H4Y8k3AGEv3ElG6xrlAwUUo5nJhhBEy6 z9UQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZTZ1f+NB; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-48260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48260-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCVv2FUig/YwRR1UFVzmLPTAWTdOcezC81vd1xWf9w9M4hlSGnaTwkZI4nAmc3Uo0LnccDyH+mGVw4IV77pf9u8/q/9pwW8fY4CLkmk8JA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c62-20020a509fc4000000b0055f0cd6afcesi3987edf.642.2024.02.01.09.26.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 09:26:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=ZTZ1f+NB; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-48260-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48260-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 786961F26B5E for ; Thu, 1 Feb 2024 13:48:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 077A35F463; Thu, 1 Feb 2024 13:47:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZTZ1f+NB" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 55EB453389; Thu, 1 Feb 2024 13:47:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706795235; cv=none; b=b7+JC38wI4UZTknPbC/H/V0FLhnIkz+1eTOlz/Tk4o+dxHWKACJUnxSq+N0igbnnpeKQWGXVJpmXi33y/q2F7OnM+8FvBRcFis/lUEmkdWBqAqbGIzCc6j0yaCahzDEWsdxsUn+mkKpLxT4Fkg3wGv6sSzc+rGkoy+HKYLi/zEg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706795235; c=relaxed/simple; bh=MicJ7RF+w26oTpS4mXGfMglg4DfFvf7LKePLvO1pSV0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mM5NnNM2dOpTCyYPsUToxffCxjMcICQVPgZ/YJ5wDhC70KO2cKyJV9GD+dqBqFran1ItvDIgX4leYfBn4AnfOcrRWITsvP9B5ZeXYfIv+N9M2ATks0wPzuXScB2HMKxMWv25TZic6c6zRyykyIqxrRhGb76l8zVGABjH7MPTYC8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=ZTZ1f+NB; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=tYvzDfQFwKusRhTebIY0H6L6hobYf0zaXRaAkQ0RHv0=; b=ZTZ1f+NBXyhYPNqdhJlWo2ZOEI R/PgLoYl3Eee9mq1bkdGmYgdsofoHdCGIMIHplMCeFEMN14Ee/o8MDdHGxDOo97AGNQ4KWkeOhSz8 Mc1liETjGH0RSzqfoTUWc18nQjpe8Eb/RA0YCjPwu09qbdoYEz90KpimVadd+QhkAXlZya91W96Sg P9G1m2TeVnCaobr8RXj5qAXdU5idsx33NPYyaYEJDHXZil8IiYak8DSKGLSwabiXHpLsDj05/0KbJ NjB9SMjRnQNle5b1DGFPL2d8rrRpyEfnetRXjcgalgNuhGyu8HR+hH4OpEiooAYv0AbUIKemBmACr v31qxLJQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVXPD-0000000FwiQ-2CYU; Thu, 01 Feb 2024 13:47:03 +0000 Date: Thu, 1 Feb 2024 13:47:03 +0000 From: Matthew Wilcox To: Liu Shixin Cc: Alexander Viro , Christian Brauner , Jan Kara , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 1/2] mm/readahead: stop readahead loop if memcg charge fails Message-ID: References: <20240201100835.1626685-1-liushixin2@huawei.com> <20240201100835.1626685-2-liushixin2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240201100835.1626685-2-liushixin2@huawei.com> On Thu, Feb 01, 2024 at 06:08:34PM +0800, Liu Shixin wrote: > @@ -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; No, that's too early. You've still got a batch of pages which were successfully added; you have to read them. You were only off by one line though ;-) > read_pages(ractl); > ractl->_index++; > i = ractl->_index + ractl->_nr_pages - index - 1; > -- > 2.25.1 > >