From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 A0F39240225 for ; Mon, 13 Jan 2025 15:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783532; cv=none; b=fSiykYPQTOeW2MrshqOCOuH/Jd5WFFvszs4DIxJSa4COvg5AfkEExuKee3RCamBX9l2SOkYTdlEeEcLHISP0EJ+PqEW9npoVsTgGbfkYcZFiVoTkq727DEIfcGBII6aQ2wg3FjR6oeALRpVJ+lhsaR2m5v6nW16mGjGs2mPvo1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783532; c=relaxed/simple; bh=BSVf2y3yPbXQKkAVQP+jdiFMtc0B3/HLJM3suhLO698=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FMrd0X/XmjDU9/v+FMwozd9X+C5FtlnhLI28MdyS8rMktTRCugrgusaF/AL1jXF2ww0jwKV9azRBq8mYsy+RqSy+Pj3lXScr/TiVdhsbypIRMF9UF6LrSIF2pAU63F8Lsgzd91ZujRrUxqOZkwx3qyAm/VafA9+hLhHACPjOOx8= 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=UN22exsY; arc=none smtp.client-ip=209.85.222.173 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="UN22exsY" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-7b6e4d38185so420178185a.0 for ; Mon, 13 Jan 2025 07:52:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1736783528; x=1737388328; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hoWZzFZ4pj30o8jUId65tsrWzQ2i2wmuYfON8PrXHnM=; b=UN22exsYSwVmIFMUfkGFV+X3ccW1O3cBv3gvkWrwn2h+41gs9kJBHpfoJHAt33lfZ6 OFPXz2wYozq5lvbKLCEvNyNIss6scnENK/ThH6VhSyUV5e7A1sUKef+8Fx1KiXVAkh5r ggdt6RTVBppeBepIvcRIESg+L5I2NNE7AHojdC5idgfNKiHZ73YGLUayud1J7D4xzFPY S+JpM7eH62vMqfkShwrVIYXkaTF7Pv4L4m5OTWj9eDotn6dRCCljnJDAkeq4Pw0BAoor 4R7rk4o1ntwCfftuiDTXxyZnRatqONNP6VuDhkTA+4WV1VFG6piISIZ+CiHToXTDaucC 8bCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736783528; x=1737388328; h=in-reply-to: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=hoWZzFZ4pj30o8jUId65tsrWzQ2i2wmuYfON8PrXHnM=; b=b5ELM5VL+Y0sCkyt6zri+esQMjq92V6eRgCeZU0PWcAvYxqXQBzRZdXM/LSRHgvq0L PO+IyopDq6AZbKWH4VmzRa1XyCr42PDfZCF7j9c3vhPCeBIKAY/IaX033rS1VaxbL8ju k/sdvL7rouEIIpv7xKOVsPxvfCdFeGI4Ob+BcIvU9ZihSbcHU85BzrufMCNdPHmdeG3X 2MneuFl+UhZPFikTf44SFfjH/n/XG5q0ylONCccxt1OjNK5KZkRi3LEpEn4q2/C/P91g pO4LNZurX7fqlnybNawNV5EFXapnAf7fdtTdPhvny4tipmPmkrvduFo84DhEwOtIEuZL WoBg== X-Forwarded-Encrypted: i=1; AJvYcCWzvY+EM1TkKfJuIKf0MrnwoehGr+uBv+m687kujPkk4NfkTCZ7HDuuHH9wcEU0061+K+bEsQDxlhy3tLM=@vger.kernel.org X-Gm-Message-State: AOJu0YyjZwzRPn8y3s3ntqe0GMAMegnW939V0sLh2K3d3B0AYgjGWduO t177cKsWqYSwECdTBzrvsKjhsLtfoeuiSIVBhpzpxIkw9Gd/SLKkkuGvTUuvAqs= X-Gm-Gg: ASbGnctv7ED/83pvwYgp4m9ZCVqCl25dxLhK0klUAdVIUVkUkq6OKRm8ReEdSsZGCnB 8H6kzbbiHBj8ymQiHY8qEebKNl3gdgM9oxbq71Imf0LXYDKdDeiqL778UHVRq6vjpSFEqVqpMcK +zJPqPqeOZ6vOFolHjQKfVlnMGbkVCRulR5xqj/NSu5XIHnOFXWB+Xbe5DcN52Rf6hm1NoV55v8 FUw8bZ6X/HODKdf0GEuKDku0ZZRF7x2Oe55RMdet7qdxceMKsrAJUk= X-Google-Smtp-Source: AGHT+IE08BUjMbuLP4KmoqR9Eb5vn4epjyX/uelR4lIa8rg+NWttLIUyCND/2qz71rq/PmfYNaPV6g== X-Received: by 2002:a05:620a:2588:b0:7b1:5672:5d46 with SMTP id af79cd13be357-7bcd97084dbmr3002244285a.15.1736783528435; Mon, 13 Jan 2025 07:52:08 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6dfade947dfsm42384216d6.116.2025.01.13.07.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 07:52:07 -0800 (PST) Date: Mon, 13 Jan 2025 10:52:06 -0500 From: Johannes Weiner To: Chen Ridong Cc: akpm@linux-foundation.org, mhocko@suse.com, yosryahmed@google.com, yuzhao@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: <20250113155206.GB829144@cmpxchg.org> References: <20250111091504.1363075-1-chenridong@huaweicloud.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: <20250111091504.1363075-1-chenridong@huaweicloud.com> 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.