From patchwork Sun Aug 14 05:53:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rebecca Mckeever X-Patchwork-Id: 12942848 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61229C25B08 for ; Sun, 14 Aug 2022 05:54:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F33F88E0009; Sun, 14 Aug 2022 01:54:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBF628E0001; Sun, 14 Aug 2022 01:54:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE7AA8E0009; Sun, 14 Aug 2022 01:54:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BEB068E0001 for ; Sun, 14 Aug 2022 01:54:19 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 954FB160689 for ; Sun, 14 Aug 2022 05:54:19 +0000 (UTC) X-FDA: 79797133038.09.9F4879C Received: from mail-il1-f194.google.com (mail-il1-f194.google.com [209.85.166.194]) by imf10.hostedemail.com (Postfix) with ESMTP id 3C87FC01A0 for ; Sun, 14 Aug 2022 05:54:19 +0000 (UTC) Received: by mail-il1-f194.google.com with SMTP id z8so2507413ile.0 for ; Sat, 13 Aug 2022 22:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=mrwOFT/FVIpeQilRUSDlN1UFE6zYPVjgWmD8J2V/Rvw=; b=kzOoUtnt+1ScgJ8esSYWaoJQNS0I+4PV9yigMOUggv6Un7yJZpa2YCTxfyI7pmNJCE OchlVt+bRFGASVbrBnqan+ICPglUQP1NW/JQu277PhGvNJDI2PXHFbHhOUR6BTdZhyNw Dicfa0soc5mWdHKIfA9Hhs+EGQRefyT94wFa369xpj1MDMIoBNtNf4u8HsOgogPBnLx5 ppkIXLRVJum8M6IAVYXbkf75ABQzT4m4hrg15N+ORpppsqsrvELpnHhkXa990aij2VbK TOTW0HcwOvaVXqa0vPMppMRwUtfPJcPMf0NP+UOk+nOpovLeP2biej/Qzcq5um6ovfXm olxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=mrwOFT/FVIpeQilRUSDlN1UFE6zYPVjgWmD8J2V/Rvw=; b=yWxQRPMYx8nNQ+3Ey7/0PawDdnNggiskzOCYJveu+PpYeGBSLDMdaoemLxfmywM1w4 ddRdK1y6IBysmqfyH5EKQwjOjr5DuhhqqO3i1W+eKv0ZCjhMG3SD6ZNv4Sq8Rz2VlcN+ dytru0MPp2wI8rmLtUHh1GXGEvSGfPPtA50/AXm3Ta2XBebl7B7N5xUUQmzwprK2BCCD zHKzSF/4airNuwuJae1EVTqIKQxEGmbVW+EFMcYMyu+DpxWOPlGZMH1/r1kRq4Pf+q4B mIuQ2Lau5s2LzJbqg35xf3SFPnZ8ZcRp3LOfU1c0h0hLT52wQl+gj1oE18BYmLGqmeWR OflA== X-Gm-Message-State: ACgBeo0l/kWZilCthvJ/oteV0nsx3NF1qysRmAxOHda5fZx/VvYSUvHm 9//N+6SYOluirCWsB30Ivh8= X-Google-Smtp-Source: AA6agR5YE34UARRXt7XzwTzkmVuH340HkSDCAUvT5f59RLZ+kXqXbh02Efm57RVbCJnfAhEDb7bzZw== X-Received: by 2002:a05:6e02:1caf:b0:2e0:cec1:9f17 with SMTP id x15-20020a056e021caf00b002e0cec19f17mr4801562ill.5.1660456458500; Sat, 13 Aug 2022 22:54:18 -0700 (PDT) Received: from sophie (static-198-54-128-70.cust.tzulo.com. [198.54.128.70]) by smtp.gmail.com with ESMTPSA id u7-20020a056e02110700b002dcafb975c6sm2603415ilk.82.2022.08.13.22.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Aug 2022 22:54:18 -0700 (PDT) From: Rebecca Mckeever To: Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: David Hildenbrand , Rebecca Mckeever Subject: [PATCH 6/8] memblock tests: update alloc_nid_api to test memblock_alloc_try_nid_raw Date: Sun, 14 Aug 2022 00:53:58 -0500 Message-Id: <4c9b416480a5070f18c3933a1a03296f32c2091b.1660454730.git.remckee0@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660456459; a=rsa-sha256; cv=none; b=tRD3hkRSpy3Wo94dZXovQVxYk4mzgFJL04UQbiN7xaJcHGvt6WQO9VIO99zJphvn5qUcBA KY8HC5a+UIr6tDelENVA6dDtzjPvbfa6YA9JwiyerwHzLEBe83JAod00QaC8xOB/WJF3zi Si8+O78fx257hcib7LN4dwD+wndWluU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kzOoUtnt; spf=pass (imf10.hostedemail.com: domain of remckee0@gmail.com designates 209.85.166.194 as permitted sender) smtp.mailfrom=remckee0@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660456459; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mrwOFT/FVIpeQilRUSDlN1UFE6zYPVjgWmD8J2V/Rvw=; b=U1E3bu6sqRal7cK/iQTWCSIPggojeSKIdVMX6zyd0VtCob0idZMMijRkkj5dy9ncKL23rG TSQj3bs4wvYObL8yT5ghanuXsKPu3oSxCVcQZSi3Z35Q/VsaE/nVXC1FVHEvaaULx4N0iV /qdJieZ7VXG5jeyEnGZG0DLof9haETk= X-Rspamd-Queue-Id: 3C87FC01A0 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kzOoUtnt; spf=pass (imf10.hostedemail.com: domain of remckee0@gmail.com designates 209.85.166.194 as permitted sender) smtp.mailfrom=remckee0@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: xag7p8ikowja6fcxsagmxyrz1byyectg X-HE-Tag: 1660456459-7277 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000034, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Update memblock_alloc_try_nid() tests so that they test either memblock_alloc_try_nid() or memblock_alloc_try_nid_raw() depending on the value of alloc_nid_test_flags. Run through all the existing tests in alloc_nid_api twice: once for memblock_alloc_try_nid() and once for memblock_alloc_try_nid_raw(). When the tests run memblock_alloc_try_nid(), they test that the entire memory region is zero. When the tests run memblock_alloc_try_nid_raw(), they test that the entire memory region is nonzero. Signed-off-by: Rebecca Mckeever --- tools/testing/memblock/tests/alloc_nid_api.c | 196 ++++++++++++------- 1 file changed, 127 insertions(+), 69 deletions(-) diff --git a/tools/testing/memblock/tests/alloc_nid_api.c b/tools/testing/memblock/tests/alloc_nid_api.c index 82fa8ea36320..e16106d8446b 100644 --- a/tools/testing/memblock/tests/alloc_nid_api.c +++ b/tools/testing/memblock/tests/alloc_nid_api.c @@ -1,6 +1,42 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "alloc_nid_api.h" +static const char * const func_testing[] = { + "memblock_alloc_try_nid", + "memblock_alloc_try_nid_raw" +}; + +static int alloc_nid_test_flags = TEST_ZEROED; + +static inline const char * const get_func_testing(int flags) +{ + if (flags & TEST_RAW) + return func_testing[1]; + else + return func_testing[0]; +} + +static inline void *run_memblock_alloc_try_nid(phys_addr_t size, + phys_addr_t align, + phys_addr_t min_addr, + phys_addr_t max_addr, int nid) +{ + if (alloc_nid_test_flags & TEST_RAW) + return memblock_alloc_try_nid_raw(size, align, min_addr, + max_addr, nid); + else + return memblock_alloc_try_nid(size, align, min_addr, + max_addr, nid); +} + +static inline void verify_mem_content(void *mem, int size) +{ + if (alloc_nid_test_flags & TEST_RAW) + ASSERT_MEM_NE((char *)mem, 0, size); + else + ASSERT_MEM_EQ((char *)mem, 0, size); +} + /* * A simple test that tries to allocate a memory region within min_addr and * max_addr range: @@ -32,12 +68,13 @@ static int alloc_try_nid_top_down_simple_check(void) min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2; max_addr = min_addr + SZ_512; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); rgn_end = rgn->base + rgn->size; ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, max_addr - size); @@ -86,12 +123,13 @@ static int alloc_try_nid_top_down_end_misaligned_check(void) min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2; max_addr = min_addr + SZ_512 + misalign; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); rgn_end = rgn->base + rgn->size; ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, max_addr - size - misalign); @@ -137,12 +175,13 @@ static int alloc_try_nid_exact_address_generic_check(void) min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES; max_addr = min_addr + size; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); rgn_end = rgn->base + rgn->size; ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, min_addr); @@ -189,11 +228,12 @@ static int alloc_try_nid_top_down_narrow_range_check(void) min_addr = memblock_start_of_DRAM() + SZ_512; max_addr = min_addr + SMP_CACHE_BYTES; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, max_addr - size); @@ -241,8 +281,9 @@ static int alloc_try_nid_low_max_generic_check(void) min_addr = memblock_start_of_DRAM(); max_addr = min_addr + SMP_CACHE_BYTES; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_EQ(allocated_ptr, NULL); @@ -287,11 +328,12 @@ static int alloc_try_nid_min_reserved_generic_check(void) memblock_reserve(reserved_base, r1_size); - allocated_ptr = memblock_alloc_try_nid(r2_size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(r2_size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, r2_size); + verify_mem_content(allocated_ptr, r2_size); ASSERT_EQ(rgn->size, total_size); ASSERT_EQ(rgn->base, reserved_base); @@ -338,11 +380,12 @@ static int alloc_try_nid_max_reserved_generic_check(void) memblock_reserve(max_addr, r1_size); - allocated_ptr = memblock_alloc_try_nid(r2_size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(r2_size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, r2_size); + verify_mem_content(allocated_ptr, r2_size); ASSERT_EQ(rgn->size, total_size); ASSERT_EQ(rgn->base, min_addr); @@ -402,11 +445,12 @@ static int alloc_try_nid_top_down_reserved_with_space_check(void) memblock_reserve(r1.base, r1.size); memblock_reserve(r2.base, r2.size); - allocated_ptr = memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, r3_size); + verify_mem_content(allocated_ptr, r3_size); ASSERT_EQ(rgn1->size, r1.size + r3_size); ASSERT_EQ(rgn1->base, max_addr - r3_size); @@ -466,11 +510,12 @@ static int alloc_try_nid_reserved_full_merge_generic_check(void) memblock_reserve(r1.base, r1.size); memblock_reserve(r2.base, r2.size); - allocated_ptr = memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, r3_size); + verify_mem_content(allocated_ptr, r3_size); ASSERT_EQ(rgn->size, total_size); ASSERT_EQ(rgn->base, r2.base); @@ -531,11 +576,12 @@ static int alloc_try_nid_top_down_reserved_no_space_check(void) memblock_reserve(r1.base, r1.size); memblock_reserve(r2.base, r2.size); - allocated_ptr = memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, r3_size); + verify_mem_content(allocated_ptr, r3_size); ASSERT_EQ(rgn1->size, r1.size); ASSERT_EQ(rgn1->base, r1.base); @@ -597,8 +643,9 @@ static int alloc_try_nid_reserved_all_generic_check(void) memblock_reserve(r1.base, r1.size); memblock_reserve(r2.base, r2.size); - allocated_ptr = memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_EQ(allocated_ptr, NULL); @@ -628,11 +675,12 @@ static int alloc_try_nid_top_down_cap_max_check(void) min_addr = memblock_end_of_DRAM() - SZ_1K; max_addr = memblock_end_of_DRAM() + SZ_256; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, memblock_end_of_DRAM() - size); @@ -666,11 +714,12 @@ static int alloc_try_nid_top_down_cap_min_check(void) min_addr = memblock_start_of_DRAM() - SZ_256; max_addr = memblock_end_of_DRAM(); - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, memblock_end_of_DRAM() - size); @@ -714,13 +763,13 @@ static int alloc_try_nid_bottom_up_simple_check(void) min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2; max_addr = min_addr + SZ_512; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, - NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); rgn_end = rgn->base + rgn->size; ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, min_addr); @@ -769,13 +818,13 @@ static int alloc_try_nid_bottom_up_start_misaligned_check(void) min_addr = memblock_start_of_DRAM() + misalign; max_addr = min_addr + SZ_512; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, - NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); rgn_end = rgn->base + rgn->size; ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, min_addr + (SMP_CACHE_BYTES - misalign)); @@ -822,12 +871,12 @@ static int alloc_try_nid_bottom_up_narrow_range_check(void) min_addr = memblock_start_of_DRAM() + SZ_512; max_addr = min_addr + SMP_CACHE_BYTES; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, - NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, memblock_start_of_DRAM()); @@ -887,12 +936,12 @@ static int alloc_try_nid_bottom_up_reserved_with_space_check(void) memblock_reserve(r1.base, r1.size); memblock_reserve(r2.base, r2.size); - allocated_ptr = memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, - min_addr, max_addr, - NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, r3_size); + verify_mem_content(allocated_ptr, r3_size); ASSERT_EQ(rgn1->size, r1.size); ASSERT_EQ(rgn1->base, max_addr); @@ -959,12 +1008,12 @@ static int alloc_try_nid_bottom_up_reserved_no_space_check(void) memblock_reserve(r1.base, r1.size); memblock_reserve(r2.base, r2.size); - allocated_ptr = memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, - min_addr, max_addr, - NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, r3_size); + verify_mem_content(allocated_ptr, r3_size); ASSERT_EQ(rgn3->size, r3_size); ASSERT_EQ(rgn3->base, memblock_start_of_DRAM()); @@ -1004,12 +1053,12 @@ static int alloc_try_nid_bottom_up_cap_max_check(void) min_addr = memblock_start_of_DRAM() + SZ_1K; max_addr = memblock_end_of_DRAM() + SZ_256; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, - NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, min_addr); @@ -1043,12 +1092,12 @@ static int alloc_try_nid_bottom_up_cap_min_check(void) min_addr = memblock_start_of_DRAM(); max_addr = memblock_end_of_DRAM() - SZ_256; - allocated_ptr = memblock_alloc_try_nid(size, SMP_CACHE_BYTES, - min_addr, max_addr, - NUMA_NO_NODE); + allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES, + min_addr, max_addr, + NUMA_NO_NODE); ASSERT_NE(allocated_ptr, NULL); - ASSERT_MEM_EQ((char *)allocated_ptr, 0, size); + verify_mem_content(allocated_ptr, size); ASSERT_EQ(rgn->size, size); ASSERT_EQ(rgn->base, memblock_start_of_DRAM()); @@ -1193,13 +1242,14 @@ static int alloc_try_nid_low_max_check(void) return 0; } -int memblock_alloc_nid_checks(void) +static int memblock_alloc_nid_checks_internal(int flags) { - const char *func_testing = "memblock_alloc_try_nid"; + const char *func = get_func_testing(flags); + alloc_nid_test_flags = flags; prefix_reset(); - prefix_push(func_testing); - test_print("Running %s tests...\n", func_testing); + prefix_push(func); + test_print("Running %s tests...\n", func); reset_memblock_attributes(); dummy_physical_memory_init(); @@ -1225,3 +1275,11 @@ int memblock_alloc_nid_checks(void) return 0; } + +int memblock_alloc_nid_checks(void) +{ + memblock_alloc_nid_checks_internal(TEST_ZEROED); + memblock_alloc_nid_checks_internal(TEST_RAW); + + return 0; +}