From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-99.freemail.mail.aliyun.com (out30-99.freemail.mail.aliyun.com [115.124.30.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E0D419ADA4 for ; Fri, 17 Jul 2026 12:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.99 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784293120; cv=none; b=W1cc2lCUnUC4dmXTCkHfAKUqNzvV8jgMWDM9pLasccJrN48G9VIh5RqHi8VDRxAyuvpgQ1ZHoZFoDFgIaZVvP00SpvqsRXVZIXwncXL1ILlkxa+6DS71m06hB/Hilo6JckO70HPJ/ZxV6dSPT/IIpzgjEscb7GduKvYBo89FeC0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784293120; c=relaxed/simple; bh=DT+eElkcKlW79KGI2gAiYFjeINU3UYY/YGXikg2B21g=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sKvNb4rKsg4nHqV2cQUIdEOV0LNZQSyk8EjowrtqCKDTh0oDfjdNDiol+VKerfjqL2q8RfTPYafxC/rno0P+yuWgGZWACBmsi5o3w2BRyUFyU/H+FVGjqJxNtUrgkCSaHDZWwVRv6xJ9j8DHMREHhs1CZ478B/kzgRBr3Qq0Qhs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=hLkax/xY; arc=none smtp.client-ip=115.124.30.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="hLkax/xY" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1784293113; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=Vl2opDxTawVfRb7omtrrnxcmfq1PYXs/79M2DZppbtE=; b=hLkax/xYqvtt6yGwui7unayD+4BdFVi7IyF7VBjEaMHggGhHj6GVMN/6VVclbdIy/qEBskrB4b0O+wvOiPhZ3ghXTC7jyEF8ym0ffnHOPhB2MCsA+KZXjnN+Y6qgF/Gr0RjAoVFN2sRTFaOZay/bGFJ7Gx+c9U8iW9neOy4eZRE= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam011083073210;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0X7HRfwE_1784293110; Received: from 30.120.38.205(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X7HRfwE_1784293110 cluster:ay36) by smtp.aliyun-inc.com; Fri, 17 Jul 2026 20:58:31 +0800 Message-ID: <704bbe81-a0d9-4ba6-9d3e-82efd7db4294@linux.alibaba.com> Date: Fri, 17 Jul 2026 20:58:30 +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/2] mm: mglru: promote mapped executable folios after first usage To: Johannes Weiner Cc: akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, riel@surriel.com, liam@infradead.org, vbabka@kernel.org, harry@kernel.org, jannh@google.com, lance.yang@linux.dev, kasong@tencent.com, qi.zheng@linux.dev, shakeel.butt@linux.dev, baohua@kernel.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, mhocko@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <7db4d1975cf04e3e48157f98bdf398565ee189a4.1784268206.git.baolin.wang@linux.alibaba.com> <20260717124403.GG6843@cmpxchg.org> From: Baolin Wang In-Reply-To: <20260717124403.GG6843@cmpxchg.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/17/26 8:44 PM, Johannes Weiner wrote: > On Fri, Jul 17, 2026 at 06:05:34PM +0800, Baolin Wang wrote: >> Classical LRU protects mapped executable file folios through commit >> 8cab4754d24a0 ("vmscan: make mapped executable pages the first class >> citizen") and commit c909e99364c8 ("vmscan: activate executable pages >> after first usage"), giving executable code a better chance to stay in >> memory, avoiding IO thrashing and improving workload performance. >> >> However, MGLRU's protection of mapped executable file folios is less >> reliable. Although shrink_folio_list() checks references, the access flag >> of mapped executable file folios may have already been checked and >> cleared by lru_gen_look_around() or walk_mm(). Additionally, >> folio_update_gen() or lru_gen_set_refs() only sets the 'PG_referenced' >> flag for mapped executable file folios, which causes shrink_folio_list() >> to ignore the first usage of these mapped executable file folios and >> reclaim them easily. >> >> Follow the classical LRU's logic, promoting mapped executable file folios >> after their first usage in folio_update_gen() and lru_gen_set_refs(), >> giving executable code a better chance to stay in memory. >> >> On my 32-core Arm machine, with the memcg limit set to 2G, running >> 'make -j32' to build kernel showed some improvement in sys time. >> >> base patched >> 9248.543s 7861.579s >> >> While we are at it, introduce a new helper to check mapped executable >> file folios. >> >> Signed-off-by: Baolin Wang > > Both patches contained herein look good: > > Acked-by: Johannes Weiner > Acked-by: Johannes Weiner Thanks for reviewing. > [ Sorry ;-) Please don't mix refactoring work with functional > changes. It's difficult to look through a sequence of diff hunks > with more than one review narrative interleaved. ] Ha, sure. Sorry for mixing in a helper replacement. I'll split it out into a separate patch next time. :)