From nobody Mon Jun 15 19:26:54 2026 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 A00B93B28D for ; Wed, 15 Apr 2026 12:28:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776256081; cv=none; b=hWySZRUzMdDyktH5vyIsub1beoPlkW2JlXCxzufMcEXBx9acJArvTfHMlVx3V1ecCV3TMVbx8pg0zEtC/k7ddv4tjnMJoK9W5/Ik1dv5nXQzj7l5CEAnyyZhbgaFjKGZrU5Wc3+iV0bHM7GPClPDuO5Tal8ChWPGFlW99/JyvNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776256081; c=relaxed/simple; bh=0m5uqPJxigUALId5YSv54iKGA9Ocoq1eqOv9LyyXBkw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BQD8832AMGJuuil7WuJWHc9xaTdSe521/IFxWL2TB2NgEnz7/9BijbANqEq81nxtP6luwT8WY26kqCE6NXNTc3XG1jtsXHmn0/3d3UP420i7+ZkkL3yp5SegtLkkmbgIrvebz7Zmqpf2CpoA2isx1+mJ+AMCGKgcd6LUPB1oJoE= 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=UzeKAsgu; arc=none smtp.client-ip=209.85.210.175 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="UzeKAsgu" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-82c70e4654eso2881035b3a.2 for ; Wed, 15 Apr 2026 05:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776256080; x=1776860880; 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=MGXqlQS/KnXB9/V1z19COjJZUtHkidF1KtI4LzcaBPE=; b=UzeKAsguZGg3hM7NiayCfa8uVJEVGRmD3k6HbVT3tps30ko6ZRzTaFNcM+/m5CFMu1 wG3YOUHz7/JLKswzftdRFd6rAaYSRSRsYdmP1Db+KSnkNt1Ot5g2AspnoFP0Tl/H620X mf7KHN05POjAxtDxYGNaTALlhAp0WgkKWZNV7g1RZjlvRUWV6C1gQ8XkUCtX7nmn/s0C gFZxhsnn8chjs3XFjviumskklL8ib3uTr50hfkRWyeGKl35YXUACIbWkoDHmXqYnfDMW S1mgtyU8nRqgOTjDCE8ICCThRcBTgLFuCmw5RYaV7eXR8FejkUB6J9kCNKmY6d0TfMoW CKXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776256080; x=1776860880; 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=MGXqlQS/KnXB9/V1z19COjJZUtHkidF1KtI4LzcaBPE=; b=HtVAtQRdzHq3PxAgWIdZWKFCuK/zgu6BCdxT5MiaGNJEr16ls6q8xYFb3vdPtGo/uH 5ESu0JKJeB0/QGFsBFfZYHhzT8LrOm42lOzLJiQiLMD+p6egL52gruT3v/xeuI8YMeay 2mM6Wgo+9UYiQN/DEeGDyC4sVPQWYCr7KzI5YZU5jY/Z2d+c6/KtLAShEAbbof6vcdrW jdhJ50c5t+mA3n0Ks65gcCXU/x4JDJkXuDtRSemaYkz+48D6gFJxiXredDmdae4symCo sBMKjZxiaQoSsl07/VbdvWq0UXHeh14/V3AZaMd49gqMC3NGvK6sDkrG/sWCpj3UvUqy yp6Q== X-Forwarded-Encrypted: i=1; AFNElJ+EkjaNfcIWXKLQV4PZEwVDXxZsOyOKluCVHWztZGigwqMIiEv8qzNiOWEujFVYAz0Z3+zHjELrHvJlzeo=@vger.kernel.org X-Gm-Message-State: AOJu0YxQpZqGbNVHaqMGAyuNh4UwgArZ8KgdrZglwu1kZRl5jvxw96F6 28YSKu6dFyyC1r4urSPXTSI/Ih/N1JjaTKyAPPQEDJsDEanNV4XsAZ34Qb77eyG9vqY= X-Gm-Gg: AeBDiesyRNFK20yoTAezUP2ACZ3sOyyd0JCgjW6WTwMQaM8uS8/FdYQ5hI0MZ7srM0q UQJEcE8tAm2ji+ZE0VW2rNkyd5/nJHkGDRE8ZQuuJhJH/8QhEgaSFD9bwVWwATt2Ysii6gnmhcK qjKMFwMf8rKkeKPF231NAK2LmioK6foPnRCFku5C9nmxskJSV8zVmsvFWrXi2p/sFJ1J3i7DJO6 caEcrI7jQv24vI2jiVSs69L6TIgJVjDQRcD6SWXJ1f7ceBia4aBtyHk1zK+0MHKECAzeyiKukvg ili840thDgjS865sO+bPxSkuXrRq3Fj5Xn6//1TVf8WVBKSirgD8jYlM25gpsoV8GOkWhWUrAj3 cRFaFpuoX0309yK0E0YoPHwf/5sdEy64ku9SCBaP30wATGVzc4SzTn9HiYQzX0zlx7rYI6kfLoD EkfZaliAj/XMp2m9nuVTmvB/DFE3c= X-Received: by 2002:a05:6a00:2ea2:b0:82d:30f:b197 with SMTP id d2e1a72fcca58-82f0c28b84bmr23171264b3a.22.1776256079805; Wed, 15 Apr 2026 05:27:59 -0700 (PDT) Received: from potato.. ([192.19.252.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f673e149fsm1824361b3a.32.2026.04.15.05.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2026 05:27:59 -0700 (PDT) From: priyanshukumarpu@gmail.com To: rppt@kernel.org Cc: akpm@linux-foundation.org, changyuanl@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Priyanshu Kumar Subject: [PATCH v2] tools/testing/memblock: fix stale NUMA reservation tests Date: Wed, 15 Apr 2026 12:27:31 +0000 Message-ID: <20260415122731.1768912-1-priyanshukumarpu@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413091458.774770-1-priyanshukumarpu@gmail.com> References: <20260413091458.774770-1-priyanshukumarpu@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" From: Priyanshu Kumar memblock allocations now reserve memory with MEMBLOCK_RSRV_KERN and, on NUMA configurations, record the requested node on the reserved region. Several memblock simulator NUMA tests still expected merges that only worked before those reservation semantics changed, so the suite aborted even though the allocator behavior was correct. Update the NUMA merge expectations in the memblock_alloc_try_nid() and memblock_alloc_exact_nid_raw() tests to match the current reserved region metadata rules. For cases that should still merge, create the pre-existing reservation with matching nid and MEMBLOCK_RSRV_KERN metadata. Also strengthen the memblock_alloc_node() coverage by checking the newly created reserved region directly instead of re-reading the source memory node descriptor. Finally, drop the stale README/TODO notes that still claimed memblock_alloc_node() could not be tested. The memblock simulator passes again with NUMA enabled after these updates. Signed-off-by: Priyanshu Kumar --- tools/testing/memblock/README | 5 +---- tools/testing/memblock/TODO | 4 ++-- .../memblock/tests/alloc_exact_nid_api.c | 6 +++--- tools/testing/memblock/tests/alloc_nid_api.c | 21 +++++++++++++------ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tools/testing/memblock/README b/tools/testing/memblock/README index 7ca437d81806..b435f48d8a70 100644 --- a/tools/testing/memblock/README +++ b/tools/testing/memblock/README @@ -104,10 +104,7 @@ called at the beginning of each test. Known issues =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -1. Requesting a specific NUMA node via memblock_alloc_node() does not work= as - intended. Once the fix is in place, tests for this function can be adde= d. - -2. Tests for memblock_alloc_low() can't be easily implemented. The functio= n uses +1. Tests for memblock_alloc_low() can't be easily implemented. The functio= n uses ARCH_LOW_ADDRESS_LIMIT marco, which can't be changed to point at the low memory of the memory_block. =20 diff --git a/tools/testing/memblock/TODO b/tools/testing/memblock/TODO index e306c90c535f..c13ad0dae776 100644 --- a/tools/testing/memblock/TODO +++ b/tools/testing/memblock/TODO @@ -1,5 +1,5 @@ TODO =3D=3D=3D=3D=3D =20 -1. Add tests for memblock_alloc_node() to check if the correct NUMA node i= s set - for the new region +1. Add tests for memblock_alloc_low() once the simulator can model + ARCH_LOW_ADDRESS_LIMIT against the low memory in memory_block diff --git a/tools/testing/memblock/tests/alloc_exact_nid_api.c b/tools/tes= ting/memblock/tests/alloc_exact_nid_api.c index 6e14447da6e1..0c46c73b5e04 100644 --- a/tools/testing/memblock/tests/alloc_exact_nid_api.c +++ b/tools/testing/memblock/tests/alloc_exact_nid_api.c @@ -368,7 +368,7 @@ static int alloc_exact_nid_bottom_up_numa_part_reserved= _check(void) max_addr =3D memblock_end_of_DRAM(); total_size =3D size + r1.size; =20 - memblock_reserve(r1.base, r1.size); + __memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN); allocated_ptr =3D memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES, min_addr, max_addr, nid_req); @@ -861,8 +861,8 @@ static int alloc_exact_nid_numa_reserved_full_merge_gen= eric_check(void) min_addr =3D r2.base + r2.size; max_addr =3D r1.base; =20 - memblock_reserve(r1.base, r1.size); - memblock_reserve(r2.base, r2.size); + __memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN); + __memblock_reserve(r2.base, r2.size, nid_req, MEMBLOCK_RSRV_KERN); =20 allocated_ptr =3D memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES, min_addr, max_addr, diff --git a/tools/testing/memblock/tests/alloc_nid_api.c b/tools/testing/m= emblock/tests/alloc_nid_api.c index 562e4701b0e0..c23652727976 100644 --- a/tools/testing/memblock/tests/alloc_nid_api.c +++ b/tools/testing/memblock/tests/alloc_nid_api.c @@ -1965,7 +1965,7 @@ static int alloc_nid_bottom_up_numa_part_reserved_che= ck(void) max_addr =3D memblock_end_of_DRAM(); total_size =3D size + r1.size; =20 - memblock_reserve(r1.base, r1.size); + __memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN); allocated_ptr =3D run_memblock_alloc_nid(size, SMP_CACHE_BYTES, min_addr, max_addr, nid_req); =20 @@ -2412,8 +2412,8 @@ static int alloc_nid_numa_reserved_full_merge_generic= _check(void) min_addr =3D r2.base + r2.size; max_addr =3D r1.base; =20 - memblock_reserve(r1.base, r1.size); - memblock_reserve(r2.base, r2.size); + __memblock_reserve(r1.base, r1.size, nid_req, MEMBLOCK_RSRV_KERN); + __memblock_reserve(r2.base, r2.size, nid_req, MEMBLOCK_RSRV_KERN); =20 allocated_ptr =3D run_memblock_alloc_nid(size, SMP_CACHE_BYTES, min_addr, max_addr, nid_req); @@ -2496,15 +2496,18 @@ static int alloc_nid_numa_split_all_reserved_generi= c_check(void) =20 /* * A simple test that tries to allocate a memory region through the - * memblock_alloc_node() on a NUMA node with id `nid`. Expected to have the - * correct NUMA node set for the new region. + * memblock_alloc_node() on a NUMA node with id `nid`. Expected to allocate + * the region within the requested node and mark the new reservation with = the + * correct NUMA node. */ static int alloc_node_on_correct_nid(void) { int nid_req =3D 2; void *allocated_ptr =3D NULL; #ifdef CONFIG_NUMA + struct memblock_region *new_rgn =3D &memblock.reserved.regions[0]; struct memblock_region *req_node =3D &memblock.memory.regions[nid_req]; + phys_addr_t req_node_end =3D region_end(req_node); #endif phys_addr_t size =3D SZ_512; =20 @@ -2515,7 +2518,13 @@ static int alloc_node_on_correct_nid(void) =20 ASSERT_NE(allocated_ptr, NULL); #ifdef CONFIG_NUMA - ASSERT_EQ(nid_req, req_node->nid); + ASSERT_EQ(memblock.reserved.cnt, 1); + ASSERT_EQ(new_rgn->size, size); + ASSERT_EQ(new_rgn->base, (phys_addr_t)allocated_ptr); + ASSERT_EQ(new_rgn->flags, MEMBLOCK_RSRV_KERN); + ASSERT_EQ(nid_req, memblock_get_region_node(new_rgn)); + ASSERT_LE(req_node->base, new_rgn->base); + ASSERT_LE(region_end(new_rgn), req_node_end); #endif =20 test_pass_pop(); --=20 2.43.0