From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 26B512F39A7 for ; Tue, 27 Jan 2026 23:29:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769556547; cv=none; b=FHZTmGNGkiSvzzc53mlis4ag5ZufZjdONr+D4n90SOz5C9wv1HcV9hbeY/kLZKAUZ/kyFu8SbhvmzsK7h4uJ32u6t9YmTPouLUllfKbNNXMgNDKLIK0XTXcF36Mb0R3gBVUDkUI49xxuyAjySz5vGvM2/oSVzSv6YdNNd2zLjTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769556547; c=relaxed/simple; bh=ofHckpHSK4mfHbe6L1ZVH+h1/SSvRemGaI9zfgs1u/8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hiPw4ODlGQDcKZbrDvuMNisx2uTDlwA0wzTdgoqElI/KX5V0tYchO8rtrOdWJmmOgkTkD0u5y5nNhqAHoCG3h9OQ1FKrVXKvfScM/LcG85B47p76C0JSpK6DD+6Q5ex94KC3miqRi/fSeL1A6oVUIMc8zjXm1HOtjOMzMfiFKj0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tUC0yXXp; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tUC0yXXp" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2a1462573caso15235ad.0 for ; Tue, 27 Jan 2026 15:29:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769556545; x=1770161345; 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=ggQbKrh8ZyuooMxE9NUhGxSmgLEA7sxK0OqhmRkzBEY=; b=tUC0yXXpIxgzfBlE8DG6JXMNpxu5ZIrjeQFQjue8NDSaJRUDXP1JV1o33Jx0/x3msu m2NTcRtRfxDrw9EyNszm/ju2KJK4gs+LjVd+bWIfXlJOo8zvdcYV6UZkatItmU1C22l3 vcMo1GvMYC0ukHR8TZVN8RvfhJaWwCc03rp8ZzY/x7dtSqftSJuRMb5CxNuIEvcESp7H hKH7J21Dr4k7e63XWAKWdnj+FcbSfRxHjvIj1H+cqzNG0kExRQ+qwq5305oQnppyXhZD g6H0TX4oVXI3zlpcia1lMHedP9cDEQoY43LsMvqkaytxa6w18dz0GxJQg3dzg6KRUI6Y e48A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769556545; x=1770161345; 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=ggQbKrh8ZyuooMxE9NUhGxSmgLEA7sxK0OqhmRkzBEY=; b=sirMXUFgwnXocDwCY68SWfk/Mg7MWxND8MkDzKHZvXL8MOvD9SnJ5QgTAO72CtQ/SB 2c1Z+2hubzqfhuvoMKv6cADSPgqJmQiNAbB35NsO4nQHo13Fl201SBMeBqZYPmB41jaT N6QbRq7xNggRQh01uN4cX3eosB6sEKROiNsc/lrmMYsTKg1pTAAl6odlQRt/KdYI7I55 Q7pNKUlbrbkgeC0wPFTMX9Bv6gDkro8dG5NQmoGmrWNcpPDqyo+2s6gIbDRhowynNNg1 vkoEIJNfq8dXzd4aBiD0UlSCW1uimvZRUmpUbEzNYz94iVcm+3/rl4vvjOP2npR6EowL f8oA== X-Forwarded-Encrypted: i=1; AJvYcCVZuOjo426epGqyH+u5YVVOdcBAZnOa9SYTpj2KYruSvY3u7DiLixOcAto71082LPWGDNp5Z80iA4Biyzc=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8wrXcs8SlVtGo2zHYZbBuO4vEzXa5bGn3X+5BujTMYvyqOIT0 emfPEKGec7vUK4eR20ad5JPNJAqa99lH7/DLjbhV/Zv/72pm09SHetQIt2ZkFOpWSw== X-Gm-Gg: AZuq6aKdJKxOpeXRvfEE3OiX4zJmG4Xqb7eDT6o4pEb1181RkoCF+iuVrqee77ku1m2 C15Z9auIbjupBEJzw/K9Y4NLlrDu4KByTC293B6nyYfGVluIbxlRCg8W4SvY0pbwRJnW/zLhZi6 C+m6hSrQrg9+Lw0xXscQK3tLAVus4ed+s1nbgfokMlWNwuGzge61Sf22rwyigXcWyQyEGW9aR8I 3sGmZKR2XkDzk95TkBBba02R5fCE52zQzwNhuPb2yHO/ppEWrXDwLPgrwqtgqcTczCV4PWax7bg waDu1RFpRi9ZY1III3FK1GQSdLzZza7MGgu1cL5ibHcGN8Zl4U/1kSlv8dqM7y0eqm/dmS+6IbM A4WoYtK7wpG13J6tbwI6mVyCbmd6bjn04YmZEcQrfy8zI1w5iHBgNvbN4HoH82GBM6WsiF71gHk 7ulW7/JupDTDWUS0gJb5iJjf/g9ZqAAtG+rCbmVmaTZzpz4DHdJw== X-Received: by 2002:a17:902:fc4c:b0:2a1:3cdc:771f with SMTP id d9443c01a7336-2a870b97452mr3881485ad.20.1769556545254; Tue, 27 Jan 2026 15:29:05 -0800 (PST) Received: from google.com (130.15.125.34.bc.googleusercontent.com. [34.125.15.130]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a88b417394sm4031265ad.42.2026.01.27.15.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jan 2026 15:29:04 -0800 (PST) Date: Tue, 27 Jan 2026 23:28:59 +0000 From: Bing Jiao To: Gregory Price Cc: Akinobu Mita , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, hannes@cmpxchg.org, david@kernel.org, mhocko@kernel.org, zhengqi.arch@bytedance.com, shakeel.butt@linux.dev, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com Subject: Re: [PATCH v3 3/3] mm/vmscan: don't demote if there is not enough free memory in the lower memory tier Message-ID: References: <20260108101535.50696-1-akinobu.mita@gmail.com> <20260108101535.50696-4-akinobu.mita@gmail.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 Tue, Jan 27, 2026 at 03:24:36PM -0500, Gregory Price wrote: > On Sat, Jan 10, 2026 at 10:55:02PM +0900, Akinobu Mita wrote: > > Since can_reclaim_anon_pages() checks whether there is free space on the swap > > device before checking with can_demote(), I think the negative impact of this > > change will be small. However, since I have not been able to confirm the > > behavior when a swap device is available, I would like to correctly understand > > the impact. > > Something else is going on here > > See demote_folio_list and alloc_demote_folio > > static unsigned int demote_folio_list(struct list_head *demote_folios, > struct pglist_data *pgdat, > struct mem_cgroup *memcg) > { > struct migration_target_control mtc = { > */ > .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) | > __GFP_NOMEMALLOC | GFP_NOWAIT, > }; > } > > static struct folio *alloc_demote_folio(struct folio *src, > unsigned long private) > { > /* Only attempt to demote to the preferred node */ > mtc->nmask = NULL; > mtc->gfp_mask |= __GFP_THISNODE; > dst = alloc_migration_target(src, (unsigned long)mtc); > if (dst) > return dst; > > /* Now attempt to demote to any node in the lower tier */ > mtc->gfp_mask &= ~__GFP_THISNODE; > mtc->nmask = allowed_mask; > return alloc_migration_target(src, (unsigned long)mtc); > } > > > /* > * %__GFP_RECLAIM is shorthand to allow/forbid both direct and kswapd reclaim. > */ > > > You basically shouldn't be hitting any reclaim behavior at all, and if > the target nodes are actually under various watermarks, you should be > getting allocation failures and quick-outs from the demotion logic. Hi, Gregory, hope you are doing well. I observed that during the allocation of a large folio, alloc_migration_target() cleans __GFP_RECLAIM but subsequently applies GFP_TRANSHUGE. Given that GFP_TRANSHUGE includes __GFP_DIRECT_RECLAIM, I am wondering if this triggers a form of reclamation that should be avoided during demotion. struct folio *alloc_migration_target(struct folio *src, unsigned long private) ... if (folio_test_large(src)) { /* * clear __GFP_RECLAIM to make the migration callback * consistent with regular THP allocations. */ gfp_mask &= ~__GFP_RECLAIM; gfp_mask |= GFP_TRANSHUGE; order = folio_order(src); } #define GFP_TRANSHUGE (GFP_TRANSHUGE_LIGHT | __GFP_DIRECT_RECLAIM) Best, Bing