From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (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 389C5312815 for ; Wed, 15 Jul 2026 06:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.118 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784098705; cv=none; b=QyXXNHeTds9tBG3zARfdn67apm4fSe/8KP+b2zkX+kmfOfvaXw7T1JYnX690zR9Q+JTFddcwNrn4streK9E4FOLtGpWGeTB4YkpoQ+Mj7XEl71fYY2W5/j+wKhUSa/7KU5X9rN/P+2MIWQsDsO648Sy+i6+7YRj0VkZhEnwTmlM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784098705; c=relaxed/simple; bh=zTaraScYt3nyYmeio9LX7gywQyr4Lf/ZKZ1NO0I5Yhs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hICdqMX6s1CWbQSne47sIIB2+am92hk3MQ/eZ4fTqcPsLdDrA+b4Ybt1NOwYu22Y+CDRCLQKZYncQCpMR/evv3vwz2pUkywu4honEN6GBke3FaLuMAjC8nOWtRpHkbbYKzTcASKdtagzRW6s7tQ4zfMzMGOc6BpniLZFEVbebJg= 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=mXjb4qL5; arc=none smtp.client-ip=115.124.30.118 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="mXjb4qL5" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1784098692; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=W7iA7Abq88NzO2gqEz24+99ykgJHehn+TTeWHBeNLhw=; b=mXjb4qL5ks8rI7tO8LSB50mgnS0Zu1noyjZfkdQS7/3WLbv2uTKiqa3AqSGxt06YAolONTQuQ6B3RvLRUb8mN0ydyr69D12jRHV6ZbCClsuLr5JRpSP/GPSYzzaIQyQQYtASA+GWsOBip8Vh6Epfj/zYlgVLsrYIXkAmI47Lg3g= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R521e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0X78ACtB_1784098690; Received: from 30.74.144.123(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X78ACtB_1784098690 cluster:ay36) by smtp.aliyun-inc.com; Wed, 15 Jul 2026 14:58:11 +0800 Message-ID: Date: Wed, 15 Jul 2026 14:58:10 +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] mm: mglru: promote mapped executable folios after first usage To: Barry Song Cc: akpm@linux-foundation.org, kasong@tencent.com, qi.zheng@linux.dev, shakeel.butt@linux.dev, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, david@kernel.org, mhocko@kernel.org, ljs@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <4b921ed528c483e13c9e22d1ae44ba58b4a15b0b.1784096432.git.baolin.wang@linux.alibaba.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 7/15/26 2:52 PM, Barry Song wrote: > On Wed, Jul 15, 2026 at 2:33 PM 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() 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. >> >> Follow the classical LRU's logic, promoting mapped executable file folios >> after their first usage in folio_update_gen(), 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. > > Hi Baolin, > > Because ARM doesn't set the surrounding PTEs to young, while x86 > may behave differently and mark the surrounding PTEs as young as > well. Could we also collect the data on x86? > > void set_pte_range(struct vm_fault *vmf, struct folio *folio, > struct page *page, unsigned int nr, unsigned long addr) > { > ... > > if (prefault && arch_wants_old_prefaulted_pte()) > entry = pte_mkold(entry); > else > entry = pte_sw_mkyoung(entry); Sure. But I don't think it's very relevant to this point. MGLRU doesn't protect normally accessed mmaped exec file folios well enough. Anyway, I'll test it on x86.