From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67A222C11FE for ; Mon, 11 May 2026 14:27:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778509674; cv=none; b=Yxy3yimDzDhKgSX4UdO2GcF92ysv6iXAfrrLD3D/P8LPpq50ClGEKjpKTNbPywehSk22HZm+NZ4AlIjfspBdPKa19wFvUlwYWoRDStspji90N54iVJ4t2xHyPyD3fIaoSmY42jXjpasO7zNSoqLQiLA7xDrO+gVCBJ6optbLVeY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778509674; c=relaxed/simple; bh=mR1N8h15WwMb3XsZt3bFfjYRoYF9WUIzweoxu88Vexk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GsW4g929HO+4clNplaB+MbjQ+KhuWmQHHiorU5IOiLCiXmAyYR08Pl34bvotzFc7UMCf/uf54qOM/RYDx1PKk662GJIAqI99dMRhU3+XS7EIgna6MxCYIYHl2F2DIWvC2O0O5+XwZGnY5YVkL9DAHI2DQtBEwW3az0f088HQwkA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=FdowHraG; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="FdowHraG" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-50fae4d1f85so51755951cf.3 for ; Mon, 11 May 2026 07:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1778509671; x=1779114471; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=R/9AQUhUatyLnDe5uIdhOnIgduBxT6hJS5BrKvyhjsk=; b=FdowHraG+UhkB1mcJkn9ernzRkiYZ3lVb8Wp1cfBH2jkOzVMk902ouwejg6gO+ziWf zoZ6sDA1S9TWc1ETOmCK+FLMlAH1vxvDVoSmldlnxYrJt6O3IhyX+c9sNdNfXNo+LWd2 bYnzYzObNml9Zw2II5/Yo1bQDVN/7dhYhKYu8yZ6wli52fEplxf0OJK0uI4jiTzr3HR9 Vcut4S3RePLU0tynGKfuP/cUlHHyyGCZjuZEeVH0JEnmQRYnmH/V+E/vpStjKXctXGp+ UIE8xJyXX+N0MlQFekjZFPnGXIy0PSkszR5Xq37Y+beC01h/MOQfKXjNY/HbXvWX82Z0 iwNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778509671; x=1779114471; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R/9AQUhUatyLnDe5uIdhOnIgduBxT6hJS5BrKvyhjsk=; b=US1XHepmjjWwDtAq5Ff3PpN73BwSJ8gxHNi5xhcqzV2WpAfqj8DmREgDwUVQOu0zuf 1JTvhmJgMEIa21kGgqrMNb37Js5aFfqs6f5Ib81QW2b8iUbMUK2QsboXcCQny1Je8LlD u4tQN7lqGUUCf68v+cEoPRKJg+LsCcaHE739Krh9rr11qfbpFh84euxUbx1dAIZG2Uy4 nXrPKZd7eXn11v+kqsxfVzVa8wQDsGsBPIcUeXmrWojLdoxl6KQbabMvQgxN76ADBNns I34/7Txi45ghqUvJPSMv3++khnpkX00wNQYaTA/6AzrhLuJNcGcHTRmEMPFOkDbWocPO ILCw== X-Forwarded-Encrypted: i=1; AFNElJ/LoWoHoLafrlLYewMabLOG63BRygnnPRjmcRqb52mKleKpP946Zem6WkWb6EfI8Wb0eHnDCZ1CKzyzxgk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx72jLkrliVfCBdoxJ8hJAT2PaN/fPKszQgdo0pT+b/AxVaN9lm s4g2nBmzN9gB3WieNL72G3o4T+hSU6P9x05mlQtDV7Xzep2CA4d2Qcev8KVGvo8oTBk= X-Gm-Gg: Acq92OG+icdD4m1Nvt8foF1qb2Imt6BkouD/8TliMajT87rvJ4csrXowRDTDvF8D3Dy CYe9LUpBMSXoKdjw3rLnfAg+zp9svr3kRJ7+iOgiZjKX7H9+oyBMLyvHgVtvj4Rzh9mhJB9OQpO 3RySRyHjz20rvh25BLMr7nC5f9Bn9Zg99bqeNBEAghax1W0ruKEm0JkYvx4tuuyf99SPY0t+Ko/ 6Q4vtAjOu/9VkECwb8DOCsaK/PWiMI9Lm8o5F010WVoOO/MHhH6ifxlbAJI1cn40hXGO2o2Ajps p1XmXRsAx4k7eKW/M5nSZ8GKX+ZvOG3oIi+7vPuNI5vjjZTYgr2+WK0HFVHBcIKPG3VULqKUV+1 abkGIQLkiwc18XVgYuwQLFqB1sQwjfJghVjr8/jiSHP0DGYDfn7CWU9F5UYUbAlGNAOHZ/7R58D 7nEdoF4R5ypPcMgQ5XndONUsV/MkAI3vnUvHPy8UUpphwmGeBEDE/p56vuJUEefA+oxHQBjQVb6 KFoWp6ohNqQ X-Received: by 2002:a05:622a:1907:b0:50d:af3a:d8ed with SMTP id d75a77b69052e-51461fcd2dcmr347757881cf.41.1778509671015; Mon, 11 May 2026 07:27:51 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F (pool-100-36-248-188.washdc.fios.verizon.net. [100.36.248.188]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5148e82579fsm89645911cf.24.2026.05.11.07.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 07:27:50 -0700 (PDT) Date: Mon, 11 May 2026 10:27:46 -0400 From: Gregory Price To: Bharata B Rao Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jonathan.Cameron@huawei.com, dave.hansen@intel.com, mgorman@techsingularity.net, mingo@redhat.com, peterz@infradead.org, raghavendra.kt@amd.com, riel@surriel.com, rientjes@google.com, sj@kernel.org, weixugc@google.com, ying.huang@linux.alibaba.com, ziy@nvidia.com, dave@stgolabs.net, nifan.cxl@gmail.com, xuezhengchu@huawei.com, yiannis@zptcorp.com, akpm@linux-foundation.org, david@kernel.org, byungchul@sk.com, kinseyho@google.com, joshua.hahnjy@gmail.com, yuanchu@google.com, balbirs@nvidia.com, alok.rathore@samsung.com, shivankg@amd.com, donettom@linux.ibm.com Subject: Re: [PATCH v7 0/7] mm: Hot page tracking and promotion infrastructure Message-ID: References: <20260504060924.344313-1-bharata@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Mon, May 11, 2026 at 03:32:20PM +0530, Bharata B Rao wrote: > > > On 06-May-26 8:52 PM, Gregory Price wrote: > > On Mon, May 04, 2026 at 09:36:05PM +0100, Matthew Wilcox wrote: > >> On Mon, May 04, 2026 at 11:39:17AM +0530, Bharata B Rao wrote: > >>> This is v7 of pghot, a hot-page tracking and promotion subsystem. The > >> > >> I continue to think we should not do this. > > > > My only pushback on the general "we should not do this" is that we need > > something to counter-balance the demotion bit in vmscan.c, and the > > current implementation (prot_none faults) is rather :[ > > So you are saying pghot subsystem currently does hot page detection and > promotion only, which is fine. But the current implementation of demotion is not > very optimal and hence we should spend effort in fine-tuning demotion first? > I'm saying because of demotion and fallbacks, we need a mechanism to handle promotions. I'm not convinced a hotness will extend to coldness - at least any better than LRU/MGLRU. > In this series itself I have shown via benchmark numbers that for over-committed > cases (involving both demotion and promotion), the workload isn't really showing > real benefit due to demotion and promotion. Are you specifically referring to > this problem? > If over-committed means over-subscribed hot-tier (more hot memory than available top tier memory), then yeah that result is intuitive. I haven't pointed to any specific issue, as of yet, still taking time to consider some of the results. > > Can you provide more context about the LRU inversion problem? > I've been tracking some data around shrink_folio_list and alloc_migrate_folio behavior when a low tier node is full. The result is we end up just swapping memory from high tier straight to swap and skip demotion, resulting in a bunch of file and anon refaults. Hardware: Single Socket, 768GB DRAM, 256GB CXL Expander In this workload, we see swap usage after the full 1TB of memory is utilized, and as a result we see swap spillage. second_chance = second alloc attempt in alloc_migrate_folio succeeds swap_fallback = second chance fails, we swap directly from top tier Sample data: pgdemote_kswapd 333052779 pgdemote_direct 3181480482 pgdemote_second_chance 31017629 pgdemote_swap_fallback 335759535 workingset_refault_anon 30106868 workingset_refault_file 2343035341 (note here: swap fallback is number of occurances, while the others are number of pages. As a result, the actual number of swapped pages is likely much closer to the pgdemote_direct number) As a result: LRU is just broken on CXL systems, LRU inverts by design. In a sane world we would just see the second tier as an extention of the LRU, but that doesn't necessarily mean we can gleen hotness data from it (it's still largely a coldness tracking mechanism). I have patches I haven't RFC'd yet that try to address this, but I need more time to test it. I don't think this is something to address with PGHot. --- diff --git a/mm/vmscan.c b/mm/vmscan.c index 112983b42559..ccdd698c5937 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1043,7 +1043,10 @@ struct folio *alloc_migrate_folio(struct folio *src, unsigned long private) mtc->gfp_mask &= ~__GFP_THISNODE; mtc->nmask = allowed_mask; - return alloc_migration_target(src, (unsigned long)mtc); + dst = alloc_migration_target(src, (unsigned long)mtc); + if (dst) + count_vm_events(PGDEMOTE_SECOND_CHANCE, folio_nr_pages(src)); + return dst; } /* @@ -1616,6 +1619,8 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, /* Folios that could not be demoted are still in @demote_folios */ if (!list_empty(&demote_folios)) { /* Folios which weren't demoted go back on @folio_list */ + if (!sc->proactive) + count_vm_event(PGDEMOTE_SWAP_FALLBACK); list_splice_init(&demote_folios, folio_list); /*