From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta0.migadu.com (out-93.mta0.migadu.com [91.218.175.93]) (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 361353B2D0A for ; Wed, 26 Aug 2026 09:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.93 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787735187; cv=none; b=JQqSO+rjZ+UBadDZmUEf7Tt9vN7Eo4WIHrMCkR7yPc+R6TnnUSnaiOdf4tD12L7GIdw2fZKNfgNLKvKbsSyEZmwzhhtwW+wLrKZy8u+GlTlD6f0wRznQgfXfcxz3xzV5lIsqxxhEUxyOtItscakaJ99hfC+3Z/Wof/N76Ndvdnk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787735187; c=relaxed/simple; bh=6qfHuU2CPeFQ/FpwTQILkdqooY7I0WFuJOzbL3HiHGw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cfbBdy1NF0TFtKNodLDHyGhcG6lIovzS2q89VLRoC94ImIJigC3AGs0J7vWr/vQ2U6KkrNF50mlHgYKYgfZXp0cpFSDEwbAqt8eVBblg+LHF/FkhvAos2iKjZEDwwmWEUaWvKTzLkhNFZtq9jmURKjTb195qOo42qWckQ+Kw83Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=WpSMDVtg; arc=none smtp.client-ip=91.218.175.93 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="WpSMDVtg" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=6qfHuU2CPeFQ/FpwTQILkdqooY7I0WFuJOzbL3HiHGw=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787735183; v=1; x=1788339983; b=WpSMDVtgX8+yriZAVhEDemGgZ+KlqBl+3mi6YvysMWM3nYb8kC21FFes5S/an2W693emHyGn 36Zoxdaj6madOT3DNPzlj5lTmMVe7of8x+AVObHY2SZkIpXty+D5HBoEtTkE92iT0NYJUaFyi06 w1RKjBCFF5xaGVO2rBgJkLs8= X-Envelope-To: linux-kernel@vger.kernel.org Received: from localhost (223.70.159.239) by mta12.migadu.com with ESMTPS id be78230b644cb2df; Wed, 26 Aug 2026 09:06:22 +0000 X-Mizu-Trace-ID: be78230b644cb2df X-Migadu-Flow: FLOW_OUT Date: Wed, 26 Aug 2026 17:06:20 +0800 From: Baoquan He To: "Barry Song (Xiaomi)" Cc: akpm@linux-foundation.org, linux-mm@kvack.org, axelrasmussen@google.com, baolin.wang@linux.alibaba.com, chenridong@xiaomi.com, david@kernel.org, hannes@cmpxchg.org, kasong@tencent.com, lianux.mm@gmail.com, linux-kernel@vger.kernel.org, ljs@kernel.org, lyugaofei@xiaomi.com, mhocko@kernel.org, qi.zheng@linux.dev, shakeel.butt@linux.dev, stevensd@chromium.org, wangzicheng@honor.com, weixugc@google.com, yuanchu@google.com, zhangbo56@xiaomi.com Subject: Re: [PATCH 5/6] mm/mglru: move folios from oldest gen to second-oldest gen from head to tail Message-ID: References: <20260821102538.22642-1-baohua@kernel.org> <20260821102538.22642-6-baohua@kernel.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=us-ascii Content-Disposition: inline In-Reply-To: <20260821102538.22642-6-baohua@kernel.org> On 08/21/26 at 06:25pm, Barry Song (Xiaomi) wrote: > For reclamation, it makes sense to reclaim folios from tail to > head, as folios near the head are relatively hot. However, when > moving folios from the oldest generation to the second-oldest > generation, using the tail-to-head order would effectively cause > a cold/hot inversion. This is great, do we need do the similar thing on scan_folios()? While it's not relevant to this patch. Reviewed-by: Baoquan He > > Signed-off-by: Barry Song (Xiaomi) > --- > mm/vmscan.c | 19 +++++++++++++++++-- > 1 file changed, 17 insertions(+), 2 deletions(-) > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 7bd01875fade..2fd82b2ca4d1 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -191,8 +191,20 @@ struct scan_control { > prefetchw(&prev->_field); \ > } \ > } while (0) > +#define prefetchw_next_lru_folio(_folio, _base, _field) \ > + do { \ > + if ((_folio)->lru.next != _base) { \ > + struct folio *next; \ > + \ > + next = list_entry((_folio)->lru.next, \ > + struct folio, lru); \ > + prefetchw(&next->_field); \ > + } \ > + } while (0) > + > #else > #define prefetchw_prev_lru_folio(_folio, _base, _field) do { } while (0) > +#define prefetchw_next_lru_folio(_folio, _base, _field) do { } while (0) > #endif > > /* > @@ -3932,9 +3944,10 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness) > for (zone = 0; zone < MAX_NR_ZONES; zone++) { > struct list_head *head = &lrugen->folios[old_gen][type][zone]; > unsigned long protected[MAX_NR_TIERS] = {}, delta = 0; > + struct list_head *pos = head->next; > > - while (!list_empty(head)) { > - struct folio *folio = lru_to_folio(head); > + while (pos != head) { > + struct folio *folio = list_entry(pos, struct folio, lru); > long nr_pages = folio_nr_pages(folio); > int refs = folio_lru_refs(folio); > bool workingset = folio_test_workingset(folio); > @@ -3945,6 +3958,8 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, int swappiness) > VM_WARN_ON_ONCE_FOLIO(folio_is_file_lru(folio) != type, folio); > VM_WARN_ON_ONCE_FOLIO(folio_zonenum(folio) != zone, folio); > > + prefetchw_next_lru_folio(folio, head, flags); > + pos = pos->next; > new_gen = __folio_inc_gen(folio, old_gen, &gen_increased); > if (gen_increased) { > delta += nr_pages; > -- > 2.34.1 >