From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=57.103.87.62 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795686964; b=B+XZ/TYzBxZltVy4rIVIy2IUYhATWabqAycnmHVAezpZs4T8M18gW1Lc0Luf+QuoGzvW kEGDAE/ap5OcC1iQDe9ZSMdxipgcKNFpjQSRco23ton40Hg/Ub/eTortq/3mjwfF3pcoo g7KmhXIhNcLGmwwiaYzXhbl5hjjBJqz0bDiZbSxhl5LSM3VAblGBqp7k+NYZ7azbzF4Uf CWegtUpN6kGdVeFPS5lCEPahHYleuUmdodmi4EvHHTrgagZwz0TAPDrQYOLlqpT5agN0V uhakdjV7URSXblRkrtXsQNNI3xoaSm+3dLtBz7vKtctC1q4OqUI2M2ukC0SyhWTCdsQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795686964; h=DMARC-Filter:Received:X-ICL-RepId:Dkim-Signature: mail-alias-created-date:Received:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To:X-Proofpoint-Spam-Info: X-Proofpoint-GUID:X-Authority-Info-Out:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-JNJ; bh=rP/jTD2/f1MP5JxdM/crFR5Z+zyVxyrdqDuSKQpH9Go=; b=w0kZ4ZGVCZf/r2OT1AnFSE6KbUYZWVnul1WoMeoKGcXsjHjN+8pjGViBN0jq7MzYUmF3 MfTdZqwMt+wkQN8Wlci/UFibdlaz9Mnv1lGeD0leeU1/j/lY+t9GXdmxRx5Q1Z9JZ5bYs jGbopaN2yblzJneAx99lpPYyyqK3PNCB/GjPK8A6qoAzeFRtTvGTFSqSdLGSmUnhDdjAK UgbbXHbVi0gYUhwZSiDzPz2n56/PR6qyqOkdBO7NMl1Omo8zRh19d8QvxTlflvWQId3Z5 fR+aqxYkU+K91rHXNE91kRsj9Ex92F77um3H2xjbH5j6O5G2fqDBwtLWzJOrZqyHEzg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass header.d=icloud.com header.i=@icloud.com header.a=rsa-sha256 header.s=1a1hai header.b=lUcN61jd; arc=none smtp.remote-ip=57.103.87.62 Received: from outbound.qs.icloud.com (qs-2001f-snip4-10.eps.apple.com [57.103.87.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51A44606A31E for ; Thu, 26 Nov 2026 09:56:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 51A44606A31E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.a=rsa-sha256 header.s=1a1hai header.b=lUcN61jd Received: from outbound.qs.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-2d-60-percent-2 (Postfix) with ESMTPS id 8C526180DB29; Thu, 26 Nov 2026 09:55:57 +0000 (UTC) X-ICL-RepId: 01a21748-818b-7989-9c68-a19eb0b3ff9c Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1795686962; x=1827222962; bh=rP/jTD2/f1MP5JxdM/crFR5Z+zyVxyrdqDuSKQpH9Go=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:x-icloud-hme; b=lUcN61jdofNfL0SjfDGGScuPq7Bt330IQqswppasvD1oSPOeJ/L//CRMqGflyFqsqZ9nBLmB9XbtstGdvGUr2fMqvlageMbC6XegyEEaFyYiG/DOvV1tQBK0Elv7d/5+rYv/8ajHMpT2/xQ8qqu5A6Uf7l50X8e/wAgdgfvFjmYHL8Gt+E7iYhtd1jGBEIH8Q/zQOTUKGbyv0G1YWuXJgv41rjUEp3xjfscnwn/NLJkbHoM0iD5opCX1J7d//hHdE/q/9M4Tm4b9LMeohcnCKqkYSe58gW2biK0ZrsoaJfzoLcBo2PeuNj+RBivz4pVOSLkJUY++uRUQJWNRjMxMQA== mail-alias-created-date: 1772519804199 Received: from lima-default (unknown [17.57.155.37]) by p00-icloudmta-asmtp-us-east-2d-60-percent-2 (Postfix) with ESMTPSA id 54CA4180DB17; Thu, 26 Nov 2026 09:55:51 +0000 (UTC) Date: Thu, 26 Nov 2026 17:55:46 +0800 From: Bingfang Guo To: Barry Song Cc: bingfangguo@tencent.com, Andrew Morton , Johannes Weiner , David Hildenbrand , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , Yu Zhao , linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] mm/mglru: skip oom killing for order != 0 allocs in kswapd Message-ID: References: <20261125-fix-mglru-kswapd-age-v2-1-4cc37437af9b@tencent.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Proofpoint-Spam-Info: AW1haW4tMjYxMTI2MDAzOCBTYWx0ZWRfX6LHtraZbWcF+ abn6R4qKk7vzmQHsHkTOYZOrQIg2mVYmLwmo0rxqdcuCvtrsbSBHbybvZW/77ra2c2ELCnxc2H8 uhnYvSwwOHxyNe+KMkA22Ebdv9+r19I= X-Proofpoint-GUID: FCzsWs0gG87hjATcI8PVbH98kaihm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2jTwB2VyhaUUSxmjMj6GZ6soUgh JP21K2bgxEEj/+qo0hiVK7wJ9qRWkkGXfwAK1nv1pAQqnFH6568aWQQuubmtwHC/pxwgII cR5KTwwnnuaImwEu704nTusv8Ln4YUb4bB9mN446QtH/h3o93Pwk1x1RHaY0lQSCEPXB8b VYAyRQ0XiRSKxU+XjJ7Epw9DX5HodW45JAZbm+IzVuXnf4lBy1tAoaWOKWDEGd2lXzHIkG 3DqzI16LIq3kN2O66hmTFMJbBtNyW1KMQh5ys3wXYg9tqdPI+fjo7VmdEQ5wm0MVGA Hi, Barry! On Thu, Nov 26, 2026 at 08:40:44AM +0800, Barry Song wrote: > On Wed, Nov 25, 2026 at 5:32 PM Bingfang Guo wrote: > [...] > > You are right. Maybe we can start from skipping aging in reclaim path if the > > youngest gen is still too young? And maybe for this path, min_ttl can have a > > default value? Is that a good idea? > > > > diff --git a/mm/vmscan.c b/mm/vmscan.c > > index d891ae46baf49..7f9b14b772d14 100644 > > --- a/mm/vmscan.c > > +++ b/mm/vmscan.c > > @@ -5136,8 +5136,11 @@ static bool should_run_aging(struct lruvec *lruvec, unsigned long max_seq, > > return false; > > > > + /* avoid excessive aging for huge allocations */ > > + if (unlikely(sc->order)) { > > + int gen = lru_gen_from_seq(max_seq); > > + unsigned long birth = READ_ONCE(lruvec->lrugen.timestamps[gen]); > > + return !time_is_before_jiffies(birth + min_ttl); > > + } > > I'm not convinced that we need to couple the aging decision with > min_ttl protection. > > This has been a long-standing problem: high-order allocations can > trigger excessive reclaim and still fail to obtain contiguous > memory. > > I've tried to address this twice, but haven't found a satisfactory > solution yet: > > https://lore.kernel.org/linux-mm/20260422021842.78495-1-baohua@kernel.org/ > > Johannes shared some thoughts on this here: > > https://lore.kernel.org/linux-mm/aejtfpBUu7gNV6Tk@cmpxchg.org/ > > Do you have any traces showing how many pages kswapd scans and > reclaims while kcompactd makes little progress toward satisfying > order-9 allocations? We encountered this problem when running a stability test on a 6G VM with 2 nodes. It populates the system with hwpoisoned pages per 511 pages so order-9 migrations should mostly fail. Then it tries to allocate order-9 pages. So the results might not quite reflect real scenarios, but I think that applies to unmigratable pages such as slab as well. When the system OOMs and kills all the processes, we have about 4.8 GiB memory free and: PGSCAN_KSWAPD : 162,406,932 PGSTEAL_KSWAPD : 91,233,588 COMPACTMIGRATE_SCANNED : 6,542,604,811 (kcompactd: 4,041,105,566, 61.8%) COMPACTFREE_SCANNED : 541,265,798 (kcompactd: 348,448,520, 64.4%) COMPACTISOLATED : 174,688,832 (2.67% of migrated) PGMIGRATE_SUCCESS : 100,824,439 PGMIGRATE_FAIL : 2,022,069 So seems in this case, compaction fail rate is quite high and we have really many scanned pages compared to the actually used size (about 1G). > > Basically, I think we need some form of throttling to prevent > kswapd from freeing more and more memory when there is already > plenty of free memory, yet compaction is making little progress > toward satisfying order-9 allocations. > Yes! And I've read your and Johannes's previous discussions. It also seems weird to me to keep reclaiming even if there are plenty of pages available there. And it's quite tricky to balance between that and concurrency... Looking into shrink path in kswapd, sc->nr_to_reclaim += max(high_wmark_pages(z: zone), SWAP_CLUSTER_MAX); I think this is too much, for this case. So I think maybe we can still reclaim for scalability, but reduce its target. At least we should take reclaimable memory size and free memory size into consideration, and rescale nr_to_reclaim. The check to restore sc->order below can be relaxed as well, if free pages are sufficient. Thanks, Bingfang > > > > /* better to run aging even though eviction is still possible */ > > return evictable_min_seq(min_seq, swappiness) + MIN_NR_GENS == max_seq; > > > > I will give this a test later and share more findings. > > Thanks, > Barry