Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp340730rdb; Thu, 1 Feb 2024 09:57:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEr9WXFU8n7UKHMX8SjMfAsXZgciCw/zRx2Zn+IQNA9sQcXkkc/NXUdMyepQ+c4i61NiRay X-Received: by 2002:a17:90a:ee96:b0:295:f30d:ae6 with SMTP id i22-20020a17090aee9600b00295f30d0ae6mr4812356pjz.16.1706810240578; Thu, 01 Feb 2024 09:57:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706810240; cv=pass; d=google.com; s=arc-20160816; b=Ue3OWD9G3RyuSJt2LWwLt6mLPN6M/2r/4jJVgmXky9zBEA7+7+/c+fzoVv4RfGAtYF KUpoFU52dUntX5KrPW0iEaYtYiggpnDelZSHR2/muPF75/fpb4sP0J24eVbefNohB5lX y+5x8ZK7XvJHYECvoxFqshuw9JJJbIMCiQ/Lzm0UteZVzqYKIbcr3zhad/yUfzRUR9xC wT3oOCrcVVyLCUrCYRLxykzpsjuk9pDfAF74qzM4lonFCSR5eLQdPmEEvaS1SlUPrFq9 sTVH/mR+O0z+SpQsKT9cuGkml7K4Nve7nnm6N4oLICkRixYgBjW1VXrZ++pnxiXRnpsx oNfA== 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=HvWvFe8kmg8uC1rXi4MnVrUITUPbCSnUcddzzqebB+A=; fh=CSKXRuNhRu5o+AbwfJPaA4jaiCrNS9aVkEMVzug60II=; b=Gq0tRJcAnePmH6tRuyIUtMRUAPDAIM7Xld5NB67K3vUwqifKZZ0gveaJof9OEJzI3e KlMLeEhQ1P+bst68QmBCNXeeJLZ5+OxImdZxOUb3Lq+sic8KtfCPxedT7Shb8kWp5XFL +wpSm3AmsO2iBvgLrMwanxWQOrFqvqj7giYOW70fl3luSanuXCQpaPi/+yM2yf5v1zxX F6mEwOnxCZOAP3fWmBkdS1MPYDzflwRh0nuM3xbyS6sMPo0KIq9kORo0zxlluXIycjGM fiKuC4OIjogOcVpiz0vMdIoShtm53r7VNCqke1Tm6TTSmR0Ar+F1YAX+si5u7daR5vgS PSpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=mJ4Nplj6; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-48269-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48269-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCUDwfgfJFqIwemoEva8EtibSdITX4GdmVG4ELA4FquxUdrdzjJaz9sZ7hqyOmbCRzaa09k8ggKE0MaKH8cSyMfomxQphukDFVoMuo9N5Q== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id nk17-20020a17090b195100b00295eb30fe5dsi203177pjb.46.2024.02.01.09.57.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 09:57:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48269-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=mJ4Nplj6; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-48269-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48269-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 35DE2296330 for ; Thu, 1 Feb 2024 13:54:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 571505D491; Thu, 1 Feb 2024 13:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="mJ4Nplj6" 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 F2FC05D48D; Thu, 1 Feb 2024 13:53:58 +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=1706795644; cv=none; b=lDhVJsXCmgfSm2N7lpT09jvWQloUpsggSToXE9qxwLrJ+gmIKZTc0Es2HzncSBQVV0ic+ZDftaH+GNTAOlyVNlBbw+W/wJRyZ+LIyBhCTL1SDJqfuZA5O/pPoETJhppjq+nlWPBS08GGFtst2uBXUmQYhqwNWcjn1KPSeG9k9Us= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706795644; c=relaxed/simple; bh=UaYoO8odMjsOoJa0rA+5orOrqeLC2r0iVUdb6uKnm/Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QEcxktAdw4I8axWONj8R150I1vuMCtRyc/3PZ9z9hRUCkawhYnOzoBuF1oeS03teHrWMqZhxljRiKrSTZRMn21OVGl26UQoc8R6ar53MyUJB94bR9Vwyr0oAE2MzTyBjczX1PDIvnnRnm0HbUn3h8HGINpJ00+hpDfzp15f7C+8= 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=mJ4Nplj6; 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=HvWvFe8kmg8uC1rXi4MnVrUITUPbCSnUcddzzqebB+A=; b=mJ4Nplj678opG4pI0nIIioQ2ao ehU6FxBSUrTMKj9Xqt7omU5DeAVSCxi6SfC9aiT/nRK1tHvEF6MgJPKpU37FpkPuXEtIMuJda+IPv duBz42Tn0qfXvytuDT7kpBOEkwkwK0AKZeu3n/ehzXwqiXd9EhcWX4ZuW65nmqlB92aIypjN5/Buc EFDoverS85GS/IBfiTk5Ymyc7mlHZC2yckd2UIvBv6mIEHiPUiW/foidIwTdqrUMG/IKWsTGfxPLO gF/NtWJGtKO01th3kWeJ+qRy36hljFmUHCpo4NusHGXIrqEfHpv5Kf+TiJySl0MVI59VwoDCq52nQ RuWExw8Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVXVq-0000000Fxpf-31Gt; Thu, 01 Feb 2024 13:53:54 +0000 Date: Thu, 1 Feb 2024 13:53:54 +0000 From: Matthew Wilcox To: Jan Kara Cc: Liu Shixin , Alexander Viro , Christian Brauner , 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> <20240201135231.tgnn7cnlmtqh5n4f@quack3> 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: <20240201135231.tgnn7cnlmtqh5n4f@quack3> On Thu, Feb 01, 2024 at 02:52:31PM +0100, Jan Kara wrote: > On Thu 01-02-24 13:47:03, Matthew Wilcox wrote: > > 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 ;-) > > There's a read_pages() call just outside of the loop so this break is > actually fine AFAICT. Oh, good point! I withdraw my criticism.