From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (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 80FB115852E for ; Fri, 17 Jan 2025 16:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737130093; cv=none; b=p3TNT1ppndHIO9PcFgYe7XuH6Yhs/sPzGvHK16U2ISj46a5pSJff1Ja8NsesMtx5eWHlElN2GD4hr1NGpMc/2tcKAhLwmsSKLCWOUk+nXLr9aTKLREHRBHRZCDgQ733lQWVNzRwHfAG4EwNdXmvkGVLxpBbyM9vG3g3kgqO4lak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737130093; c=relaxed/simple; bh=4X/vwufpFngRGjACmoqmaFEQ2NvuD4uOfrUocx3T9Jw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ncXhzZLjMOOuDmiX1uEtGnYb7qfQ4AIwgmCsSDiU+6hRiCkE8OvZkvEn4FzfJJoXH2XmqJis0GIvyeDZkTvWXNRTlBi8Fb1jwy9kE1ojovWqJYmPW/PaklcPzic+O9L3vauyq3oJk+Gel15TMkERvNa6VoqQ4qPZ6tzynSkA7RA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b=cYf5C3JM; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="cYf5C3JM" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-467bc28277eso20738501cf.1 for ; Fri, 17 Jan 2025 08:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1737130089; x=1737734889; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=TzFOrc8++e6jSAehyUUi+5x6xOOD+5GZ3W8iI61RM0g=; b=cYf5C3JMd+1f2yev7WQNiF149i1jpOYkyzylWm+v20CcPB3fMaJBu1qHKZrtVfil8m vr2kuEpYU93gopGdKJJyCrWLH3eSERHtmAzD5wPpt8sR8mzA5cqkbiam9svOTLBx9ZfA jPrz7lGLVg+jS8mH0LvIzdZOYBTrg+8wx+OwhT4/nBqB5Ij2GuSdZWPmv0IgbSsImpV1 AciSic8eQcZGfhIzjElSr1b0KxNpFg6ZC6IrCifhocGfl/vpRzgoZuxA/6RHYqNR9QUR 8EGc7WiyoNaVw4korT9eyh4tJloZLVUFruxyr+D0yI8wuVN8WPivW5yr4JyUBu1V0du0 HMiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737130089; x=1737734889; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TzFOrc8++e6jSAehyUUi+5x6xOOD+5GZ3W8iI61RM0g=; b=GvsBuqUoz3qnJzr0DXfAIyBvBBoidPrc6z/mJlCB20CuZUstEib0alYbRZwFEtV/FR eOioCAS6jN+oL/Mgb6rfaTwc06WN8ChntwnwjrNCbQnkhvwNHxeyL9frIFB4ZSsyGPmk w0XZUnHJnMUnttjIH1GvFfYvSJF5nrQ2DQE+k32bPoP68wBjZBUiQskOoePNNGq9vhr8 Dh6/LVAQWsDnC+jyLX12DV6/Xyy+VXFzNtLeUpMk41UUelyQUVkLrT1dodC69l2NK6tE 0H4TeK5/YGTjeYFvYLdGblq6tyEppTEz87SHCZ+K1eItHTkjayjMwPxOSWJ0TaBdCGS4 UaAQ== X-Forwarded-Encrypted: i=1; AJvYcCWkNnmJ4qW6LG2qVWnTelZ/ZDU8W8ENZWw8cFba6ARNjD0L/Lp9cx6OJ/E7uuSBOfcE6WplRCMPeAbO6IU=@vger.kernel.org X-Gm-Message-State: AOJu0YwJEMswjyk6asD7cQ62aaXE7tUxHa3QT6/ItTQRLiy2C+WeXsAe +7pGC9TtZjsQMSLytjkpMGhmzUoKilLQot+AbSFLrMlCcIsLjkTQTmSjqQCrS7k= X-Gm-Gg: ASbGncvdXPSpQhKJNimvieXMftYe36oq41Oy4E6WgA6lm1v71cetIOH3TnMsu4gY873 lKd2iyJIh00aRL+n8OLlhVLRBU4/aP11Ap1FIcLKiSnkAw+TjoCcVkjGLMsfIwGRS2gaILw2N1/ OjC//ApaLUxrL62ag7IK5yoc2dLNJdGjHUfCVFC9SstA7jzfjEDkAGNGVvJAvydg2gUOzqgQPD5 C5FPrnxOxfC7ZYNZ55gch828ltwOitjpE6sw1WQV97lbOCucJ11ysw= X-Google-Smtp-Source: AGHT+IEGIi75WP09z3DZQhSalvgpRut37RczhbXGlZumzaEaxztGR2/rD+O5503nc38ZHAvdHhPosg== X-Received: by 2002:a05:622a:413:b0:467:43c1:f0ea with SMTP id d75a77b69052e-46e12a3fa11mr59761241cf.16.1737130089149; Fri, 17 Jan 2025 08:08:09 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:f0c4:bf28:3737:7c34]) by smtp.gmail.com with UTF8SMTPSA id d75a77b69052e-46e1030da0bsm12473631cf.34.2025.01.17.08.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 08:08:07 -0800 (PST) Date: Fri, 17 Jan 2025 11:08:04 -0500 From: Johannes Weiner To: Yu Zhao Cc: "Kirill A . Shutemov" , Chen Ridong , akpm@linux-foundation.org, mhocko@suse.com, yosryahmed@google.com, david@redhat.com, willy@infradead.org, ryan.roberts@arm.com, baohua@kernel.org, 21cnbao@gmail.com, wangkefeng.wang@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, chenridong@huawei.com, wangweiyang2@huawei.com, xieym_ict@hotmail.com Subject: Re: [PATCH v7 mm-unstable] mm: vmscan: retry folios written back while isolated for traditional LRU Message-ID: <20250117160804.GA182896@cmpxchg.org> References: <20250111091504.1363075-1-chenridong@huaweicloud.com> <20250113155206.GB829144@cmpxchg.org> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Jan 14, 2025 at 08:59:04PM -0700, Yu Zhao wrote: > On Mon, Jan 13, 2025 at 8:52 AM Johannes Weiner wrote: > > > > On Sat, Jan 11, 2025 at 09:15:04AM +0000, Chen Ridong wrote: > > > @@ -5706,6 +5706,44 @@ static void lru_gen_shrink_node(struct pglist_data *pgdat, struct scan_control * > > > > > > #endif /* CONFIG_LRU_GEN */ > > > > > > +/** > > > + * find_folios_written_back - Find and move the written back folios to a new list. > > > + * @list: filios list > > > + * @clean: the written back folios list > > > + * @lruvec: the lruvec > > > + * @type: LRU_GEN_ANON/LRU_GEN_FILE, only for multi-gen LRU > > > + * @skip_retry: whether skip retry. > > > + */ > > > +static inline void find_folios_written_back(struct list_head *list, > > > + struct list_head *clean, struct lruvec *lruvec, int type, bool skip_retry) > > > +{ > > > + struct folio *folio; > > > + struct folio *next; > > > + > > > + list_for_each_entry_safe_reverse(folio, next, list, lru) { > > > +#ifdef CONFIG_LRU_GEN > > > + DEFINE_MIN_SEQ(lruvec); > > > +#endif > > > + if (!folio_evictable(folio)) { > > > + list_del(&folio->lru); > > > + folio_putback_lru(folio); > > > + continue; > > > + } > > > + > > > + /* retry folios that may have missed folio_rotate_reclaimable() */ > > > + if (!skip_retry && !folio_test_active(folio) && !folio_mapped(folio) && > > > + !folio_test_dirty(folio) && !folio_test_writeback(folio)) { > > > + list_move(&folio->lru, clean); > > > + continue; > > > + } > > > +#ifdef CONFIG_LRU_GEN > > > + /* don't add rejected folios to the oldest generation */ > > > + if (lru_gen_enabled() && lru_gen_folio_seq(lruvec, folio, false) == min_seq[type]) > > > + set_mask_bits(&folio->flags, LRU_REFS_FLAGS, BIT(PG_active)); > > > +#endif > > > + } > > > > Can't this solved much more easily by acting on the flag in the > > generic LRU add/putback path? Instead of walking the list again. > > > > Especially with Kirill's "[PATCH 0/8] mm: Remove PG_reclaim" that > > removes the PG_readahead ambiguity. > > I don't follow -- my understanding is that with Kirill's series, there > is no need to do anything for the generic path. (I'll remove the retry > in MGLRU which Kirill left behind.) Dropbehind trylocks the folio, so there is still a chance of misses when the IO submission is from reclaim (which also relocks the folio after IO submission). Granted, that race window is much smaller compared to the window between rotation and batched LRU putback. Probably best to retest on top of all the pending patches.