From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (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 BD3E978F2B for ; Thu, 16 Jul 2026 04:06:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784174800; cv=none; b=CgsbVzrYG9kkjpLuHE/5gjDGnr07TKhn120GxDsCIHns0PKf0S0QgPDbqesr1Irn2uXgQrKOKz2ehwkmR0AHer5sJeN3j6K6mmd30DIdmr2CuE0S10bH0clBU1pcuJSeyTk2vupl3fM+VhKv5BExfJN2G4CYETxPCbjUhEybohM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784174800; c=relaxed/simple; bh=XFneOqr4QCHqhhgoX54B6QLaeaLkGP1B8byPMueblpM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UfsshHCJYpJfgdMiHC8CZJldE7ib8KbO0J3L/3rTKAz5hkdyaNmoLqx2wRlqxQVsA02CbSxvxzB5l6naKbe3swO0wa71zbqXh4SOXmT5xlPIMFvPyCEYQJym3HQIz4Dcnt5FGrfyvc1xMj0A4c7WWet9Sk7OmNRN9Ek5Nit0kLM= 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=Wm11rdEM; arc=none smtp.client-ip=115.124.30.100 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="Wm11rdEM" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1784174789; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=XSbeUDpDHHji88tGuMMDbVDiWu7Fml1DRo8t/ryPoMc=; b=Wm11rdEMkzuZQedAE4aOdql7QT+1hzVfLkPmH1v+a39Z1hmsLOIk/I+wbjWZgScRaKQ8xSmur7zBp4QBuPFGHC18knMXKyQQ8JSOA7knHUqnlPtqKIfCPkTm3JX3LH9Tw9JTBdUHz9wfBBkkU4JFNuvnd9OlVJR+e0XiJI+yQbY= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045133197;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0X7BPo9o_1784174788; Received: from 30.74.144.123(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X7BPo9o_1784174788 cluster:ay36) by smtp.aliyun-inc.com; Thu, 16 Jul 2026 12:06:28 +0800 Message-ID: <201cee07-b4dc-4ee1-9d48-c01cb1c44a33@linux.alibaba.com> Date: Thu, 16 Jul 2026 12:06:27 +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: Andrew Morton Cc: Barry Song , 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> <0fdd8922-3087-4636-aa5d-27074462fa6d@linux.alibaba.com> <20260715124442.6002198725f60b2ffece2d97@linux-foundation.org> From: Baolin Wang In-Reply-To: <20260715124442.6002198725f60b2ffece2d97@linux-foundation.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/16/26 3:44 AM, Andrew Morton wrote: > On Wed, 15 Jul 2026 17:00:19 +0800 Baolin Wang wrote: > >> I did a quick test with the same test case on my x86 machine, and I >> still see an improvement in sys time. >> >> base patched >> 1152.249s 993.235s > > Nice. Sashiko asked a thing: > https://sashiko.dev/#/patchset/4b921ed528c483e13c9e22d1ae44ba58b4a15b0b.1784096432.git.baolin.wang@linux.alibaba.com Thanks. Forward Sashiko's comments: " This is a pre-existing issue, but does this miss promoting mapped executable file folios during direct reclaim? ...... This means current->reclaim_state->mm_walk is NULL. When shrink_folio_list() calls folio_referenced(), it invokes lru_gen_look_around() which calls walk_update_folio() with a NULL walk. Since walk is NULL, we fall back to lru_gen_set_refs() here, which bypasses the newly patched folio_update_gen(): mm/vmscan.c:lru_gen_set_refs() { if (!folio_test_referenced(folio) && !folio_test_workingset(folio)) { set_mask_bits(&folio->flags.f, LRU_REFS_MASK, BIT(PG_referenced)); return false; } ... } Because lru_gen_set_refs() lacks the new VMA_EXEC_BIT promotion logic, it merely sets PG_referenced without updating the folio's generation. When those adjacent folios are subsequently isolated by shrink_folio_list(), their PTE young bits have already been cleared, causing folio_check_references() to return FOLIOREF_RECLAIM and evict them. Will we need a similar fix for lru_gen_set_refs() to handle direct reclaim paths? " During aging, MGLRU always sets up a valid mm_walk to walk the page table access flags in try_to_inc_max_seq(). When aging is not needed, it is indeed possible to fall into lru_gen_set_refs() and miss promoting mapped exec folios after first usage. Although I think the impact is limited, because after the current patch, accessed mapped exec folios rarely get a chance to enter the eviction path. Anyway, I'll add promotion logic for lru_gen_set_refs().