From patchwork Thu Apr 25 07:19:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13642907 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 46162C10F1A for ; Thu, 25 Apr 2024 07:20:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0C1F6B0095; Thu, 25 Apr 2024 03:20:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C6F026B0096; Thu, 25 Apr 2024 03:20:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9D6A96B0098; Thu, 25 Apr 2024 03:20:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7E6336B0095 for ; Thu, 25 Apr 2024 03:20:01 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4AC0A16038E for ; Thu, 25 Apr 2024 07:20:01 +0000 (UTC) X-FDA: 82047205002.01.82C02CE Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by imf23.hostedemail.com (Postfix) with ESMTP id 8B15E140016 for ; Thu, 25 Apr 2024 07:19:59 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IB44bI3a; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714029599; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=ruk7s7bdabrinkpT9zz0qoc/gy6xrlFmeWcA59VPr04=; b=wK8/72kIskdMgQKvryNcm+51Fccq/YmyWRTD7/iD8uLnBin1uhspcd41RcbJW4fx8dQA1e TE9fs2Iw2CBUt/o0svO81llPntesZMKgpml8Zr4XzJnqXpwgpOZZU5MQkTeEJQAax2U65Q Wyoc7okKxutROzKVEPFLCbHezx4/faI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=IB44bI3a; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.45 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714029599; a=rsa-sha256; cv=none; b=3TEhMABSUh1p5QvYABrzbZTdHW4fVbZVlUOD43N1BPqHHeCBiKLVnmtiVSY0hG48mfXhwS 9TBfZA5PjgJa4wruXvRFSOAf+3YYFTDId6YEuskKuHXT3xkCbm0fLC+Q16380NTwya2OCE gP3x+A3JMtyKrNllUhype7jjPuNG4kc= Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5723edf0ae5so306239a12.0 for ; Thu, 25 Apr 2024 00:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714029598; x=1714634398; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=ruk7s7bdabrinkpT9zz0qoc/gy6xrlFmeWcA59VPr04=; b=IB44bI3at2aoY/jPGlkYiEw4OQhx7wIBCPMKiw8VQdZP/U/m/sjwU+J/zq6XUHWQj/ dE3L4GVtz6lIhqGX/wALe+TNq6R1H6aV27mt/XxpqR2p+kldLwbVHnAoJonESH0TrYTH b+lTT9j46ZPr7450G0wuoVByKf5DJvpkPOqyF4rwDP3tUDO5SKFv1UMnKMQo77AqZIst xlxslAAvfghJqODXUJF2dFVcBArQHucd2TKrhe9Dxw10/UmnNgCYYt6W76YxmthJaOVh bSoShGwp9dF+FoMaE7nKIraucx15p0vzYXkWVnBKHRHn3kDQYQX2jYfQSuswIunW66tq BqLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714029598; x=1714634398; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ruk7s7bdabrinkpT9zz0qoc/gy6xrlFmeWcA59VPr04=; b=utT6zwKVhuPxXjE4R6BCoXysRT+RTVR7SyrbDFRSzA2TTsmigW8fgHW2cCLNX+C9pV qZ6k3fNTWZPDGTJ2HZkQdiGBf1T4O7vVCQ7cL6fDZr6c1JPZrYYa26wDogix2jXmR3rl CqGDTaNDt4cuIgKSD5H2TXANk/daG6QOZNOhvUhN3sK6c3bZ03aFa1CjGDY7GFyd+/+b +o6CVC+iw5Y9M//d8NLoNwKMTH084C0rpusmLtDfOD4svIUZbJxmhtSiI7yWDMNBRaq/ KHnZZjplZSH8evIG2645CHWvaMEFlvbENQfHPd8WrRxF/HgD5UxFfs8RRrSJYB/5qG63 +v4A== X-Gm-Message-State: AOJu0YxV1I4jxH07EXaGXaHfcfkXw1aYgxNfHe/GhDp+Cq0fBuqqWdL7 3mocI3trojuBazSzmNx1ywZQZvJeI7VHTr1s09dc778HsGVFG/L8xh/ixI8f X-Google-Smtp-Source: AGHT+IHAg9Nww8nowt5XSgWZ1jsU+QCSk2dek0fqJysW9t4Y5P7Evy6K64Z6cQtJTP4gNycXnZ944g== X-Received: by 2002:a50:a693:0:b0:56d:fca5:4245 with SMTP id e19-20020a50a693000000b0056dfca54245mr3354485edc.10.1714029597979; Thu, 25 Apr 2024 00:19:57 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id et6-20020a056402378600b0057245a3fd4bsm130271edb.68.2024.04.25.00.19.56 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 00:19:56 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [Patch v2 1/8] memblock tests: reserve the 129th memory block at all possible position Date: Thu, 25 Apr 2024 07:19:22 +0000 Message-Id: <20240425071929.18004-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240425071929.18004-1-richard.weiyang@gmail.com> References: <20240425071929.18004-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8B15E140016 X-Rspam-User: X-Stat-Signature: x9bj1udtzp9iw6ufc33zkhy3oixh1kzg X-HE-Tag: 1714029599-123998 X-HE-Meta: U2FsdGVkX19whHZRDnlr+nx8NBjATWtWsW7XszUWCU7F6HVrXZqyl7NnDClyBjrAHfAT0OQIVLFDqvRMfcO+ZOrxBMhigMoougK05352vI1pUuEXV/UZIH1MxlfX/lsuXz8ngQ3Weez6dfAPc+vL+4SsiAF6FiSzmVOQvi7sif6mc80bUytayU7B2yAAz4tlwNCQtTo0MElO0uuS0ScqnGCdOmJIAm52MSeFMxVZlzZ9881rh3rcG7KbqCe9pGqWDajzzKGdvzkwyvWurslDVgJBeBLr70wS4wLoTm9a9Bvxc0lExU74QmktManIvZ3pXdcFTcVae4FEcGE17InAJ575+f/8Qvo9CefoyqjXYh7Po/quPMjdAyDD3+36XlfVjXyvNf2g0urL230q2Z8WY4mI45DfV1skQJxra7ukAIsBC8VY/Bxs894yZsufCzvbEGAYgdmmlR+uUzkp2/LWkjojscQPyvdq6V1A41sf271b88rCS2/zo7hVFCmk1UDjl00Y2ntrZbeVywsw74mcH22BwxhqP2WNRQrPxVKkLhtHxtqFevTS/aSNh6utyM6I/MSCxZ3j75t+untKiwSicG43JKw4JmmW4f6nXTUN2jBuxxX3858VdfxU8mPhMYYo9RZK2O3C9OLCTREQhq51hEgNWHPgUowiUEfAMFGlHh3JnzBuATmCE60Vrg5ChWi3yfL6P5SCK+laVNrjK/sH1EFFzhDzX7srlWpiOZ8W5l13Hz+gJTDQ6apovYN9sVq6QTHXyAV1aH7SlVrlrAnCMnJjzEDOs9KOQntMXWMGpl7PLx7KDkIoPt3a+obDiNsWsOH2xoURhsMcrqPnHQAELFHAtPDKvHnqJsujgSw5yJ3/WFyrLUg6Z2zdSAgYLKXrWbMTwQq5tzg94qpbFLlDzJi0tRy7MV6Zd3SBZlHMZKKNBmydJkbD7dK1Yget2LWNpvK89MAtEJeWcVl2/v0 s+r63kme YYayChlWdFaQEtsdZ9/jXRH1fLS+hJAoCJkK2AFOLIFJ/z2vbsFwqw+JTH1+8cP6t+oJ1QhiLBy1LYlrfYTsaSkhST2GvbEnUhGUkTBUEfr8ACNPqxEPIfzm/3rHvwwI57a5FqXCciIsmHdW/6B5y28Q5REh+mYO5CZvbzhvJwfzdl87VmKUjtL3Mvb68ysWF40UFtsDqpKzR0katv/l/aYxgHNlv0ta2uzIBnLiKn5syxeWmZWdnr09ZrcXCDryLZQ8HeO2Oi+tMspF+r8OL8fuFeZm80qoV4qxnYo6Js+Lidj48XACP1PmXj9/3/Ua0Ob0sFoOJdzq687PrRXJc7LchjCSMsU3phQeb+qeK7mdz1yQL1QlxUQIklNffAuC4boZaTzfitJRqxDECbeV/yZVGZa5VA9KVROTlfdbpnQEy4K0zOvtBksLKonc7WQ7lNBzEa+Jsx0g5MylEXzBDnF1Or0ug9sPb65wC7BW7LARkLO0PjFD2nm3VchFov9iA5KxNpsVGqjwBIZHSa3lOO85SNjKK/mdOKJz6yxf1adNWrbXz0KnfPHgf8w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000007, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In stead of add 129th memory block at the last position, let's try all possible position. Signed-off-by: Wei Yang --- tools/testing/memblock/tests/basic_api.c | 121 ++++++++++++----------- 1 file changed, 65 insertions(+), 56 deletions(-) diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c index f317fe691fc4..1ae62272867a 100644 --- a/tools/testing/memblock/tests/basic_api.c +++ b/tools/testing/memblock/tests/basic_api.c @@ -898,84 +898,93 @@ static int memblock_reserve_near_max_check(void) * memblock.memory.max, find a new valid memory as * reserved.regions. */ +/* Keep the gap so these memory region will not be merged. */ +#define MEMORY_BASE(idx) (SZ_128K + (MEM_SIZE * 2) * (idx)) static int memblock_reserve_many_check(void) { - int i; + int i, skip; void *orig_region; struct region r = { .base = SZ_16K, .size = SZ_16K, }; - phys_addr_t memory_base = SZ_128K; phys_addr_t new_reserved_regions_size; PREFIX_PUSH(); - reset_memblock_regions(); - memblock_allow_resize(); + /* Reserve the 129th memory block for all possible positions*/ + for (skip = 0; skip < INIT_MEMBLOCK_REGIONS + 1; skip++) { + reset_memblock_regions(); + memblock_allow_resize(); - /* Add a valid memory region used by double_array(). */ - dummy_physical_memory_init(); - memblock_add(dummy_physical_memory_base(), MEM_SIZE); + /* Add a valid memory region used by double_array(). */ + dummy_physical_memory_init(); + memblock_add(dummy_physical_memory_base(), MEM_SIZE); - for (i = 0; i < INIT_MEMBLOCK_REGIONS; i++) { - /* Reserve some fakes memory region to fulfill the memblock. */ - memblock_reserve(memory_base, MEM_SIZE); + for (i = 0; i < INIT_MEMBLOCK_REGIONS + 1; i++) { + if (i == skip) + continue; - ASSERT_EQ(memblock.reserved.cnt, i + 1); - ASSERT_EQ(memblock.reserved.total_size, (i + 1) * MEM_SIZE); + /* Reserve some fakes memory region to fulfill the memblock. */ + memblock_reserve(MEMORY_BASE(i), MEM_SIZE); - /* Keep the gap so these memory region will not be merged. */ - memory_base += MEM_SIZE * 2; - } + if (i < skip) { + ASSERT_EQ(memblock.reserved.cnt, i + 1); + ASSERT_EQ(memblock.reserved.total_size, (i + 1) * MEM_SIZE); + } else { + ASSERT_EQ(memblock.reserved.cnt, i); + ASSERT_EQ(memblock.reserved.total_size, i * MEM_SIZE); + } + } - orig_region = memblock.reserved.regions; + orig_region = memblock.reserved.regions; - /* This reserve the 129 memory_region, and makes it double array. */ - memblock_reserve(memory_base, MEM_SIZE); + /* This reserve the 129 memory_region, and makes it double array. */ + memblock_reserve(MEMORY_BASE(skip), MEM_SIZE); - /* - * This is the memory region size used by the doubled reserved.regions, - * and it has been reserved due to it has been used. The size is used to - * calculate the total_size that the memblock.reserved have now. - */ - new_reserved_regions_size = PAGE_ALIGN((INIT_MEMBLOCK_REGIONS * 2) * - sizeof(struct memblock_region)); - /* - * The double_array() will find a free memory region as the new - * reserved.regions, and the used memory region will be reserved, so - * there will be one more region exist in the reserved memblock. And the - * one more reserved region's size is new_reserved_regions_size. - */ - ASSERT_EQ(memblock.reserved.cnt, INIT_MEMBLOCK_REGIONS + 2); - ASSERT_EQ(memblock.reserved.total_size, (INIT_MEMBLOCK_REGIONS + 1) * MEM_SIZE + - new_reserved_regions_size); - ASSERT_EQ(memblock.reserved.max, INIT_MEMBLOCK_REGIONS * 2); + /* + * This is the memory region size used by the doubled reserved.regions, + * and it has been reserved due to it has been used. The size is used to + * calculate the total_size that the memblock.reserved have now. + */ + new_reserved_regions_size = PAGE_ALIGN((INIT_MEMBLOCK_REGIONS * 2) * + sizeof(struct memblock_region)); + /* + * The double_array() will find a free memory region as the new + * reserved.regions, and the used memory region will be reserved, so + * there will be one more region exist in the reserved memblock. And the + * one more reserved region's size is new_reserved_regions_size. + */ + ASSERT_EQ(memblock.reserved.cnt, INIT_MEMBLOCK_REGIONS + 2); + ASSERT_EQ(memblock.reserved.total_size, (INIT_MEMBLOCK_REGIONS + 1) * MEM_SIZE + + new_reserved_regions_size); + ASSERT_EQ(memblock.reserved.max, INIT_MEMBLOCK_REGIONS * 2); - /* - * Now memblock_double_array() works fine. Let's check after the - * double_array(), the memblock_reserve() still works as normal. - */ - memblock_reserve(r.base, r.size); - ASSERT_EQ(memblock.reserved.regions[0].base, r.base); - ASSERT_EQ(memblock.reserved.regions[0].size, r.size); + /* + * Now memblock_double_array() works fine. Let's check after the + * double_array(), the memblock_reserve() still works as normal. + */ + memblock_reserve(r.base, r.size); + ASSERT_EQ(memblock.reserved.regions[0].base, r.base); + ASSERT_EQ(memblock.reserved.regions[0].size, r.size); - ASSERT_EQ(memblock.reserved.cnt, INIT_MEMBLOCK_REGIONS + 3); - ASSERT_EQ(memblock.reserved.total_size, (INIT_MEMBLOCK_REGIONS + 1) * MEM_SIZE + - new_reserved_regions_size + - r.size); - ASSERT_EQ(memblock.reserved.max, INIT_MEMBLOCK_REGIONS * 2); + ASSERT_EQ(memblock.reserved.cnt, INIT_MEMBLOCK_REGIONS + 3); + ASSERT_EQ(memblock.reserved.total_size, (INIT_MEMBLOCK_REGIONS + 1) * MEM_SIZE + + new_reserved_regions_size + + r.size); + ASSERT_EQ(memblock.reserved.max, INIT_MEMBLOCK_REGIONS * 2); - dummy_physical_memory_cleanup(); + dummy_physical_memory_cleanup(); - /* - * The current reserved.regions is occupying a range of memory that - * allocated from dummy_physical_memory_init(). After free the memory, - * we must not use it. So restore the origin memory region to make sure - * the tests can run as normal and not affected by the double array. - */ - memblock.reserved.regions = orig_region; - memblock.reserved.cnt = INIT_MEMBLOCK_RESERVED_REGIONS; + /* + * The current reserved.regions is occupying a range of memory that + * allocated from dummy_physical_memory_init(). After free the memory, + * we must not use it. So restore the origin memory region to make sure + * the tests can run as normal and not affected by the double array. + */ + memblock.reserved.regions = orig_region; + memblock.reserved.cnt = INIT_MEMBLOCK_RESERVED_REGIONS; + } test_pass_pop(); From patchwork Thu Apr 25 07:19:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13642908 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 E8C1DC10F15 for ; Thu, 25 Apr 2024 07:20:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FBEF6B0099; Thu, 25 Apr 2024 03:20:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67BB46B009A; Thu, 25 Apr 2024 03:20:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CD996B009B; Thu, 25 Apr 2024 03:20:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 26A0B6B0099 for ; Thu, 25 Apr 2024 03:20:06 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9AC60C048C for ; Thu, 25 Apr 2024 07:20:05 +0000 (UTC) X-FDA: 82047205170.13.B2AB846 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by imf19.hostedemail.com (Postfix) with ESMTP id E02A31A0013 for ; Thu, 25 Apr 2024 07:20:03 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dnXGaJJQ; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.46 as permitted sender) smtp.mailfrom=richard.weiyang@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=1714029604; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=5zCWK1z5+i/ljXs+t2uWpURyf0fwpDKHRDDfVzsjhwA=; b=MpIr7VwLfDVWSsEgWBdz9mixEsX30Oc4z6ajDuodMQzCaAPdzHGxaDsJs+NFHJD9S+PHF7 1EP4mzVpYzgNdVHtD7R6Egj1nYHrENqM5xHxalJ0/qmIVuSTDQxFsMEkc7z1zfMFAY16rJ QPIktqmrNXAfVuREVNpdP6cIFuXSZ4s= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=dnXGaJJQ; spf=pass (imf19.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.46 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714029604; a=rsa-sha256; cv=none; b=IO6+o6kit/bLG/kaZs+UqbzFbIhDAwpVfFdhRdp3RrNcqquyqtFUbKBC3azedqtoqVImBW jFIy4hF3A494K+0m3qIgUT2PuWJPUU9qm7i0r6FEZ2tto1O2BIioh+wFmozFbo5j6keHb1 qIHHcxOwOyud3O6vj8zMRqwkcgq1/Gg= Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-57232e47a81so1258605a12.0 for ; Thu, 25 Apr 2024 00:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714029602; x=1714634402; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=5zCWK1z5+i/ljXs+t2uWpURyf0fwpDKHRDDfVzsjhwA=; b=dnXGaJJQKYnufREwl7eZjqqzffDT2qVjodXBJ3SfVg0cxCSyigjL29/Rer+r3I06Cn wzRywIrl4rPEG3qMgY+Mkhy6MTfk86Q8edD5imYE9bHPFEVd4lvTSBg/CunBPrliQcwz 8GYcL1TxIxJrcdCeSMwZbpIgkAaCXEJYPR18EveLeC51G7Tieo2VvGA4fxbLULm590Cn DfjZGcSYBlQVgLDFRNG0nLaSN8Pd82ZMdCftGwPAoQA5oxsTOQK4KKxbqtay1RBcp2zp gcMPk3DOoDjzpXYT3cNXAdu9a2VQv0DdFtxLOhJTWkSALV7O5Ypl4C6z+yhMbhM7NH2R aiRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714029602; x=1714634402; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5zCWK1z5+i/ljXs+t2uWpURyf0fwpDKHRDDfVzsjhwA=; b=UJ8mPMwNhcw50zZzJ6/4l+DIyPnZyh8VEoOC21h6k9mQvJzfT4/Z/y8++pMZBsTLVt B4mj+/Z2npAxMiH+/UsHVyxtbrtUrUFZzjCV3y/G7hSLyj8rs1TEuouul79+0q6W/q28 usYg0y+0vdtfJoTr7Ov97WcGEMRI5nKvXrlf2oB6xDAJ6s7ZGfSMcD7MdGiag4hHVfGk 14VmTGWSFBEk/CBS95iEPrS1eqkwXfNWYOqPiSxuujRDirfUX+Ta1s4pGtByHb3h5wJD qjhG3k9oQQo19hTmpg3FYwdR3lZVNE/DgGq0r2zbRlQgjS44oBdiG7pdmJxyl1jl791e hNdg== X-Gm-Message-State: AOJu0YyD26CbF+Y+tz7+yFxBG9ku/v1afXLE7EGMTJdsGfvMAVItOJMX Rx3jkVSdeYhCBI7sbD8rYDd0HKst8cYoNOmI0M3qVfrrpQk28EX8pmF7mrHA X-Google-Smtp-Source: AGHT+IG5m5VYgdZb2E2I2KzVYbWjEj3B0o0lHI+6DONkJ6DaVwNCyM5NEEYeFN/On0MfpReTdJYYsA== X-Received: by 2002:a50:9e4d:0:b0:572:2efe:4d14 with SMTP id z71-20020a509e4d000000b005722efe4d14mr1975223ede.10.1714029602169; Thu, 25 Apr 2024 00:20:02 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id bc16-20020a056402205000b005722efd31e4sm1790505edb.29.2024.04.25.00.20.01 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 00:20:01 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [Patch v2 4/8] mm/memblock: remove consecutive regions at once Date: Thu, 25 Apr 2024 07:19:25 +0000 Message-Id: <20240425071929.18004-5-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240425071929.18004-1-richard.weiyang@gmail.com> References: <20240425071929.18004-1-richard.weiyang@gmail.com> X-Stat-Signature: 96d3usodyzk34ft61wrzuxurczie6s48 X-Rspamd-Queue-Id: E02A31A0013 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714029603-766987 X-HE-Meta: U2FsdGVkX1+tpvkQ2VMmQn9jcTa1YhyCbg1ZBke99o4KySjenayWnNvfb8rdNSoJ66KlVEKd8o1H0jbvJ/DDQ2ZPiJIUt5SWwQS4p8B04xtIlnJD/oYquV75NRvjvXneVP+BBP5scFFmriKDZf50ixFEuVO+YU3sdiyFl5xWEvMb1ZM2zu0OrmdyhaDpVXn1h/VGuvv3zRMpeOoW3rXVdCi4oUa2RNMMcxQtq+Pu1YojAr1xa9sTrz015915WCTsCSzH0f8A8TfQ/2uDQX7Yg6hKanjOcJYMLvx2K4XgNGfnFFIfkJH05YqHJNKsr+lEqJqfoPQyLaUkbh2nw1itPYuFHrmksxHX7g0Qcl4UvZequPWYkuMf8NlRH5NHeSDuwXERDf97WdCjKHPj8ZdnoE29pr5pMV45wiBLkQuJjOj3zFUjunMQx53l3SDFbuBkd+mPOgRA75EGoM5UBd6ADxxq0hfHZU1CqCMtmz7p0qP/jTpjZ2PcDCnWJbtR1AzeswVxQt50p/9jtXmNnWr4y+le2BmX0Y7nMxFOIKr8ieTqZ2cLej+p6U5BcMw04RqDXMLc3JfhX9w34iFw/WP5JGwzTD4Dm+q/5TX8/HSJfT6+3Fr3IEDgocsqzZrKI6wVYLofBZNgVUrY5JcBZpCfwOX7uoHLPV/K1mujBTnYdWAWpMqDKOqOfpta1B82WfPL4YRwuYG/gCVGK5XgZDV9+KSASfL43N8yG6/ZAOSQWrOuJeir/W05wbT/R1NTVoJZyWN9WHrQhVMXen0nPtMBlSTZtBcqRR47yolsYPYnGvzJX6VVlROEimfVOggGh0mnl6Uzx4TB+AHe4S5XsmYd9CWbwkho2j8t9VMj/9MXnT2skLHoGvGhFLiixI9TGvfDSvaIEw3gOVPwbpj8QxgX55g77P237AQ/IT0tg0phOpbS8aeKhIZGlnLH7wVFszBVedFbRdLv7bWWV1XWvvt vqBkOPEz 5RDMmbGLNydlseSiTjwFUzkOUZAd1mIMhIp+FZvbnpiB/ehOfmm888laM2Gl9cX1WJhaqCcX6U+HiEcRB8d62luPm2/MpUio5QdjEXAiF0sYFPH6tPXBbPQoKhsgRqZt5cRBSfggJLW1LyJIF6mft2e04xnNVDdvT4qdJR6RTBuLf4FcdcXM7Up/+nfTePWZ3HIzUFx7shH8l2dykKoGRYHTo1r7VkTOV+aEOkE37x2MT7BmNM1qH6CMob4SF4A+ZouQC6Oj8pS7J4usoFpFZxGO/YNTkUp5vbO7Kwe5mTJSuaJcr8B0weid93OOItavfQJmzJPnko3F/BOXedz84Qd3EpKx75PFeeTgVvt+lyGMmhBkfUMx7O8XH4gw+L5iRQc8d2zzy8TOlC4JPNw3V2Rx+zN/CbLhKRET5pEdaRWojG70VdFuhyJpyImcmO4Ije73+bS9X6gcwf6l3EV6SGYDeSD1N6yECPzV08F6TBJz8zpN1hgkrN7KCF+d7zGmspXcS X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In memblock_remove_range, we would remove consecutive regions after isolation. Instead of removing each region from end to start one by one, we could remove those consecutive regions at once. Signed-off-by: Wei Yang --- mm/memblock.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 5a363ef283d0..53e3aa2cd9a2 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -343,12 +343,15 @@ static phys_addr_t __init_memblock memblock_find_in_range(phys_addr_t start, return ret; } -static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r) +static void __init_memblock memblock_remove_regions(struct memblock_type *type, + unsigned long r, + unsigned int num) { - type->total_size -= type->regions[r].size; - memmove(&type->regions[r], &type->regions[r + 1], - (type->cnt - (r + 1)) * sizeof(type->regions[r])); - type->cnt--; + for (int i = 0; i < num; i++) + type->total_size -= type->regions[r + i].size; + memmove(&type->regions[r], &type->regions[r + num], + (type->cnt - (r + num)) * sizeof(type->regions[r])); + type->cnt -= num; /* Special case for empty arrays */ if (type->cnt == 0) { @@ -360,6 +363,11 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u } } +static void __init_memblock memblock_remove_region(struct memblock_type *type, unsigned long r) +{ + memblock_remove_regions(type, r, 1); +} + #ifndef CONFIG_ARCH_KEEP_MEMBLOCK /** * memblock_discard - discard memory and reserved arrays if they were allocated @@ -846,14 +854,14 @@ static int __init_memblock memblock_remove_range(struct memblock_type *type, phys_addr_t base, phys_addr_t size) { int start_rgn, end_rgn; - int i, ret; + int ret; ret = memblock_isolate_range(type, base, size, &start_rgn, &end_rgn); if (ret) return ret; - for (i = end_rgn - 1; i >= start_rgn; i--) - memblock_remove_region(type, i); + if (end_rgn - start_rgn) + memblock_remove_regions(type, start_rgn, end_rgn - start_rgn); return 0; } From patchwork Thu Apr 25 07:19:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13642909 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 18C6CC4345F for ; Thu, 25 Apr 2024 07:20:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98F786B009A; Thu, 25 Apr 2024 03:20:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9150D6B009B; Thu, 25 Apr 2024 03:20:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76AF36B009C; Thu, 25 Apr 2024 03:20:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 495DB6B009A for ; Thu, 25 Apr 2024 03:20:08 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D100F411CA for ; Thu, 25 Apr 2024 07:20:07 +0000 (UTC) X-FDA: 82047205254.22.2A1604D Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by imf10.hostedemail.com (Postfix) with ESMTP id 180A1C0007 for ; Thu, 25 Apr 2024 07:20:05 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=U5xwemTr; spf=pass (imf10.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.167.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714029606; a=rsa-sha256; cv=none; b=QgBz0qtpgu8g93FmzQ9gGFJRgxMaQce40MdarYaRekEi/Pv9cyHtZH7/V90J/V602Hpl8T Osmjolz2HXg81nTDzyfAMrmmHmBF1He92fLjhGTt4r8Nr5ErWRnGgL3CsTqQaWWgxw3fxs yZUZQhF+ExvxFnPsw9hzSiuZU4yL5YE= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=U5xwemTr; spf=pass (imf10.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.167.54 as permitted sender) smtp.mailfrom=richard.weiyang@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=1714029606; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=TgIFUF0hmmq9CpwNL9m6ci3jPkFlVMEzOQ4ZnVVDQOo=; b=l7sklfhGOfpareZv+0JVX9Anh5Ss7xsDcleH6ZU7SpZWOnNn0uYrsMjrbcW23044oDJF3s dgYmF44s1+cderd5LCEJjD5FexBm65apNyBhePck3RyVEjuSupJIk3g1Xyr1PlsMNkX3J4 oJjzL/LbYF+7ZUNq4lMcgFqAXHGtY/U= Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5171a529224so775984e87.0 for ; Thu, 25 Apr 2024 00:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714029604; x=1714634404; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=TgIFUF0hmmq9CpwNL9m6ci3jPkFlVMEzOQ4ZnVVDQOo=; b=U5xwemTrIAyktfF6IKwV4S/64iQioVuNWLDFj6ndoKyyL9AaUpurq4S+D4EJTd7iZx iRxbkiZODO/x0YibpQh6gFzo/xHWpeqQSqKKTCPNQqak5VernFNmc1PsqZr4kgSabWjt Bn9BspWPgkmI3sNVCxy+wsdpNc5WLtbA/sDPl9RkLqOWEf93N/n72sXdYdaNcspYYj/N 37/z/4j0IoQZ6Xw9ChAjOAx1ft7xT9d93PrN6PX+JqbxBm4LYZKH58Ci5xccWC/yKF7I iYjl4ogwuuqByg7LVwPdOwsIiJ0zIFWPXaCmMR+M+rRWRqst7FF6p4dray42rnFoBRsG t3cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714029604; x=1714634404; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TgIFUF0hmmq9CpwNL9m6ci3jPkFlVMEzOQ4ZnVVDQOo=; b=jltKwgX+mHyUo8RAMpl37dvK5waq8efh1e+ZNCrziIKO1TfuKxiAzwy4sWCdTsjqMH XqBrN46JtmIpEHVt/QvvZYoPXHknV4hzvp7CpNKbA1C2/uxWzOgQKZGWv7zFYiMs0IQp AmzitJZGcymomkgSRo/SOijiu3r6mt+0ZTktOPP5e7J67MRFgqP5ciP9dKeQrIqPzcj6 uXQwKFq7bAga42Ghq+//raMjW1QDwY4KTQ7rWtrsjcEnTDM8hqO9iS5TMOp2RonTulOX YQjWqxttc3LeQMcRuTjRDM+GnpayhGNbTVQJ1kO/AU6g7l3eEATed0Ggbppz9u8BAs20 PMPg== X-Gm-Message-State: AOJu0YwvzM6FAqYX+4eLrsXwGBV7mv0H0ilJfdyyLLwhvOzCFBFfyWHg vDNqzSoOIyZWDKXbv+WhjCmensqcZJVimurQ8S+VUrBZqTcHg1hE X-Google-Smtp-Source: AGHT+IE1WslR8V3HI+zRFvwT+IyAxDBcH/noyPKGJLSDNtnmQBYzsgZXkGTwm3oJpKw4d5pEAppZng== X-Received: by 2002:ac2:483c:0:b0:518:c564:1089 with SMTP id 28-20020ac2483c000000b00518c5641089mr3206480lft.52.1714029603878; Thu, 25 Apr 2024 00:20:03 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id qt11-20020a170906eceb00b00a55ab2630c3sm5466198ejb.38.2024.04.25.00.20.02 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 00:20:02 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [Patch v2 5/8] memblock tests: add memblock_overlaps_region_checks Date: Thu, 25 Apr 2024 07:19:26 +0000 Message-Id: <20240425071929.18004-6-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240425071929.18004-1-richard.weiyang@gmail.com> References: <20240425071929.18004-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 180A1C0007 X-Stat-Signature: an8upu5n4bomif9nh8psrwy3it9jxtby X-Rspam-User: X-HE-Tag: 1714029605-86571 X-HE-Meta: U2FsdGVkX19GkgbafhnViuz4eimOaLLhlWtI7F06JkbKrqu8ahpG7mlmscAUSi+6Ond97ywiu1Z3UB65X5avJxj/11MPyZGF9Lqs36IkYuw6HMqtT7Cg6FWufaImpHF6nV/F9cCr0IbUS5Av7iyqI+f3h53mC8MMlYXCsj70SpWCyrEcpIoY1hL67hexRRNN58zTCiAHhFzV+6UELotpBpi0lIlT3ApVIzeancI7H1RQt6hP6CwQGbt4t2GGwvAZilBbo0r20oTd4kguAjqA6w2sscav8QwRBacTxchUOejedE94UlPFvMYy3Zm7Xe6s8BEcfJuQARY0m8Y8qUh3pYRaJUPRs/ru8smg/DjmU2SZb5o5p4v/ggWT9FEzFPN2RC9KYQ2AGCOrEMBJax2U10F2ziXOOdEjsmRcsGQuus1+1rfhu2ZvWY11/YEjUD9mu69zHOdV43YL76iZN5/QXq6aRoQQNFgvdyvNHFA/TETpmJURoid++eoZcPyV/vRP2DyPvUJ8331ExzLPY9OsTND47+7AnXFvYS456VPbUYBW5f9+QWphGJd98W59AzPeeRNvlVHFqC0yWXNrN1oryHqkzWgl8spOF+vMXyYyfb4nKBdoTGCyfRZP+xFTOF785BTGjoOTcoDcz7N+kCx3iB3Bdy9HEo71TMZyuKqalI7HQHLYSGPjkSV3z6wSE/Y0dG/d1utabHbSchFjogbEYT3anG+nWxa39ln380id1fL41jGPS06f3hmbjABupei3/lF1VTf5S52EZ1Ekt+iPmz3oRRMR5cKjDCOCRLiPS35UNy3WK5phgz8KvbeUxWNvlYODvsMhOz40OPLJ0f46lbfcZ2zHifjr7eqEbi55QI9MWrKrcpjeN5NUk2h++9O8nR8vxY9amn7UgzZ0BA048LtuVmhm9Gq6w7IsMciWuutof2LAOgaV20qGc/schTqNZ2aUevarGKPp+QQMqnq LS8OVkOj Xy96tnDwgpHMF5fjIFZDB71fIzqjfExJPZ4g6e9IdLhRxZ3fFsi1VqBKZ70GDB0gjVjZ9GXScKyjwpe/m+xwREuo2d1SGsElclNnii59jbWgd9Arsg9ZMa8tB9kaA7HQ3uLF7V/AqJ7ARtezhvw7VLUaivGq6Y4dpbA5qIgo1NQQV450+AaPATq/U4KQFsBBmxmNbpS5U2RKz8vrnRmTt8TQb+yJSD0Sd7ATiGRYe0/6jsH/GW0n+IG9u2ujBVse08znMoB5bXUfBNrKSq8ojiMPWY6WLE42VPkLCQWBNylPfKXaWg/iHbFzEX9djgKLANL44kc3CLVtw1Kt2Uw5gW7CouqDDUKMgXeiS7DrAH+iB/jcm6mCpdDNzXWP/1aj5rtYx8HOT8tRkOLi5kO0wCywV1QRS1ZE3wlSIDP7/SLsZ2EQh8SN0IJxhmus6Fcz/eanjIJqJjFJaFxDkqQ8kvlcim6OD8V+NbNhc1EX4AV9jyuDA9LIKgKFjfJ+MPm7bhFMbv+I0vT9AW/BYUiS4rp/qxb3l3DoQUc9x7espskqdZeU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Add a test case for memblock_overlaps_region(). Signed-off-by: Wei Yang --- tools/testing/memblock/tests/basic_api.c | 48 ++++++++++++++++++++++++ tools/testing/memblock/tests/common.h | 3 ++ 2 files changed, 51 insertions(+) diff --git a/tools/testing/memblock/tests/basic_api.c b/tools/testing/memblock/tests/basic_api.c index 748950e02589..b4053ceaf832 100644 --- a/tools/testing/memblock/tests/basic_api.c +++ b/tools/testing/memblock/tests/basic_api.c @@ -2261,6 +2261,53 @@ static int memblock_trim_memory_checks(void) return 0; } +static int memblock_overlaps_region_check(void) +{ + struct region r = { + .base = SZ_1G, + .size = SZ_4M + }; + + PREFIX_PUSH(); + + reset_memblock_regions(); + memblock_add(r.base, r.size); + + /* Far Away */ + ASSERT_FALSE(memblock_overlaps_region(&memblock.memory, SZ_1M, SZ_1M)); + ASSERT_FALSE(memblock_overlaps_region(&memblock.memory, SZ_2G, SZ_1M)); + + /* Neighbor */ + ASSERT_FALSE(memblock_overlaps_region(&memblock.memory, SZ_1G - SZ_1M, SZ_1M)); + ASSERT_FALSE(memblock_overlaps_region(&memblock.memory, SZ_1G + SZ_4M, SZ_1M)); + + /* Partial Overlap */ + ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G - SZ_1M, SZ_2M)); + ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G + SZ_2M, SZ_2M)); + + /* Totally Overlap */ + ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G, SZ_4M)); + ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G - SZ_2M, SZ_8M)); + ASSERT_TRUE(memblock_overlaps_region(&memblock.memory, SZ_1G + SZ_1M, SZ_1M)); + + test_pass_pop(); + + return 0; +} + +static int memblock_overlaps_region_checks(void) +{ + prefix_reset(); + prefix_push("memblock_overlaps_region"); + test_print("Running memblock_overlaps_region tests...\n"); + + memblock_overlaps_region_check(); + + prefix_pop(); + + return 0; +} + int memblock_basic_checks(void) { memblock_initialization_check(); @@ -2270,6 +2317,7 @@ int memblock_basic_checks(void) memblock_free_checks(); memblock_bottom_up_checks(); memblock_trim_memory_checks(); + memblock_overlaps_region_checks(); return 0; } diff --git a/tools/testing/memblock/tests/common.h b/tools/testing/memblock/tests/common.h index 741d57315ba6..4c89c92ef25c 100644 --- a/tools/testing/memblock/tests/common.h +++ b/tools/testing/memblock/tests/common.h @@ -40,6 +40,9 @@ enum test_flags { assert((_expected) == (_seen)); \ } while (0) +#define ASSERT_TRUE(_seen) ASSERT_EQ(true, _seen) +#define ASSERT_FALSE(_seen) ASSERT_EQ(false, _seen) + /** * ASSERT_NE(): * Check the condition From patchwork Thu Apr 25 07:19:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13642910 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 93D0EC10F15 for ; Thu, 25 Apr 2024 07:20:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C24C6B009B; Thu, 25 Apr 2024 03:20:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 125E56B009C; Thu, 25 Apr 2024 03:20:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB88C6B009D; Thu, 25 Apr 2024 03:20:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C5DE76B009B for ; Thu, 25 Apr 2024 03:20:08 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7050A411CA for ; Thu, 25 Apr 2024 07:20:08 +0000 (UTC) X-FDA: 82047205296.22.6C2BA51 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by imf10.hostedemail.com (Postfix) with ESMTP id B5F4BC000B for ; Thu, 25 Apr 2024 07:20:06 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nioaf0Xz; spf=pass (imf10.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=richard.weiyang@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=1714029606; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=2EdLBH5AimODvZjB2/ARQXxleA2ZhKpCNLWbEJSJDI4=; b=1XkEimERWjoRv9KmENnM4Cm51aUaqUMp9rHmJ/cbruGf6h8GcDERbWh+UYCZ6mM0g6nAno yPwM/dYV2PIbYIG5Pg1nvNfxK7jogbV4GUhhq6v+TXgi/tVHv0svPIeLhmW0A6p4dWB/Xp oVWZhzaO3X2qNqmqAK7YuxvcXcnQMXQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714029606; a=rsa-sha256; cv=none; b=a/Z6S4gxIcdiFRfbhb8Nc+Tq6NTSnzw24Bgl+k6y2iBBu2oThuuAslsMhEWDB1MwO27gtL 8TyLOzXDdWnyOpe80GUWDfqDbseKdv2Vl9o4tzidaNWIX/zxg0TrY3UqAYhzLsNlw0rNgH S9+I8ExDUwNRvbfylA5tH7MSQL+bnBg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=nioaf0Xz; spf=pass (imf10.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-5723b4eab48so481233a12.0 for ; Thu, 25 Apr 2024 00:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714029605; x=1714634405; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=2EdLBH5AimODvZjB2/ARQXxleA2ZhKpCNLWbEJSJDI4=; b=nioaf0XzWdqc06quIZU2inU3oU6EigW1D/H+YNb2EZR+nZLeUl0+35evDISjFDwdMd iBRXvHfsRlh9LML9FHU6CXl9EpGovgDGWvu/QdH//1gEBgQkltAKTCJ92Q2eXE7cfTik L0or160iuupEE9ZaR7EB7DjyZ/tX2b//F6cX3jy8zcCay7drSUJ+NLzphE2EDDIcmEe3 TQXv73G9Zw9Qb1AgQ8bQYj5EFaUylFI7kkAnOFlDiw17dZfPz2yUv3q23MDEEHCfTn+P 9vFMv8VcimqUHToKeRyXiy/QJJMgTQ4rHYc1wgHrLd4eNVUzubTD0U6UI+ClAJleoxW2 LXXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714029605; x=1714634405; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2EdLBH5AimODvZjB2/ARQXxleA2ZhKpCNLWbEJSJDI4=; b=k4Vfkx3qCRtLmi+oOmmldkqbw9/uYSMkD5yF2yFdjkw+mPRl9oS1DzEsqDoVLj3M3K C0A4WKLPTL29O1Ep0cOaScKijM/GzkgjKc82aZbG4UjtdhxDjM8VxGg7CjcomAPpIkUh J9daa+oaD+bdHyCcDFiEeE95/LCDFFJR2g8O15iVioYvkSWzO7CMLMYX4crEnsl4PjpD PkdamrVKh84qdhcX0+wyGSJK3vZEWQKmamjHJckXYYRbhCXYE4OCG0EtcMVdsllNGi+m R4PnPrYmILakefmyGk4eY9GyPwQctqbO1iCzCNfjbKbSZ+kXkDJWN8vdqEG09/GklaTb ZsHg== X-Gm-Message-State: AOJu0YzyKCT1dgwKv9FHTxW/O9k/mGo6H17cgq1UXGGckVDVuHUsV6Ky rvGTJUl8PxYHhvVJvnBgoyqfLQ8mYAiNC/cZ9p6yN9qa+B+gRsW+kNtJ3wVm X-Google-Smtp-Source: AGHT+IFS/K2gwnITTc6i0LSRJc6wpdQn1YIK+miHy+3ipKic8uYXj5HNMZ4aSddUQUreazhiM6+T7Q== X-Received: by 2002:a17:906:c49:b0:a55:bee5:52bb with SMTP id t9-20020a1709060c4900b00a55bee552bbmr2940481ejf.3.1714029605286; Thu, 25 Apr 2024 00:20:05 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id s17-20020a170906bc5100b00a4660b63502sm9397300ejv.12.2024.04.25.00.20.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 00:20:04 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [Patch v2 6/8] mm/memblock: return true directly on finding overlap region Date: Thu, 25 Apr 2024 07:19:27 +0000 Message-Id: <20240425071929.18004-7-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240425071929.18004-1-richard.weiyang@gmail.com> References: <20240425071929.18004-1-richard.weiyang@gmail.com> X-Stat-Signature: ije58k1511fp9djs7a1uquahsr85g94o X-Rspamd-Queue-Id: B5F4BC000B X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1714029606-311586 X-HE-Meta: U2FsdGVkX1+WMa6Y6DN9XXzc7QV+U5fKpZbyKhaiXdXnhFPvKzzkaH1Bz1ekcB5dy+3VICckjzlhCiqDCmo2rT1+WR86rWCU1eyY69CvZ4ERc639A8MPiktt9dxYhhuqQA8QJMSLeG5am2fFt4S4P/3kYC+kNguRUhcC6NyEqcXd5/7QbwhS0iXkgQDdj95AUZw+Fuv9gmBmk8Rs0pu4klG0fAyjLExfGPFlV2mEV44/PF/hJqrf2EWr6xWb/2FAZCrd8rIZXbI0VB1YY8e+ramieV4WTRmcszIRYq9N/YCph+QGh3KN3XAtynHJmuV2jPallSQnF1fl/AwhCrNg0cq87QCFAifylSU97Ux1kgtpD68HhmhSLg+zOmbUgOiEh2W7GCR/0qF8QoF/yp/x1wzOYsmhVXXE4Ah/XhD5X2KWcPlh1DwzbigvgZptWITw+BDRSJmGoiZvZzez0E910LIDv11LZOPEuOzbbGcCXjO2+EPCm8y8VqAkfJw8HwGOpek3o0MECLJ8okUyJzB4ED5LvdBNB8KRNLXZRcLNDCCayIZRsdr+E0jdKK4kN7dDQnpLNKhnBofG2xMN49ur1EVJwiUM+z4HZVHdENa2kCt4An/csPY7mCM4jhSIi8zolJHaMNq2MNNjunt3p4DTWlNKkr9ZjdyUmLUEU+FDtl5L9aKh3JXLyvlvXMOmjIvV0pOlrjqD1Ayzm8dgfW9MLLap56Qa7LVkymJI7clz3jWL8Zg1tszlKnatRp7t2u0kuxV/BV7ZmizUYITnssaUkvQVTVGGmHcgyGtUyS6URRZv/7Y8SGBshSfyYw8ewKLbSAbaHdpRTsWtQtWevSfYXk+6TxkRvJ3xIzlwbXUPymyLbQ8w+Ok707X6PlH8DxhfyuYGtELGJxK3CuUvph3IYpACIcybRp5r2dqdpRb7rEMeWwlV9iMRPapvhtV7Iz3huh98nCaw3mYInHzYrej BiUplpZj iDvnBYVJ/Z3Jc3YTAVbh4iZJVFmUXehfjfaKLw+sutucS0LUlmJCtZtD9XMyoNy+FCYkZ6NiNhtTlI9/gnY4jRzaMWak46dBFpsi7HpdTiPaklJXPRnkh7s46cnmxz/8IlW+70yQwppOKByc4bqDSZL2HBYTaJhlmnDKZpDZ7bADza23jzRLSy7ase4lmT+k9nTLeTp5GPCrieHoCqM8QUxbHervFEpzg5Mhbem2GAjSln80fhVF0dzT7WrjLPY2bVfN9ikX39wkgcO1LzAt0eJHvioYyS0QP7iU+vXRo21VldEKwRQsLjCnQCCAcfS3KRMSQJxP9dkqlRZvbrR3H3tM+ArLssSwItXmPzmxleUDE7nhG/QlGv0lfvbNXY89vLzSahOTxnKT98JzPJczHBB3kWSg/EbRnzTtc4SMaMI93ZjV+Xvh+v3Fe53qOBkoIoFeXg7RfIXkrHhzk3zJzxcTIWLNmtJgBrH3+Thie+Rm/RXSud/HppqOZ5Uy3VCuUcOkB X-Bogosity: Ham, tests=bogofilter, spamicity=0.146131, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Not necessary to break and check i against type->cnt again. Signed-off-by: Wei Yang --- mm/memblock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 53e3aa2cd9a2..4125506d8af9 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -194,8 +194,8 @@ bool __init_memblock memblock_overlaps_region(struct memblock_type *type, for (i = 0; i < type->cnt; i++) if (memblock_addrs_overlap(base, size, type->regions[i].base, type->regions[i].size)) - break; - return i < type->cnt; + return true; + return false; } /** From patchwork Thu Apr 25 07:19:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13642911 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 B8773C4345F for ; Thu, 25 Apr 2024 07:20:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82EF56B009D; Thu, 25 Apr 2024 03:20:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78B976B009E; Thu, 25 Apr 2024 03:20:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E00C6B009F; Thu, 25 Apr 2024 03:20:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 36CFA6B009D for ; Thu, 25 Apr 2024 03:20:10 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E5EE9C0467 for ; Thu, 25 Apr 2024 07:20:09 +0000 (UTC) X-FDA: 82047205338.03.B9D3E2E Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by imf12.hostedemail.com (Postfix) with ESMTP id 54C5C40014 for ; Thu, 25 Apr 2024 07:20:08 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ky8NsCls; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=richard.weiyang@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=1714029608; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=4L+NbA3Hq/qfgSIUOMT9TI5a3SJ6I+DGvOxbUdHgPRY=; b=OG50tQpWEiEfZHG4CYkCQrPuNMfvf+g3oX77OAa8gCH7OzGF0G6JeEj/0nTFEkv+vQ7e1Q VE7nCOCXHf9ub0mACnQLrjmgtcZUF4b8IEMsMmf5DE+JIML7n+QxGkTLw/TgSJ1ARduv1a r1PH7kZEz4KxqE1dpzTVIdlt/sDjg2k= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ky8NsCls; spf=pass (imf12.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.218.44 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714029608; a=rsa-sha256; cv=none; b=OdTe5McgwcG+2UyIPxaAlmQ5TPo1yShs+/d5PjI0k2wTOh4aHHh9iqXJCYqMuwIBGIXC87 wQCOUgT2QF0ILxQ+1vAv796TR+CMP7FGVnEhQf5GtskgGmasFdQtmpoAdoY7/M36DozyCC WPlQel6jzVvOEnri+gdPLbHGk7fRUvQ= Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a55b3d57277so74235566b.2 for ; Thu, 25 Apr 2024 00:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714029607; x=1714634407; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=4L+NbA3Hq/qfgSIUOMT9TI5a3SJ6I+DGvOxbUdHgPRY=; b=ky8NsClsXHpkK84PQnu5JvRZh+B+6sCIVd+IR/LZPBhfAIAHx4R8y3GFIFgzxGQvTK 7KiqXXiDoreV1ZNPIDUR6eWy2+hMuAh5iqsV1WE/dQJJy6ZPOEKnO36aix0zpHfG+Ibs PG6uiyA7OD61ziidb96Z38Kq8SUZ1NI3pZLBu0H59VFPNA3z43W+YgIqS8FW95BFse1n ii3xNXoLq8SfE5oQSeqWd7aCFxW2V6S540nHLeUT+hZPVsMkOx+bkH1E9Ud9I6fGdEuV iILX6AuTXsbBy2yRDn5SKn/dFxhfGJ150Ae682dyHNz9sPJhpgSVk2YkNHKdHfLu+sfy j2yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714029607; x=1714634407; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4L+NbA3Hq/qfgSIUOMT9TI5a3SJ6I+DGvOxbUdHgPRY=; b=iSB/A1mJ2lnCOh7CGN7T0TzXyKuiDSCwaRvMhIrZekef6NKUvRh/0CKfxTVHJxoshV I64Z4pH1+p/lhbMZreQtizoqKVfCguuGEDWxS+jFi6CsHMdusbxeWR7PDc3GbKzVWRUT VWuBNBHpxzr8pjrGGvuhOVdZfY+akSdQMMgfkj+ehLp64sAkWX5BFpAln9xu9/lG5yQo 2/2xfxeIKxQPHKoMToXBfuciUXRUoARHuBF4xkSPi6JnTIfvD48pDefWlMzKRvarBBUE GrNJw5+XIzXtDCYJqhfYJfQCT1STn0nHWoH2gN6h92fCJ5oFcoONwKjYBF0Q1/V/7X7H aNlw== X-Gm-Message-State: AOJu0YwHTk1wlSWFpzpzyFvX0uEzWCLBzQMyJlK4NrgG+SlF0VeBYAqf XpIbmjsX+ZW8IvMMkNU3U6OsrR5eUMrRRUR0aNERc1XQ+2L+xqV4OxRsf6R9 X-Google-Smtp-Source: AGHT+IFwxB0MCZU2v2XiwXwvIJE9Ao2ip8Y+9MasoIh+AqJLs3iWYKys5vZZ3DGDuTgMbCmz4Nmugw== X-Received: by 2002:a17:906:a38d:b0:a58:7298:fd9c with SMTP id k13-20020a170906a38d00b00a587298fd9cmr2886751ejz.22.1714029606995; Thu, 25 Apr 2024 00:20:06 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id bv9-20020a170906b1c900b00a51c5940247sm9140894ejb.213.2024.04.25.00.20.05 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 00:20:05 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [Patch v2 7/8] mm/memblock: use PAGE_ALIGN_DOWN to get pgend in free_memmap Date: Thu, 25 Apr 2024 07:19:28 +0000 Message-Id: <20240425071929.18004-8-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240425071929.18004-1-richard.weiyang@gmail.com> References: <20240425071929.18004-1-richard.weiyang@gmail.com> X-Rspamd-Queue-Id: 54C5C40014 X-Stat-Signature: d98tsf8d39z4m6agh7ozoojyxnm6exrx X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1714029608-587148 X-HE-Meta: U2FsdGVkX1+SZaAWhTF6kdeIj5Ha9pAERGBM/jmBbpGsCvXqQHayf5WiohBUppi4mJ6otbp7tAV1gpK8tR9UryPnXuFZX9q3INSunAtUwmZ33ZQAmOjqZ/5RNhJ2cmPxLxzoRIUGH47G8j107Zeq0i88UjLvlxCkIaUNtPdad0cU6Hy7RRQcZ0gqjzEgnl54vtyM3moNy2j5uRxVo/ov9T04hxJb7tEDeJbFGs580Dk63BADSI00cgm0KSYLOu2H4J7Bh1mti8/g0cfzMDbCZeJ0ExX9A6NlhBSNMj1jVyhHkS2xZMswY03vyS3p3xeWsd9KzqmwPTGf+/AQd5oCXEPn7FJXDDuNZeL5+yxFFHmNSQXgo2u4HyRybORRaAvSQJRdpEdUKm3AxvtarWW7GbFnkcBUzrHsMDEFBuddoIoEyw7Y8+a+aJhrEdFYT09pWxqkLUuif8iEEuM9v74Hm4DkJ44d/hN0gy6uX0OVQnWpjhDsrQ1KxraafyV3spLr0UTNvjO0EHLvtomUiEZclWZFRr0Z4oPWA6mqMhzV4a/GwvMZR94jOdMO+tM77Ac1Yo4ueJ7SU5KM8FBHOhWr/czgBremsle915hf+5uT6vUa8V42lfuIPxgFAfEE3udVt1HG35JP/2t4vw6gsIcF8kMg+v2Mz9+COvSiaDeHoufIUlijgelJoggL1KJgeEj97f/tDzSravPBFCoofcrZlYM9PmrGuF5D70/eyHuNgxr7hSqHr+docQoqU/0JIx4L0PBs9W+tk+qRmW2VWK7ifEDqBkeSQxMucS2m+nrXHfkhQw7PliTppBrzArLoHndTAUZ5rRU/iZ1pjOjPw0LrtnpcMCN39W6IF/R4llA5uUiCUQzPeUQyv9gDnZU92cYj4aETIZm6ZfpQRKi9b0UqQWXqbF28YQThfRdClaZbU0tBsjPFNFz4jQIwQrjJcxP9NNHiWnJXYRrmEj5+BDm LMjw7wZy vyA+pUtTALIUkyV5fteAp/9XtW5ceJ3eD8gEmJkrXxdQvajydVwOECvbcJh1f1EM6i115yvoyrxstw71kI/hgDPd8nviINM+fCxJ9q3n4Oky5Efp61lF2OnTmtXITklxffFVQHDPevEnBtIOdRDf9zkssEWtQrqQwoTuYY1agb+S11W08LuiElDmtEYgh1bHVRg3xKxx7mwLsZSVGNGM2W9spw0OkSE2DEKQW X-Bogosity: Ham, tests=bogofilter, spamicity=0.000409, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Leverage the macro PAGE_ALIGN_DOWN to get pgend. Signed-off-by: Wei Yang --- mm/memblock.c | 2 +- tools/include/linux/mm.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memblock.c b/mm/memblock.c index 4125506d8af9..9b4fa8fea9a2 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2046,7 +2046,7 @@ static void __init free_memmap(unsigned long start_pfn, unsigned long end_pfn) * downwards. */ pg = PAGE_ALIGN(__pa(start_pg)); - pgend = __pa(end_pg) & PAGE_MASK; + pgend = PAGE_ALIGN_DOWN(__pa(end_pg)); /* * If there are free pages between these, free the section of the diff --git a/tools/include/linux/mm.h b/tools/include/linux/mm.h index 7d73da098047..caf68f5084b3 100644 --- a/tools/include/linux/mm.h +++ b/tools/include/linux/mm.h @@ -15,6 +15,7 @@ #define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a)) #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) +#define PAGE_ALIGN_DOWN(addr) ALIGN_DOWN(addr, PAGE_SIZE) #define __va(x) ((void *)((unsigned long)(x))) #define __pa(x) ((unsigned long)(x)) From patchwork Thu Apr 25 07:19:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 13642912 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 21B3FC10F1A for ; Thu, 25 Apr 2024 07:20:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98C556B0082; Thu, 25 Apr 2024 03:20:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C7DD6B009E; Thu, 25 Apr 2024 03:20:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 71C916B009F; Thu, 25 Apr 2024 03:20:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4ED436B0082 for ; Thu, 25 Apr 2024 03:20:11 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 05990A1F79 for ; Thu, 25 Apr 2024 07:20:11 +0000 (UTC) X-FDA: 82047205422.22.3BAF3E1 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by imf28.hostedemail.com (Postfix) with ESMTP id 6D2E8C0013 for ; Thu, 25 Apr 2024 07:20:09 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BVQ67WuO; spf=pass (imf28.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=richard.weiyang@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=1714029609; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references:dkim-signature; bh=AKYbx6j7ZXYfR5a5p47YlGuC73Kx/pjwrf4JIoPEeH4=; b=q0ULDcI6I/O3WoEMk6rhhSi9ZHZw1Uvr8500ULFe9LocLgaYg6rbKR8kf653ZurUasVZEy TQwruXwbBX+ehbhGFtl6olmR6By1Hi/XBWK4gkUUKV9NATwXVx6h8kzNnXROP+5W1yhahc TUPRlrXo6xf19TNtDihxew5m9oqC6U8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714029609; a=rsa-sha256; cv=none; b=zs4UPBApb3qdZgybHxZPv/NjaLbKo426pckMLnw70HXjM3bW9zo+MB+yqygsoC/Pkm7i7p nc8E/yLzuiNqUNEsAWhKjXAEJQUTpH5vgGtIpjf50FRhmQB2eJjWQilSa8ya5/XpkmZJxi svVsgKUSO4lMrZTgDfI2W6LC6TZRl7Y= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BVQ67WuO; spf=pass (imf28.hostedemail.com: domain of richard.weiyang@gmail.com designates 209.85.208.48 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-571bddddbc2so670924a12.1 for ; Thu, 25 Apr 2024 00:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714029608; x=1714634408; darn=kvack.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=AKYbx6j7ZXYfR5a5p47YlGuC73Kx/pjwrf4JIoPEeH4=; b=BVQ67WuOWyN5SyJ/+L5fpPsH9y/JnP/IiZuTOnEBKJRVdWEOfegN3VNXR1ZZqSBUJF iK40CEQn4zYSkp5r2ujkAywuXDGi1jBqwjMtiNYg7CuCECCy3yVOP31PRKL4g1yM6TSs axDjZeFd35YkZZp9dS0UuK6Lot5+y/gGmJkLSXPmd2cnIX6UipIqivpooQGUkUfuf4lR 07VXJHVIHjzgMlx+UUDDt3KrKMwB7z3ZoOJoYuH1mseXaXbhkhkbSXH0XSeBineAO9qx itCe2oetqUXF4ct54nsUJcrlg6STD0TMw5JT7JzH7jOLvE/qSyUwiMN9qAnIyW3nOLi9 nLqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714029608; x=1714634408; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=AKYbx6j7ZXYfR5a5p47YlGuC73Kx/pjwrf4JIoPEeH4=; b=e5KOLuGxW04WH8ziOsL1kKczVLJHQ0NDGWtIxc9iFNScunZ6SjjL8a8uKxYV6Tocjw 3jNUcLmWMMWTr4XXfijXHWxWsFBYEdMThCUArk6qgixgCrEwbnxSLpIU+HEAisXeN6Zs nr+mWi4N/Ibs9y/zRioxxuEQVarcW40GXrUdECK512CCJPbiA+qd1OhBTqsKI6MQJOS1 Wn2tefVvi5DvSnkKebZYr7V4mQ5pDOi49NMGHteQFrv2H9Jsa5FzOAxKh+ajlH3ivp0X fcVYYY94JbahW2rO/hpRzN/ZTzAGCxW/Mw8nGOvCaXfZq7ZZQbTJ15r2r37NTF8Y25yf TLTg== X-Gm-Message-State: AOJu0Yya8mSPXRCdo3B/8MjwJClt+m4H5+Cgqkl6exuEtAsBDSNUecT1 IlRWIFHjc7PAsKgNbzWoPYCP0tF5oh4sS+gXucHZowzkT6jsm7Ep X-Google-Smtp-Source: AGHT+IHGeYnhhQRHsxGDPViDbhgK3bCGNr0C94MkfrkflHXjmajvh8YEMnGNcUFX3PGBfk26Qm2c9Q== X-Received: by 2002:a50:8a9b:0:b0:568:b622:f225 with SMTP id j27-20020a508a9b000000b00568b622f225mr130177edj.30.1714029608041; Thu, 25 Apr 2024 00:20:08 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id i8-20020aa7c9c8000000b00571c1df911fsm8168031edt.37.2024.04.25.00.20.07 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Apr 2024 00:20:07 -0700 (PDT) From: Wei Yang To: rppt@kernel.org, akpm@linux-foundation.org Cc: linux-mm@kvack.org, Wei Yang Subject: [Patch v2 8/8] mm/memblock: default region's nid may be MAX_NUMNODES Date: Thu, 25 Apr 2024 07:19:29 +0000 Message-Id: <20240425071929.18004-9-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240425071929.18004-1-richard.weiyang@gmail.com> References: <20240425071929.18004-1-richard.weiyang@gmail.com> X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6D2E8C0013 X-Stat-Signature: 19cqhspc1qott1wrznynww7qbtt5ar3e X-Rspam-User: X-HE-Tag: 1714029609-782902 X-HE-Meta: U2FsdGVkX1+EozVj+a8sbqliKDG3bZmRi20fWqXmFk42q22WqisMJ84YXoICe0iAcucCI1XdirTx1R5iADA6RLQ+0QBMtwLqBr1va0N37BOfrXhsGnK6oa6ITDM0/ryZB2lxvlUp9uIMSifmwAJSqG8U92THb0BF94N0Z0IbqwhZBRlRZ561GH8b/9sB1xfS1ZkUunAh9R8o0F29dk5Zl6QllA21ZUm3t1BaBCvBAiB8+LAOgYNwJtEkznYiLIwjFRo5+/auXnHjcK7HxdHXu1ngOCJIvXHadmPh/YKn/ggdEEeE21EtjqktMoarLSEMupmo8rpcXgO05CP9JASk65iRoh12B09I3n+0j5ynsXlFHvBlLY9JY7FfBMcywqijkzS3Ji/9hkG8I9ufYwD02VfiKn3VdfN1n7XVFRlVxavecdmcU8lgDhcvYBGQspGh0FPn6GkKO+9uE3/10Mz4GpJkQ3/vrrgPigz81PfixscTn9aMqNYp+1InzvAC3+OUTK+3rkgmSQ39Cjtn0jdhrfX7PhEPWO2DZSB7/Y3VRnkV2RWDA7r2aDdxhfnlpNAIYaK3H4HtXUje7DjV6p5s5a60guI0iWx+RnCVX2TWcJubFaVNZ3JEjhVzJCjYUy5SnZl/RaHF8WeAtSXK3YQn6G0D7Y8lyq2zSJZ0MkRJCGTtojLvr3IgwkJS6TlJ7D1LhZeS/dgFfqrkywAt+EIBcDHXGButRj+VnV6OA03xmzPG47yWMvwgy38KFKCqo5QelXsbs87cBUOwK06rV/ZDWNtbdK3iYZ1oB+1dDu/kMpaVfLx8iUIhmhJxNQA0KlBTl+WY/yB5HEIQBfc6fLIYP0w4CDZLfYPbCiX2SLCySH2PSZaA9Ab4J3r5o4V4E+9P0bhCLgbY6N8LhfUtCp8ZrLvOTKXrG6wql0u0zM+ukp20RQl6PVRob1hkOcSAOVV8a/HTCtv3oLZydpwi+x4 aHlVkX1n 83eXcQLiyaQPF+TjgbrFUn2eXoh6QiKYECzRIutby0XdLdUNCv1pDy2q7Wl61SS6BIHRM2oUS98HFRGZ6K51mnac6+l77hEOItMsAzWXhBtUtBgh8Uzv0FJSpQIFMS0h7+qS2m+6brirw3jUhdQKAeGB9oYq3Q+XzROR4wI03MXZfytJo6xvASej93vSIcAOeh245ZwQJUnVZrKT92u8cxNHgOsCUKO7P87Q/ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On x86, the call flow looks like this: numa_init() memblock_set_node(..., MAX_NUMNODES) numa_register_memblks() memblock_validate_numa_coverage() If there is a hole, the nid for this region would stay to be MAX_NUMNODES. Then memblock_validate_numa_coverage() will miss to report it. Signed-off-by: Wei Yang --- mm/memblock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memblock.c b/mm/memblock.c index 9b4fa8fea9a2..3f142c787491 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -759,7 +759,7 @@ bool __init_memblock memblock_validate_numa_coverage(unsigned long threshold_byt /* calculate lose page */ for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn, &nid) { - if (nid == NUMA_NO_NODE) + if (nid == MAX_NUMNODES || nid == NUMA_NO_NODE) nr_pages += end_pfn - start_pfn; }