From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (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 2056632BF4B for ; Thu, 16 Jul 2026 12:11:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.97 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784203889; cv=none; b=B2HyXnD7VkC27DNFlpQfM+6v9e7c4uKpsvdQzxJpsxF0wMOH4cLik7ehYGkTb5HP4bGXr918jtgJgxv1JYGr9hVqaFWl+3mnc3awqPk9bsEYJjI/6H03y6LeH3g93nlinL5V7FJ0mj8BKp+3b+P2YVYvSfKnFMx9EXink6LZEXQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784203889; c=relaxed/simple; bh=UM+qnmwEh5yJUGP9F2kPK3BgnLzlT4eq470BwjEf+fk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=mOikmlghPrrb9H4q4alK+MG8ybqSfxoDYxbpdCeyLcwqb+BZ6iBcR1issEQxc9FVn4ETw2VeTviHnkUnGjFOpO8pTOq/5oODtGSNKRW0gqKfWZHU5RhWlOOwL7ypF8uuhgmdBBeAK6bp1jxJj8z/Y201UAdTFjJhrwE7fAyzKDI= 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=xoM//Jwk; arc=none smtp.client-ip=115.124.30.97 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="xoM//Jwk" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1784203877; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=22TDE33CcMaK/6oJLmhRk6PtkOBzLjo6hgniVsSgp+Q=; b=xoM//JwksrfXMsHakxHrGdYRHyOht7GNE4aSAaeo1pHNHMM15qw4Udm4hVyuC/GjZSLjQqIwr/MfDqYwdhapZNEdB4COuP/JEaMvwJ6OTesqUFhS69PWjt6ojwxqOxPqx2hOh8AkqNzyW0oGoFsHTxhiBUfNqfZXd+ATQKp9Bgs= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032089153;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0X7ENwPT_1784203874; Received: from 30.120.38.205(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X7ENwPT_1784203874 cluster:ay36) by smtp.aliyun-inc.com; Thu, 16 Jul 2026 20:11:15 +0800 Message-ID: <358e6938-9505-422c-8765-d8244f4c875f@linux.alibaba.com> Date: Thu, 16 Jul 2026 20:11:13 +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 v2 2/2] mm: mglru: promote mapped executable folios after first usage To: "David Hildenbrand (Arm)" , akpm@linux-foundation.org, ljs@kernel.org, hannes@cmpxchg.org Cc: 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: <7e3a5f6bdf70e0237027025f4593a3874d411f65.1784197559.git.baolin.wang@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/16/26 7:10 PM, David Hildenbrand (Arm) wrote: > On 7/16/26 12:46, 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 >> >> Signed-off-by: Baolin Wang >> --- >> include/linux/mm_inline.h | 6 ++++++ >> mm/vmscan.c | 41 ++++++++++++++++++++++++--------------- >> 2 files changed, 31 insertions(+), 16 deletions(-) >> >> diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h >> index b5c4dc0f3fe3..30fdf1056312 100644 >> --- a/include/linux/mm_inline.h >> +++ b/include/linux/mm_inline.h >> @@ -30,6 +30,12 @@ static inline int folio_is_file_lru(const struct folio *folio) >> return !folio_test_swapbacked(folio); >> } >> >> +static inline bool folio_is_exec_file(const struct folio *folio, >> + const vma_flags_t *vma_flags) >> +{ >> + return vma_flags_test(vma_flags, VMA_EXEC_BIT) && folio_is_file_lru(folio); >> +} > > I don't quite like a generic folio_is* helper to consume vma flags. Whether it > is executable depends on the VMA. When called from a non-exec VMA it would just > give a wrong answer. > > Not sure if something like "is_executable_file_folio()"/"is_exec_file_folio" > would be better, to distinguish from the actualy folio_is* helpers that are > independent of context. OK. 'is_exec_file_folio' sounds better to me. > Also, can this helper just go to vmscan.c? Yes. I originally expected this helper might be used by other callers, but for now it's only used in vmscan.c, so will do. Thanks for taking a look.