From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 7585341930D for ; Mon, 24 Aug 2026 12:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787574611; cv=none; b=QAEAlkwFsq0ORhnrlRpfS/02L1i8N1rG14NXuqbPygJOsLt6JfRhuP3+uWUueWz2iSvGKHFDMJyj9L1/tmpq/fofjqpULjmPmsdZJWmUDzZn+SoPjZhxGDZpgnBBN4NxsbuZUlMiNJtvjNvNWnAzxswyzycs6/Ld5G8OWhfR2go= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787574611; c=relaxed/simple; bh=9avveLcrKkhK1W9rSYKP8umKyTKseZySIkXYM3VP2/g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BBTp9lRBdpPhFqFaPx0AAz+bgH8nZwZ8inFt/ebs/iaQAp6yrgXkAJvzvsifUyeZVvEzjhmUWSQ7HgS8K328FeMVfIsnrebF4iwuPtKot55F5Y7ml+XARApi8Ief9PbMLUb+vyb5fHUsQ8tgfiMQxwe/EA2YiRP1Tb/tMge+0Ek= 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=FMAtwmUh; arc=none smtp.client-ip=209.85.221.54 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="FMAtwmUh" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-471eeac43bfso2706444f8f.3 for ; Mon, 24 Aug 2026 05:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787574606; x=1788179406; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=PUk7KPHfvUyw9pUIUwd/E+D8sEbupQa09omQcDsDz3o=; b=FMAtwmUhSEDMxJShEkhx1hFBibflKnjtqMFzgZaAbZqR1q0+OFu6xS9qASpydQpQjb C8wiDorVQjObJqHHTF2ltkONPAOdXsqZ5sy01LX6CqZrVJ//sLxVh+zSs+FvWU1k0Pz3 DLdczUVj+WMsePjttdwEcYSwfDWaJg3MScklyj3ZIDbNUGXz9bF1kip6OJV7WGK5rJ11 Cqd8PZbS+toJzjYWP6xpHIAHWnHdp55c+X6pIhNUaVpgjz6ExqmYiUJ9DsuAfPmRWLZS wCKtJorBzjz+biqDv7cwIKxem8jO72jyvR/l3WGsCzZCEHs41jhUwOe6fWkjsab2sywn GZ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787574606; x=1788179406; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=PUk7KPHfvUyw9pUIUwd/E+D8sEbupQa09omQcDsDz3o=; b=NCno1alJoNfnJAcMjMhTkOUStPz+DwOBFkFtIWrMUgaEfMw+AE+k5kw43GphaxpXgf OuL4HK8508IcTnKfDz8hk2g9d+aVRmboZDf7FcVpk9wInCH3zZlWqJ/tRZ/TSZqmtfdl rWJojOXGH2h2XXVNfcjauS+FCDq8e/3ZhWrAElceOjnLvs/LLKaNExsoN2Mv30oCCWNt ngIZg4dtVp5U46PoJttbNZ+ES4KN9NE2S7Lzhf62BjH6TwYvxm4N5Rm4onxui3myS7zH B21BTuLMlL2UJskkiAJW+KyWsqa7lhJz+E0f6Q4b+92yKJxslTnErTY/2okAWYaxx4Oy 8PYg== X-Forwarded-Encrypted: i=1; AHgh+Rq403QkXNsCoQp8dESxEN4sug9gQ3dne8/KrKOjqkvLV04u2sOO0o8ZceCWZLiNXGxpwO65i9l8X+WVc8s=@vger.kernel.org X-Gm-Message-State: AFuF++lNeu+yX+2W+/RxD2D4/Z0pnNUvozMsKI8NqzPPl0br1ZM1fHHG xYo78bZ2STnzSr+mjy5Jf9mTgB28HDHKArCp8X7lgfDhcJkUeijqSgjb X-Gm-Gg: AR+sD11xfFTTYsc2BFyTwTF9pBPKCajwe4gvqnEhrzpjlFDQWvTFVovSr7p/nuzUsva kvYMqECK5WJ6W8c1+p93aqptp29YUSSzvuuu9Jfn5QiLNxxVSUjjoFAeg5sS7XXRIu9MnuBI1uV z7kOQ065pPX2xiNn/KPj86saqAkpuR2piEsN5UT5tnkxw8Eld+jsCeLUmG+Ji7mAYwqCkkU9tgj NkEdkVV+lvtVQoZfCE0YgyChrfKYUz5r5xgl/XyUelkREOso687yPnWvI+q2jUv9wJqXUd9Jiaa iFp142GB4g0hGn8JA8ON1bpURxMfOKs1M9W4RvyDe0nQeXCUhPGQcOItEQ40LVQVls5t8AX8sjz JLpZOvc9aCuy6rwVwMJkUd0Sg3WSk9wt5njHimxU34/IYc07vwCa6jbzYTjEGmaVSYUa09z+s8N Di2GCpcuHu8IAIuRYHGMRrjIE9upFCb6Yh3cUmZHDnWFKmCJAC9o3UD9cfxGDBtoeq3o5oe7H4b ACwCYWLTq/9eCFChNeZ1KX+ X-Received: by 2002:a05:6000:2383:b0:475:3a97:8e2c with SMTP id ffacd0b85a97d-482c81c0377mr18786975f8f.16.1787574582551; Mon, 24 Aug 2026 05:29:42 -0700 (PDT) Received: from KASONG-MC4 ([101.32.222.185]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-482c9c086fbsm7997186f8f.26.2026.08.24.05.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 05:29:41 -0700 (PDT) Date: Mon, 24 Aug 2026 20:29:29 +0800 From: Kairui Song To: "David Hildenbrand (Arm)" Cc: kasong@tencent.com, linux-mm@kvack.org, Andrew Morton , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Shakeel Butt , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Chris Li , Baolin Wang , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Yu Zhao , Zi Yan , Qi Zheng , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/7] mm/migrate: copy the referenced state via folio_migrate_refs() Message-ID: References: <20260818-mglru-flags-cleanup-v1-0-8dbbdac0d28c@tencent.com> <20260818-mglru-flags-cleanup-v1-3-8dbbdac0d28c@tencent.com> <51b025a4-7da8-4b50-9ba3-1c25eaee7b04@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: <51b025a4-7da8-4b50-9ba3-1c25eaee7b04@kernel.org> On Thu, Aug 20, 2026 at 08:20:34PM +0800, David Hildenbrand (Arm) wrote: > On 8/18/26 07:38, Kairui Song via B4 Relay wrote: > > From: Kairui Song > > > > folio_migrate_flags() copies PG_referenced separately, while > > folio_migrate_refs() copies the rest of the reference state. Make > > folio_migrate_refs() copy the complete state, i.e., PG_referenced plus > > the MGLRU refs counter, in both LRU implementations, and drop the > > open-coded copy so the reference state is transferred in one place. > > > > Signed-off-by: Kairui Song > > --- > > include/linux/mm_inline.h | 16 +++++++++++++--- > > mm/migrate.c | 4 ++-- > > 2 files changed, 15 insertions(+), 5 deletions(-) > > > > diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h > > index 93bf3fa221f8..df62daaa2ee7 100644 > > --- a/include/linux/mm_inline.h > > +++ b/include/linux/mm_inline.h > > @@ -366,11 +366,19 @@ static inline bool lru_gen_del_folio(struct lruvec *lruvec, struct folio *folio, > > return true; > > } > > > > +/** > > + * folio_migrate_refs - copy the reference state to a new folio > > + * @new: the destination folio > > + * @old: the source folio > > + * > > Man, that function has a confusing name (refs vs. ref_count). :) > > "ref_state" would be clearer (just what the description says). > > Or better, "folio_migrate_lru_refs", because that's literally the name of the > function you use: folio_set_lru_refs. > > Can we have a cleanup patch to name that consistently? Sure, I think I can just rename it here as the code gets consolidated and kdoc being added