From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-134.mta1.migadu.com [95.215.58.134]) (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 926803E5A0C for ; Wed, 26 Aug 2026 10:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787741326; cv=none; b=sBmcym/MejFZsSTuO0SXEzoE+Syxcbim2/xyW6wQbBiCbjqr30fCXQT+cQGGm38TfFhSsM6ZGAsQjrCHZ3dThZBim8R1MqbyZ2MYTV+SDh7vEINWaFRzsNeCKAC+Tddn9M4zpt+I7y1ma6EMf5QBhNM4YZRh5A/pjfB/420Mhwg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787741326; c=relaxed/simple; bh=OWFpLa2hlcedUTd6dCHWJ++O5mBHb6pDvO1c2wDCw8Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MsRhtaAZIN/YpuUn7hw++ymmf7XMPRtGb6Q8iOFRSDoBOfr9BY3XGl145e45/vTzxTNUvFbgXzCQOprb9ch5mIqi0M9m+HFJoGJDvWS9L9Xq9dpynr7aTaReb876Q1/RsGoWzFhRO9XOec3XCms1mzyO9hR2wjhePg+Jsq5iIRU= 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=FvC0xlWI; arc=none smtp.client-ip=95.215.58.134 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="FvC0xlWI" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=OWFpLa2hlcedUTd6dCHWJ++O5mBHb6pDvO1c2wDCw8Q=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1787741304; v=1; x=1788346104; b=FvC0xlWIGLcIgTNq4B3Oxl0DK5lhkedsbNye7z2kKr8bJ6HD4KZUPyJS+QJAtb88CIhcBCf1 vImV54atef34do9Ae38R2vRpYrI4W2qO7viN0ktHll0b0pVvXwMhNe/upj+TFN14ILL2cDYsfeG +BqlsjAUdBHLhn17yCNFVuXw= X-Envelope-To: linux-kernel@vger.kernel.org Received: from [10.254.116.35] (101.126.56.83) by smtp.migadu.com with ESMTPS id 19486a93eca802f7; Wed, 26 Aug 2026 10:48:24 +0000 X-Mizu-Trace-ID: 19486a93eca802f7 X-Migadu-Flow: FLOW_OUT Message-ID: <49526857-62f4-45e3-9d8c-40d22586abdd@linux.dev> Date: Wed, 26 Aug 2026 18:48:14 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/6] mm/mglru: introduce helpers for manipulating gen and refs flags To: kasong@tencent.com, linux-mm@kvack.org Cc: 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 , Ridong Chen , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Yu Zhao , Zi Yan , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Kairui Song References: <20260826-mglru-flags-cleanup-v3-0-d9f1c75549c8@tencent.com> <20260826-mglru-flags-cleanup-v3-2-d9f1c75549c8@tencent.com> From: Qi Zheng In-Reply-To: <20260826-mglru-flags-cleanup-v3-2-d9f1c75549c8@tencent.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Kairui, On 8/26/26 1:53 AM, Kairui Song via B4 Relay wrote: > From: Kairui Song > > Instead of doing bit ops on folio->flags.f, introduce helpers for > adjusting a folio's refs and generation info, making the code easier > to debug and understand. > > No functional change is intended: some combined atomic operations are > split into two, which only creates harmless transient states. There is > no measurable performance impact, and some paths even look slightly > better in the generated assembly. > > Signed-off-by: Kairui Song > --- > include/linux/mm_inline.h | 76 ++++++++++++++++++++++++++++++++++++++++++----- > include/linux/mmzone.h | 1 + > mm/folio.c | 19 +++++++----- > mm/vmscan.c | 61 ++++++++++++++++++++----------------- > 4 files changed, 114 insertions(+), 43 deletions(-) > > diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h > index 621c8653d8f7..edfaf2661812 100644 > --- a/include/linux/mm_inline.h > +++ b/include/linux/mm_inline.h > @@ -142,10 +142,42 @@ static inline int lru_tier_from_refs(int refs, bool workingset) > return workingset ? MAX_NR_TIERS - 1 : order_base_2(refs); > } > > -static inline int folio_lru_refs(const struct folio *folio) > +/** > + * lru_gen_from_flags - Return the LRU generation number from folio flags. > + * @flags: folio flags > + * > + * Returns: A number between 0 and (MAX_NR_GENS - 1), inclusive. Returns > + * -1 if the flags indicate the folio is off the list (e.g., isolated). > + */ > +static inline int lru_gen_from_flags(unsigned long flags) > +{ > + int gen = ((flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF); > + > + BUILD_BUG_ON(LRU_GEN_MASK & LRU_REFS_MASK); It seems a bit weird to have this build warning inside this function, but after I tried using static_assert() and failed, I think I understand why you put it here. Besides that, LGTM, so: Acked-by: Qi Zheng Thanks, Qi