From patchwork Tue May 21 02:39:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13668807 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 34BB7C25B77 for ; Tue, 21 May 2024 02:40:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42B406B0093; Mon, 20 May 2024 22:40:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E37686B009C; Mon, 20 May 2024 22:40:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70A906B009A; Mon, 20 May 2024 22:40:17 -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 3121D6B0099 for ; Mon, 20 May 2024 22:40:17 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id EE7CCA0FFD for ; Tue, 21 May 2024 02:40:16 +0000 (UTC) X-FDA: 82140848832.14.F4EB842 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf09.hostedemail.com (Postfix) with ESMTP id 2D513140006 for ; Tue, 21 May 2024 02:40:12 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="eu3E5L/p"; spf=pass (imf09.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.24 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716259213; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zEBuyZNhF/CL5lPcNah+oRHllxv4MjfsSuOU5w+v1uI=; b=PUysP+WIP33pSh1zsPcgJiqAdBJyZ9QdpMJYevBDHrpMl++6WBzqonDG/y6mfq+prhns9b BTnf6Fi9aNeI7PWTGAn+S0lVNs3gh1sb+4VjuMEAsT1UKQaxQVoy5brC2l4O4oRi5uyiWO /Yf4EeqcVDk9lBGMDm84od/CUQTOpAI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716259213; a=rsa-sha256; cv=none; b=H46KBqQlpk9Bl9iXP4vwh+JDUuQj4F6Gz6uSVoek+N8nZKY2n+vezI8IPPRg8mIF7zvkkg NiGO4/Q3ZsyGoNd23KMptE1TJVDDkePel3MdZtsoTFKyrMpFjhntFDRAl/4bAYrrg7qXhg msW7I3uKlDWmJglCGS1tonqPjwE9Q5s= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="eu3E5L/p"; spf=pass (imf09.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.24 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240521024010epoutp012c418eed776d999d0fd9ecba9e9406b9~RYKiWJ9WL1194311943epoutp012 for ; Tue, 21 May 2024 02:40:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240521024010epoutp012c418eed776d999d0fd9ecba9e9406b9~RYKiWJ9WL1194311943epoutp012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1716259210; bh=zEBuyZNhF/CL5lPcNah+oRHllxv4MjfsSuOU5w+v1uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eu3E5L/pUZoUnW3GZHjjN+T4eiYopRIR47Dc2o2Tc38FgW+ULbYlL8zoZt6D14DiD ixQU3fgmJcYFOzyU8kUKleXa8ZPICIXBDMBLq8fHLrhJE4LRN5CQhvIiJ03umcSfvg l5GQOBJ19AK1N9Mt4RmYFd4oCRSNLF+BPD2TWtnA= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20240521024009epcas1p28bd3d0438a305494443a92e585d320ba~RYKiHHtqm0671506715epcas1p21; Tue, 21 May 2024 02:40:09 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.36.225]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4VjzDn4FC1z4x9QJ; Tue, 21 May 2024 02:40:09 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id 8A.40.09663.9890C466; Tue, 21 May 2024 11:40:09 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20240521024009epcas1p3440f857e3b31b319c270e2d658379383~RYKhd4Ike1250112501epcas1p3y; Tue, 21 May 2024 02:40:09 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240521024009epsmtrp19f0c8de878deda13b3a4e6889ec4b12f~RYKhdLe4_2362723627epsmtrp1I; Tue, 21 May 2024 02:40:09 +0000 (GMT) X-AuditID: b6c32a37-557fa700000025bf-5d-664c09893051 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 0A.54.08390.9890C466; Tue, 21 May 2024 11:40:09 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.104.99]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240521024009epsmtip2409720cc711bae36955b9fba12d29dc8~RYKhSinmk1232612326epsmtip2G; Tue, 21 May 2024 02:40:09 +0000 (GMT) From: Jaewon Kim To: rppt@kernel.org, vbabka@suse.cz, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [RESEND PATCH 04/10] memblock: take a region intersecting an unknown region Date: Tue, 21 May 2024 11:39:51 +0900 Message-Id: <20240521023957.2587005-5-jaewon31.kim@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240521023957.2587005-1-jaewon31.kim@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplk+LIzCtJLcpLzFFi42LZdljTQLeT0yfN4PJ6RYs569ewWXRvnslo 0fv+FZPF5V1z2CzurfnPanFk/XYmi9mNfYwO7B47Z91l99i0qpPNY9OnSeweJ2b8ZvHo27KK 0ePMgiPsHp83yQWwR2XbZKQmpqQWKaTmJeenZOal2yp5B8c7x5uaGRjqGlpamCsp5CXmptoq ufgE6Lpl5gAdpKRQlphTChQKSCwuVtK3synKLy1JVcjILy6xVUotSMkpMCvQK07MLS7NS9fL Sy2xMjQwMDIFKkzIzmg79JSp4KpQxc2Tf9gaGPfzdTFycEgImEjcW+7bxcjFISSwg1Gi98ts dgjnE6PE4zsTgRxOIOcbo8Syfc4gNkjD1CePmSHiexkljh1JgrA/M0rM7U0GsdkEtCXeL5jE CmKLCNhJfJt9AMxmFiiVePvmBFivsECYxLxHX8HiLAKqEmeOTgazeQXsJQ4dfM4CsUteYual 72A3cAo4SMyfspgdokZQ4uTMJywQM+UlmrfOZgY5WkLgJ7vE3J/fmCGaXSTeXjzBBGELS7w6 voUdwpaSeNnfBmXnS1y4+IoJEhI1EgsnGkKE7SV2fZ3BChJmFtCUWL9LH2IVn8S7rz2sENW8 Eh1tQhDVahItzyA+kRCQkfj77xlUi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+7iZGcKBrae1g3LPqg94hRiYOxkOMEhzMSiK8m7Z4pgnx piRWVqUW5ccXleakFh9ilOZgURLn/fa6N0VIID2xJDU7NbUgtQgmy8TBKdXAZPey0vLNyRfl wtu27XTe/tRb8bevprzSzVoblosLrR+WTXBrZZ03geFoEefF6FuH1pl9VZKfdPSQ/xY2jo/r I+cmRrZM9RNS3iH/d/1l68LHe9ZktJ/eonhNZ+lzrttL75kq/xTc9ND8xuaM4EUC0sXP5gTu Krl5TLJ3/4c3jLut/lnf2+VvPE/g7OfITcudNjz9qpf2b/3hhMxAidW77+v3Fjy038DyJLGp 34TvXxjDmxPszCJ3Cr96cG6sarAQb5IX39y9Le4z56SJK5WsH3/eopJ0e34gD9sDWbsF+x55 95yZsVpy9/bHp29vWz7BtK/l75qOgxPsNh0zeHMjYHds56epH35zXP7wVWWK6rw2JZbijERD Leai4kQAvBDQM+MCAAA= X-CMS-MailID: 20240521024009epcas1p3440f857e3b31b319c270e2d658379383 X-Msg-Generator: CA CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240521024009epcas1p3440f857e3b31b319c270e2d658379383 References: <20240521023957.2587005-1-jaewon31.kim@samsung.com> X-Rspam-User: X-Stat-Signature: ppm46qzgrdazyh5cafwgc8ni5ebs6wda X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2D513140006 X-HE-Tag: 1716259212-841765 X-HE-Meta: U2FsdGVkX1+PA5PqVhkP0N2hQrAFnVcXDzUyI6WYQt1WPwR9zCeig4N1PBjUAiAkHv4JVTPggT54Ham7mTLWH5hCylZcHO9uS/HTpsH6ARzJf3SKJHR0KHuilN01T7fgIjvntgz2mH6eGBfNP05y50HAH+7TbsNXLIHEDy4eGQWNYUgLWKh3uYoNc2yFtBQvwIiDpgbZeGDY1AWiJBHh5S37fbJhM/xdqPBwVSlB3N+097PmU1n76YrLG4cj7lFYvmCr2tYE8Ju+eZqg2xCCo1hkPx08ta2imt/ob0+gNk9v2kXl/Rk5Nf+6boBibJBNO4R43UnWeo5/ljhgRZck3qss4HZRIJiN5LotQYGSeG6buArxw0t2HcyqnfPX5xp1VJjuLB+SLlnjT6qwYTBfqFxh61YgeG9ke6AoQ82qpBM2MTBUx/z5XOb+ZQDUCT5zxr4QK+dbrJiHuKmWTgpT+o/E+jZxAMXBRd7fGWkD3iyhYW8otyB3fx539bi7rMWV9hMiHn1e4+dC5Oisn8GZ+HP8bqkTMEcQm/BkTqH8YyOAsXO+n0J0NYBPTEQOzeYlC6WFYmJO571bWNayxEz1Ec3HPH/0VEQ4w2ObFDx/xSP/1yWplnv3MzAI2Be21QbzWJd5HXQ/dGzFcztINrncAD7wXesIGXv+U+IlEZdEpu+CsU0tm4k43DWhsiOpE/bymr+NkK5+UdDA2NQiukwfYtOiSl5whpU6zCH1E0xg7f7nHItDVculO2iUW0/AqB5n4ocZKdJBrZ+72MDvN1qnunAHSuy3K+P+mn7tku37VVeutpoiWdHQ6Jb7Dc+vJApngwNfhp7UMbCH+0X6BfGJWiP1iMKVNQIJgBrg6eNZ3mph+X/aWRrsdCvXtE/ZAItZrEoJSys2nifFfUq6YKD/t2b9+bUEVmHQlkUPZ0S23H5lMzZ1Ys7oREj4rvlvn6Udn2Ip1r0Nyz9aMXi7/hH DKkJvj4c fPK+7aRoB4CgIoC+lWbPT3UyhFt4D0yN3iNsgryidMn99xSjVufjLbLqF8b5J6BCynaLT2OKYkw99B5RZRtSMvZGJBQYOD1zr8Pfz5lOwTx32vSqHDB9aAWiQ7kqWneGxZ6Et0m2Dr7h7sJQGd3DIEHPpsbP3da5FqGJG 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: There is case where reserved regions overlapped with already checked as unknown regions. To get more information of the name, size, so far we allowed only regions which are exactly matching with or located within the unknown region. For a region intersecting an unknown region, we did not take and just showed that duplicated information. So total size was not perfect. To fix this, let's allow to take even the intersecting region. Signed-off-by: Jaewon Kim --- mm/memblock.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 4a0506e14025..9b68ddc4af5e 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2081,20 +2081,54 @@ static bool __init_memblock memsize_update_nomap_region(const char *name, phys_a for (i = 0; i < memsize_rgn_count; i++) { rmem_rgn = &memsize_rgn[i]; + /* skip either !nomap, !unknown, !overlap */ if (!rmem_rgn->nomap) continue; if (strcmp(rmem_rgn->name, "unknown")) continue; - if (base < rmem_rgn->base) + if (base + size <= rmem_rgn->base) continue; - if (base + size > rmem_rgn->base + rmem_rgn->size) + if (base >= rmem_rgn->base + rmem_rgn->size) continue; + /* exactly same */ if (base == rmem_rgn->base && size == rmem_rgn->size) { memsize_get_valid_name(rmem_rgn->name, name); return true; } + /* bigger */ + if (base <= rmem_rgn->base && + base + size >= rmem_rgn->base + rmem_rgn->size) { + memsize_get_valid_name(rmem_rgn->name, name); + rmem_rgn->base = base; + rmem_rgn->size = size; + return true; + } + + /* intersect */ + if (base < rmem_rgn->base || + base + size > rmem_rgn->base + rmem_rgn->size) { + new_rgn = memsize_get_new_rgn(); + if (!new_rgn) + return true; + new_rgn->base = base; + new_rgn->size = size; + new_rgn->nomap = nomap; + new_rgn->reusable = false; + memsize_get_valid_name(new_rgn->name, name); + + if (base < rmem_rgn->base) { + rmem_rgn->size -= base + size - rmem_rgn->base; + rmem_rgn->base = base + size; + } else { + rmem_rgn->size -= rmem_rgn->base + + rmem_rgn->size - base; + } + return true; + } + + /* smaller */ new_rgn = memsize_get_new_rgn(); if (!new_rgn) return true;