From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (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 A942F1A9F9F for ; Wed, 7 Jan 2026 07:28:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767770915; cv=none; b=l+lLHp22zdVUhMtfwPtBbKBzcZGuN7KwUSkhDFvrDXWGdBppNPxtZvJH+oxJZBf0tajYOxPkYZFpX5qljWmdSjmQHkXz04wGmkh3Dr060CuKgK7aPHKjPD8aQdrtDZIyemu2459GOeRhrVfRzUX7QVBA+DT27Jk0OxCh8e33gGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767770915; c=relaxed/simple; bh=oJ+tZkryLv2yQuLGN/4ADVc0dTBYexdRUOi5Ms0jLS8=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=J/aa1m7crBpyrUwdHL3+ZqGLSiw3UlPPmXvJStOlrAiCgyx9d2lvPWNr1dFAqrryCqsPUl1RRJkUg+D+aOaVhmAl0krkHTMH+JG18FsPALyzdSQhOeUjX2L+gXHGTtfmhKHmxL0WdxgqH90v37yqov6uMJd37q3Ms/MmbbhP48s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--bingjiao.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Z5IyqSPO; arc=none smtp.client-ip=74.125.82.74 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=flex--bingjiao.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Z5IyqSPO" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-11dd10b03d9so1386963c88.0 for ; Tue, 06 Jan 2026 23:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767770913; x=1768375713; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=vdcc16eCk3W6QUfO+1xnmrdGTvoo0vZZZVL5vCZllR4=; b=Z5IyqSPOqNlXJCmDrBrK+76Ssy0n5GIa6uyXMXy5nbpguBZ4+sqOCtnZYEl3/1BmNz GVGMsHgj0/O2L/n4QIEY3sWw07FO511/FL2N+u1TA0Dmk52PCFtr/WHyUteL9EbYtMRK lRif5nnrP6gU4r7n7A2kSmv0tD1oDwXU0CAr8tg2+0+TjAArDu3nKj2/1BXpYgIVQBDZ M6d8JO7gNwom250vjJs1Gl+HCZrxiBHJR7O43TPnuq15FkU8Fr+n/rj7f4ZUitHmyhNu aNe9RiANER462lETmY3mPeo//aMJJHUTf/OycbJHeXnc4MPzLOcn9G3tj5KdgFYaTW1B Evtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767770913; x=1768375713; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vdcc16eCk3W6QUfO+1xnmrdGTvoo0vZZZVL5vCZllR4=; b=iE7abWXZIUui/UZvauqSQYfGOanBHdjn8ZAtOg31QnJKDppSFtRTgLAb6GDjPyQXcf oE2gRaUTyshRHroI3I+TuYV3cRnf+UK9Ei7RP3WG60fjXbd75xj9eJGveZjWofzXsQM3 3o1akB/P9Cgo2FMqhsDF1SqueHCF7iE9sVyLAVe1OIUXO9dYYuQvKsvEu7+CaPATZndb EyX7iKJtZ6du1NsBynOGHqh7rTkJbZ6stKKAMPyYmPOGPIaeE+6B2/1V6m8pjmx1V/Tj Q991dDNjhzS3md3DfYIB9+qXMocfiOi4Z5Hu7dmCy4gwqrumGHUL7EnGrT5rdkNXhaK9 0lNw== X-Forwarded-Encrypted: i=1; AJvYcCVmjM1g6YSDbB05IMgil0fN/q5hNJvmS2k7El+9JdUfik5vye1E7bYuE/HFoqiTZbIp04fDaCfljQ0ZD28=@vger.kernel.org X-Gm-Message-State: AOJu0YxNLjtEBpSlBcyFjHzvV5VPkvevSSLauyULzbAL+v5GTPFcBwHZ UJzFDbpIziHYQyH5RGHD/K3e+LobKiZ7nCRB+MccS/mD/LFZLDZPaDQ7FPTHGtcbCHX3ggFxGJd 48mr8iGeADDQArA== X-Google-Smtp-Source: AGHT+IHR0C5tVYbOki5l0STjGxIf1O+37PMISMcWlWW8Ftb4oXB5Rwcc0Sx4CNNUs/wlltI47lRxtm92zhJq5g== X-Received: from dlber3.prod.google.com ([2002:a05:7022:2643:b0:119:9f33:34a9]) (user=bingjiao job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:428f:b0:119:e56b:98b0 with SMTP id a92af1059eb24-121f8b7957cmr972577c88.23.1767770912626; Tue, 06 Jan 2026 23:28:32 -0800 (PST) Date: Wed, 7 Jan 2026 07:28:12 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.358.g0dd7633a29-goog Message-ID: <20260107072814.2324646-1-bingjiao@google.com> Subject: [PATCH v1 0/2] mm/vmscan: optimize preferred target demotion node selection From: Bing Jiao To: linux-mm@kvack.org Cc: Bing Jiao , Andrew Morton , Johannes Weiner , David Hildenbrand , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Axel Rasmussen , Yuanchu Xie , Wei Xu , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" In tiered memory systems, the demotion aims to move cold folios to the far-tier nodes. To maintain system performance, the demotion target should ideally be the node with the shortest NUMA distance from the source node. However, the current implementation has two suboptimal behaviors: 1. Unbalanced Fallback: When the primary preferred demotion node is full, the allocator falls back to other nodes in a way that often skews toward zones that closer to the primary preferred node rather than distributing the load evenly across fallback nodes. 2. Suboptimal Target Selection: demote_folio_list() randomly select a preferred node from the allowed mask, potentially selecting a very distant node. This series optimizes the selection logic while ensuring balanced allocation across fallback nodes. Patch 1/2 introduces a randomized fallback mechanism in alloc_demote_folio() to prevent allocation hotspots when the preferred node is under memory pressure. Patch 2/2 updates demote_folio_list() to traverse the demotion targets hierarchically, ensuring the perferred target is always the closest available node. Dependencies: 1. Patch 1/2 has no dependencies. 2. Patch 2/2 depends on commit d7138516fb5c ("mm/vmscan: fix demotion targets checks in reclaim/demotion"). Bing Jiao (2): mm/vmscan: balance demotion allocation in alloc_demote_folio() mm/vmscan: select the optimal perferred node in demote_folio_list() mm/vmscan.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) -- 2.52.0.358.g0dd7633a29-goog