Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp182330rdb; Thu, 1 Feb 2024 05:53:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXeDXJ+ekweoP5MIHia+e67p8+FCJa+pjYK75/KuypWS5szZir4MaodD/JSNoUyQdYkeD4 X-Received: by 2002:a05:6808:14c8:b0:3be:add9:76fb with SMTP id f8-20020a05680814c800b003beadd976fbmr5358568oiw.12.1706795587688; Thu, 01 Feb 2024 05:53:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706795587; cv=pass; d=google.com; s=arc-20160816; b=M1naiT1aY29ioC8OTWlU3fykxMVq/scESzOZ6Is8mtKO4THJ1L73pYiJSajiFdCk0n U+3R1m3DTaSbpkUWvmQHqFEW7/+xOqJXO2opD5reXT1gXhW0/oh/qw/V+5enCSYZ8wD6 yGIMupAnmnyszxA5Do/zX4d+uUnxnBbfg3pXK6woNSwkWnGDpLB2cy2e6Oz6szliorF9 3xuKVy/5qxBRbB4NXjN72s2pLlUMpCUPIV702yxFi3XcA7jfeVqg1ZPJdQ8TUtmL6Vzs v2R4XmtPsOFV6Wb5Uk96u+LMgRSCnTyoVpT7NSQngGpX5J/OEczfbsl5IBeOIuY11t0y aYoA== 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:dkim-signature:dkim-signature :dkim-signature; bh=QXLAKSzHX3H7LPzmvOeu1w9fqDyHIC6pdFRLsbYn6qU=; fh=F0US51aaVY59vz/ife9mpJlzGjUDKLSbB/PgwfuboqM=; b=GQ/LvRY1gIdpvWvZO+1nn6zzuaMonybszIX05R9c2n90Ap4uEL/PuVCAEBLSga1wlg xkKi3JcEueIyZ1ZJtVEjOSj0wLo5Jb3cEVxOlFv9GdW1l4Hg7Dxc0/qKBIT3vjShM6ut fmYZWUJaZuombhD/6XWo8x5mRiFHDrir3xhPZmZApCN0C0KDIbubYA/31URmq3/W1NIl ZqxxZHeh4wrEAxrtqMiqdsv1hnVimEzJtina8RMzVsCTHrrgkWOY4hewJK/z6XB76hQC EtvLhkaK/OAbup+T2zpLBLKnkBHAYJWor4siULNX5uMWGZa+zWTyhFalA9BNmuKqrsXa xbcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Wnr/ij3c"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Wnr/ij3c"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-48266-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48266-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXd0VeuSProUh/J0zCtxYJkyhx0EDfH82ZbTo1wy3CpYO3e4GSV+KssPDdTkeBaazvDwkybpDlsi78g2qaRvjGcSLNebidauAspndRMHw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id l23-20020ae9f017000000b00783571b7509si13993988qkg.483.2024.02.01.05.53.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 05:53:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48266-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Wnr/ij3c"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b="Wnr/ij3c"; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-48266-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48266-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6F66E1C23841 for ; Thu, 1 Feb 2024 13:53:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE92F5F462; Thu, 1 Feb 2024 13:52:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Wnr/ij3c"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ObB0qpuj"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Wnr/ij3c"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ObB0qpuj" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50FE45CDEC; Thu, 1 Feb 2024 13:52:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706795556; cv=none; b=UIsHoVhZFBv3EcETzPIjj5JkioeW85lvQO2Of2yv58zpT6hLBYPs1V/sE5TSnimAz4kdaNn9dWPnIJD1fQ9Wa4kAtUPmYg6kkKxibNnkYwJFhb3dF4psDZU2unpUHOujNixaHzmR3Ctcg3f5MFAl2mRKvMz2r4RGKRPIXVAM/Ek= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706795556; c=relaxed/simple; bh=rEX9GUMW7rfBrCx8VpRtb1mBFzM/kN0JmS9EePHlTC0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qiK++uqfZGKTyI356LKM5xCocOusZZ5wG86VABv3V1nUrXmnzDenFiSgXoedNFSO9RUmRpiORrxtNjEQL6JstfafVXmJPHr+TcL9fijbB4XSMe25bw6ETlh+fZmbQIWMRAXJn5AdrP3ZlDNaNZhRCMgQ4w3KfSxOXNbceT/V7/M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Wnr/ij3c; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ObB0qpuj; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Wnr/ij3c; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ObB0qpuj; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 25C8E2216C; Thu, 1 Feb 2024 13:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1706795552; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QXLAKSzHX3H7LPzmvOeu1w9fqDyHIC6pdFRLsbYn6qU=; b=Wnr/ij3cMxbQLn1J5JeiEN3JP3xSrwMxBG7wen/9M+eXezXyuPZuf/P+usPZaJlgzx0vI2 dsT/79GLcdEicmUXpa7/V0nK09Y2hjYPAd3lDtcFYQB71aq0X7wUFladF7H7NutqtZrK8R bEN3lTZURBQtT6H1FUL5y/aAovSYJGM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1706795552; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QXLAKSzHX3H7LPzmvOeu1w9fqDyHIC6pdFRLsbYn6qU=; b=ObB0qpujeoxkArOyrTmPv46kyZCeJVO+CPQl6xTZopBwm6HvYMYNwh+As6rGhyHXDogBoS buDTjdUv61uYcABg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1706795552; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QXLAKSzHX3H7LPzmvOeu1w9fqDyHIC6pdFRLsbYn6qU=; b=Wnr/ij3cMxbQLn1J5JeiEN3JP3xSrwMxBG7wen/9M+eXezXyuPZuf/P+usPZaJlgzx0vI2 dsT/79GLcdEicmUXpa7/V0nK09Y2hjYPAd3lDtcFYQB71aq0X7wUFladF7H7NutqtZrK8R bEN3lTZURBQtT6H1FUL5y/aAovSYJGM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1706795552; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QXLAKSzHX3H7LPzmvOeu1w9fqDyHIC6pdFRLsbYn6qU=; b=ObB0qpujeoxkArOyrTmPv46kyZCeJVO+CPQl6xTZopBwm6HvYMYNwh+As6rGhyHXDogBoS buDTjdUv61uYcABg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 185C313672; Thu, 1 Feb 2024 13:52:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ajPtBSCiu2XWSwAAD6G6ig (envelope-from ); Thu, 01 Feb 2024 13:52:32 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id A6C19A0809; Thu, 1 Feb 2024 14:52:31 +0100 (CET) Date: Thu, 1 Feb 2024 14:52:31 +0100 From: Jan Kara To: Matthew Wilcox Cc: Liu Shixin , 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: <20240201135231.tgnn7cnlmtqh5n4f@quack3> 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: Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -0.80 X-Spamd-Result: default: False [-0.80 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[9]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[10.62%] X-Spam-Flag: NO 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. Honza -- Jan Kara SUSE Labs, CR