From nobody Sun Feb 8 12:37:02 2026 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (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 847F237BE7E for ; Tue, 13 Jan 2026 08:15:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768292131; cv=none; b=Y/b1HYb87pscIDleMrUoFRaSwerh5nJKLuoX7Cg2A4c8xXDUK+hSSVbBcaoyBIKDFEh/DbtjiUmQ5R8Rdn0Jv5D2Y6/UpySS8Lp1xHpEoW/El3UVlUNncBQNbLk3rKlBhSwBJ6y4eK956tZb+G4q0L54R1nEZXt4XSM1qG1GfdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768292131; c=relaxed/simple; bh=eUfMDALs3oQGUoNDnjd6BXOv9jf2PYXIXtYjEOUdMWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kWOAxNh6KqlYdEL8jlKzicqvTexopqqlihxbm8v2WgS0LxQs7wiih4wndu/MjX3TxuaY8Q08jLBiF8+hCNuzI2K2MZ7UCiWsXyYhW6vLrCyBHVVrvhGaAKjHKE7yBInBh0eUwYp86LQkgMguY7aqDpx/gVC9i32bUAokI4d0b2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VyN8i23A; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VyN8i23A" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-34e730f5fefso5166714a91.0 for ; Tue, 13 Jan 2026 00:15:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768292130; x=1768896930; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PwTnQsuEWMmzKeRtMHdsKcZZ3Am1ZXUylBtZW2knjDQ=; b=VyN8i23AloqYp0gSyrI+vUwcHa4eMdWQHy/uUYsuS3qYXoletVPJxWWpWhQ9/i4MVZ 2kFR/oxG7IwrwFvuTVW6Dd+bLP6ohpdrrtidR/t55Sip2zwv+mxhUX+M0VLfmavY7cKo 0T7zlf623+NNLcbcVvC/C1sWt1RhLqVh+GS3RoC6cEwsgqdz2ZnM3wksTgD99n+AOxU9 CgCTsUe4ZWY3E8xcSWv4Iav9m9FTAAMRc3k24U4LayQ27sTSfyrdy5EoB5LIVySC+nXS 9WO01iSqpp+x4/ROIGkTE7lZquRiV2fw5ltMK8EQQ+q3stFs5PJ22WHQeWZnelH10Kiu TKgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768292130; x=1768896930; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PwTnQsuEWMmzKeRtMHdsKcZZ3Am1ZXUylBtZW2knjDQ=; b=DbK+LbBlpLufZhMoT44+l7ilxTxD5ilyaFERyxkoXFoNUnOAozGyS23kqBXIpN3pif sVXCq3SfCRIGyRDyVqRuFpsrmOumj/SglP9AK5XHJVZZwx+ENNyPPkbn1Qz4tcsEyfYZ rIYGByFYskHiHN52V4KEvwFF1LMBvHbjbmVTSbvFVCaIRuxb9QwJPMEP1Y6osZ/IZGdn W9cJAUbTqMA3DGnpkmP238pTha96UmGDLJr4qIkvmFjQu11OGD0opG2cyRR2O6dRU+uR U+vVhnHjYo88QEsq4PTTw+zNDOOUnmuSu+0KSSgYcq944TTY44XJhVWrP70aP/S807yy 2/TA== X-Forwarded-Encrypted: i=1; AJvYcCWm0MQcK/2t1bg12m54yE7eWq5KIBzCURMx3fbJfnnm4lJ5YbXcBwvjZLxsTIglt0EtMRervAE7yh551K4=@vger.kernel.org X-Gm-Message-State: AOJu0YzLdQORuouih4WU/78kYiQhbBcNSb/spR4XFuqttEnpFt6qfw+/ atGiQ3xEQRjENH8kM355O2Ph3rS8FP9PLopkicp7pWoveumjVhpA2GAA X-Gm-Gg: AY/fxX4fWeolbWNQCzqUhdb4acU+wW0se5nh4QV0bl2MqzKgHZCV9lWpMbyOTbZG2Zo NZTozeJVhooBsxXXXM+3vsBc0hEY1V9iOfajLCO0yoxO7S+lKpe5/ePUmxaojv84HICiL7uymw0 GX432KXFFgRrO+5hTRIXUgmlkHex9C6+pnFkvMfqLCDAYLKOv6V0POwyMuxtYlE4MXpif//Hauu 5jcwc3QGdZEb+AqxAuHbfv/PeDRCmUR6Bi0ATws2CO6RLTu6NttfXVBVPP5NWQztKrDmugdA6s5 +GjpYmSxCAilWaWZVh4KCjLMYdTg1lhV03zUN6UPJTJiqMQ955t6vJe8I3OO35uzEddDp4tbm/w YigG2qsNa85cOwayIILbCPs6x+3Qh9JQxIioGt/psmvbpJEqFJUDsmf4trQpDCEWSKLh72oNgmb G/q4jIdk1YCvehWgE7iDlaT2tlqw== X-Google-Smtp-Source: AGHT+IGyoLWqkhk6HNGdCwYOoM3jG2DoR/KQRVZcJr9YqWUTu1tHClglXbICbAvlyxhP0k0QSxD03g== X-Received: by 2002:a17:90b:3941:b0:34c:253d:581d with SMTP id 98e67ed59e1d1-34f68c4cc61mr17622637a91.9.1768292129845; Tue, 13 Jan 2026 00:15:29 -0800 (PST) Received: from localhost.localdomain ([240f:34:212d:1:180a:3788:c683:2f64]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-350ff05492dsm657199a91.3.2026.01.13.00.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 00:15:29 -0800 (PST) From: Akinobu Mita To: akinobu.mita@gmail.com Cc: 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, ziy@nvidia.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, ying.huang@linux.alibaba.com, apopple@nvidia.com, bingjiao@google.com, jonathan.cameron@huawei.com, pratyush.brahma@oss.qualcomm.com Subject: [PATCH v4 1/3] mm: memory-tiers, numa_emu: enable to create memory tiers using fake numa nodes Date: Tue, 13 Jan 2026 17:14:51 +0900 Message-ID: <20260113081453.8293-2-akinobu.mita@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260113081453.8293-1-akinobu.mita@gmail.com> References: <20260113081453.8293-1-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This makes it possible to create memory tiers using fake numa nodes generated by numa emulation. The "numa_emulation.adistance=3D" kernel cmdline option allows you to set the abstract distance for each NUMA node. For example, you can create two fake nodes, each in a different memory tier by booting with "numa=3Dfake=3D2 numa_emulation.adistance=3D576,704". Here, the abstract distances of node0 and node1 are set to 576 and 704, respectively. Each memory tier covers an abstract distance chunk size of 128. Thus, nodes with abstract distances between 512 and 639 are classified into the same memory tier, and nodes with abstract distances between 640 and 767 are classified into the next slower memory tier. The abstract distance of fake nodes not specified in the parameter will be the default DRAM abstract distance of 576. Signed-off-by: Akinobu Mita Reviewed-by: Jonathan Cameron Reviewed-by: Pratyush Brahma --- v4: - remove unnecessary include of linux/node.h, suggested by Jonathan Cameron - include linux/notifier.h for the notifier_block, suggested by Jonathan Ca= meron - typo in abstruct distance value in the commit log v2: - fix the explanation about cmdline parameter in the commit log mm/numa_emulation.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mm/numa_emulation.c b/mm/numa_emulation.c index 703c8fa05048..2d05e61570cc 100644 --- a/mm/numa_emulation.c +++ b/mm/numa_emulation.c @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -344,6 +347,27 @@ static int __init setup_emu2phys_nid(int *dfl_phys_nid) return max_emu_nid; } =20 +static int adistance[MAX_NUMNODES]; +module_param_array(adistance, int, NULL, 0400); +MODULE_PARM_DESC(adistance, "Abstract distance values for each NUMA node"); + +static int emu_calculate_adistance(struct notifier_block *self, + unsigned long nid, void *data) +{ + if (adistance[nid]) { + int *adist =3D data; + + *adist =3D adistance[nid]; + return NOTIFY_STOP; + } + return NOTIFY_OK; +} + +static struct notifier_block emu_adist_nb =3D { + .notifier_call =3D emu_calculate_adistance, + .priority =3D INT_MIN, +}; + /** * numa_emulation - Emulate NUMA nodes * @numa_meminfo: NUMA configuration to massage @@ -532,6 +556,8 @@ void __init numa_emulation(struct numa_meminfo *numa_me= minfo, int numa_dist_cnt) } } =20 + register_mt_adistance_algorithm(&emu_adist_nb); + /* free the copied physical distance table */ memblock_free(phys_dist, phys_size); return; --=20 2.43.0