From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 4DB353F9F50 for ; Fri, 24 Apr 2026 19:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777057555; cv=none; b=c35PMnMOxz9GNVlVdBgWghwvsG87HNWM6Q0IrgjHZitN/N/Xn3qPXk94BhbtGxPfoxEkUnv2FqfN+d/ZcHhaOn1bV6Ppne2BP3RuqdO+y3BEe6L7yMLNna0Ozvf2T9DAmPw60Dye9gGKacOI50wQ4BPqjiFDdNyvHcnNPJ84MpU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777057555; c=relaxed/simple; bh=ZajVb5vHxHCUVLS9iT5/jfGShHk28QiUxJU1kY1L9Yg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R52XO69COx1Vq4H0vSL+kz/LcKPI1DSxtJ0RJIufTX0/Ayr7BdcCK2Xs2wSIoJE2rZSVkW1rGOnxxrVus59L7CJDd9umQU4nM+fxuHeTEZz8zTkuk5puFbAti6tRHhWBza3sXlrO9Odxkt2dAqIBpeBd/PXNi6Y3pzwPSPeG5XI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NFsc+hcq; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NFsc+hcq" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-82f2766905fso3871689b3a.3 for ; Fri, 24 Apr 2026 12:05:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777057554; x=1777662354; 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=+y/frdnpSLgJEoZfNr5r0lhUmPxn2PgdQPDQIjaIR+0=; b=NFsc+hcqJpGafoEorKEh3l5scVCqRITrpdrkdTmcRPZBprOD5Demg1YujwD5ObvPHn 5wFnhZw8Dgd2OcJPrgWKxDVEhvCJbSbtD+SjACUkpFCRHHEFuk1Y/2m2qnSJrJyXN8LE m2z4I2q8g8qEKU9kePa8R2p8t1Ltu56uX/Qr1n2dGLaXkH31jdT1x5BldmLu6cB7Rx3I S68TVN+iDtYJBfPXRAwWOwRh6+8v0N1OpfThaQs043jLVh0irH2Izd7TjEY9pF1oyGT4 2A1zSv5ur9iLm4id+YlSMsdZ5mAy8mcgxw2sHU+nN67EisFEV8HyNjzya8m4dnItNnNa zN6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777057554; x=1777662354; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+y/frdnpSLgJEoZfNr5r0lhUmPxn2PgdQPDQIjaIR+0=; b=W5QSGMBQeZ16rmigz8ydDcYIXwTS+byS4EQq+YGJMVrGzZ3ILTgXSs/t0ILwFBBUH/ KPwR5SpxxCdiMdXMtvrnLxqSHPqh8RoUqp7Jv0MXhdB7GjYp+M95OkT+N9vI52cmaZUL ZWKNe6hm8U4fm1+Qw4Xoo4k4V+V+lFV/bL6IxqW+gVp2CutxaC8osebSm/mD8iUblEs1 b9d09ErXvfXXKgWDhmmarBGGW9Q/pu92RC/LGO+FxDeK4pOrbYXwiXpomCjW7YJtz8em HYmhNqnDSt3QxaR+0IKpRmdn6i0ulqP0o7xeTOex4gqnfkdJUuBJEp04ArhT5Cmsn3pt VyNg== X-Forwarded-Encrypted: i=1; AFNElJ9kXEcudFPT6b641g8z4RBvyIfve2pnXUP8EiH0XKaszXXVQo7ftLT4WHwpoxFgH/5b+4+O2QemgzoGcOs=@vger.kernel.org X-Gm-Message-State: AOJu0YxnuWOLhZGkkh5uGU0jGJg/RhO2lbbr642JyFKhG5bOxAfwCbyO UvT2i+Ue+dlHej+dOqN3GCZTeKnZEtrvFKt69JM6OtPlpxGNaAq/jSUk X-Gm-Gg: AeBDieuXGyFFYwrOjwZljTN7XNDv0SegLBQepyFwGXAL3hnf5ba0ZrFoR6xAfkImsIk bs1oXnihhpm/atNnHM9tdQ4EzbfBlIiUNl7OjTUZKChN9EIVw+G0iKnSJ4r1W163EVD2873L84s aDGVjXJyGCRsM2M3PTokuxdczZ9KQCP3ZTpMStYYQZf0xq4Mk3Sz2Om8T3/vj+OJ3wUK/n3/zMz cVn1Wm3hE5w7RIkcDkAWnTASNdBcCvwjGNQYSEOITM6Kd82fj/sFBR1AWMQklRlai0A4wAZnv6B MqZ+mzK8Te95/ICn3yOmFlhy4qFvOXKmKldtGkQXD0Aw5p+vtni2UApfPU22cr0cp1EDSBglv1w ycNXPosZ+36oMZJB6QQ/HtaXzOTA/WL7iojzl3wxSwfOFq9unAkSYleN2G0n8qwjUHDnTTs9/Z0 yFUWUBXKE1CEEa9WG8b5sdFAfqL/ZY1NvKVmO9P/WciKovhpXdClaALGHrXg/48qNdCrPwC71u+ t+unZtN X-Received: by 2002:a05:6a00:3e16:b0:82f:8332:492d with SMTP id d2e1a72fcca58-82f8c7dcfecmr35092904b3a.2.1777057553343; Fri, 24 Apr 2026 12:05:53 -0700 (PDT) Received: from KASONG-MC4 ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8317076ca48sm6904899b3a.35.2026.04.24.12.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 12:05:52 -0700 (PDT) Date: Sat, 25 Apr 2026 03:05:45 +0800 From: Kairui Song To: linux-mm@kvack.org Cc: kasong@tencent.com, Andrew Morton , Axel Rasmussen , Yuanchu Xie , Wei Xu , Johannes Weiner , David Hildenbrand , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Barry Song , David Stevens , Chen Ridong , Leno Hou , Yafang Shao , Yu Zhao , Zicheng Wang , Kalesh Singh , Suren Baghdasaryan , Chris Li , Vernon Yang , linux-kernel@vger.kernel.org, Qi Zheng , Baolin Wang Subject: Re: [PATCH v6 09/14] mm/mglru: use the common routine for dirty/writeback reactivation Message-ID: References: <20260424-mglru-reclaim-v6-0-a57622d770c3@tencent.com> <20260424-mglru-reclaim-v6-9-a57622d770c3@tencent.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: <20260424-mglru-reclaim-v6-9-a57622d770c3@tencent.com> Forwarding sashiko review (the format doesn't seem right, maybe some sashiko bug): > commit 1f5e2fcf6aa79d5fe07e850245e1292c205ab0fb > Author: Kairui Song > mm/mglru: use the common routine for dirty/writeback reactivation > This commit removes MGLRU-specific handling of dirty and writeback folios, > instead falling back to the classical LRU routine to reactivate them. The > intention is to improve scan efficiency and keep these folios away from the > LRU tail until writeback completes. > > And using the common routine also keeps the folio's referenced bits > > (tier bits), which could improve metrics in the long term. Also no > > more need to clean reclaim bit as the common routine will make use > > of it. > The commit message notes that this approach keeps the folio's referenced > (tier) bits. > When folios are processed by the common routine, they may be marked active > and subsequently returned to MGLRU via move_folios_to_lru() -> > lruvec_add_folio() -> lru_gen_add_folio(). > While lru_gen_add_folio() updates the generation, it does not clear > LRU_REFS_FLAGS. Should the tier bits be explicitly cleared when a folio > moves to a new generation so tier tracking starts fresh? > If stale tier bits are retained across generation movements, could this > artificially inflate access counts and disrupt the eviction algorithm? I don't think that's an issue, writeback folios are moved to tail (oldest gen) once writeback is done. And in real tests this seems actually an improvement. > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index 35e3352a53e3bc..74255efc4ad9dd 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > [ ... ] > > @@ -4628,21 +4627,6 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, struct scan_c > > return true; > > } > > > > - dirty = folio_test_dirty(folio); > > - writeback = folio_test_writeback(folio); > > - if (type == LRU_GEN_FILE && dirty) { > > - sc->nr.file_taken += delta; > > - if (!writeback) > > - sc->nr.unqueued_dirty += delta; > > - } > > - > > - /* waiting for writeback */ > > - if (writeback || (type == LRU_GEN_FILE && dirty)) { > > - gen = folio_inc_gen(lruvec, folio, true); > > - list_move(&folio->lru, &lrugen->folios[gen][type][zone]); > > - return true; > > - } > > - > > return false; > > } > The removed folio_inc_gen() path previously cleared LRU_REFS_FLAGS when > updating the generation. Can the new fallback approach cause regressions in > tier tracking by skipping this clearing step? Same as above, that's not an issue but expected, even an improvement for many cases.