From patchwork Tue May 21 02:39:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13668806 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 F3A1FC25B7B for ; Tue, 21 May 2024 02:40:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20BC06B0083; Mon, 20 May 2024 22:40:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9AD46B0099; 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 457B26B0098; Mon, 20 May 2024 22:40:17 -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 C98006B0088 for ; Mon, 20 May 2024 22:40:16 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 84F281A0B05 for ; Tue, 21 May 2024 02:40:16 +0000 (UTC) X-FDA: 82140848832.09.DF6E152 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf05.hostedemail.com (Postfix) with ESMTP id BA30E10000A for ; Tue, 21 May 2024 02:40:13 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="bP52x+/A"; spf=pass (imf05.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=jaewon31.kim@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716259214; a=rsa-sha256; cv=none; b=sPRdgaLR5iKk1uUzqNqlnxpNaCFc8Gu0ANr/KxUH6lfcydEFhPTMLJ4MATfHikeS3Bgz1N 30CZvJEH721iWbgrdekPph4PA546HC8Xud3HPvq6mx1N/WmTEme2XUldHaygLjOeQTP6WZ 5uKqcttkvNa1GP2DWyIZ4aSSIgEsWQ0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="bP52x+/A"; spf=pass (imf05.hostedemail.com: domain of jaewon31.kim@samsung.com designates 203.254.224.34 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=1716259214; 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=yVf68Cj1nmtMbTxmkx6CIgy96BRosJN2TQP/FPuQu/8=; b=lXUvj++ztLHzM9or8/AwSNsDumZ/Cv5OIE71Wx8fR921hYW+NMgTRtJ/Y744MgDGnXz7C9 YlRQnkAadRbEb1s3XJEnMQvkOqHSiEjbks+jUZltEHdYO3f56sx6ZJUMMoSxRrLJ5+FgQQ yazvGr/Qe9Ije5ZVbv7ial9zNlGc6bI= Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20240521024010epoutp04a613696e1d32133585549f7b8c49b075~RYKi2zzGt1821818218epoutp04r for ; Tue, 21 May 2024 02:40:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20240521024010epoutp04a613696e1d32133585549f7b8c49b075~RYKi2zzGt1821818218epoutp04r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1716259210; bh=yVf68Cj1nmtMbTxmkx6CIgy96BRosJN2TQP/FPuQu/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bP52x+/ApNVHBIzFM/4oYwo//UvPFD67XoOXBDj31FTLgcP111sQ/RlcWu9Fkgyam W9WMEnnmdph6iZBCEI0t1tEnA6mabO7o9BBdeeLew/1v/dSIjx07amZdjIlN/FXUQv ZbFtnW6NTHxOJtXyygLGARqqE3L9NVbhm6hM/BKM= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20240521024010epcas1p495284369abe490f8d94fdd6adcef2e70~RYKiZSNF71520715207epcas1p4A; Tue, 21 May 2024 02:40:10 +0000 (GMT) Received: from epsmgec1p1.samsung.com (unknown [182.195.38.240]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4VjzDn6DFBz4x9Q7; Tue, 21 May 2024 02:40:09 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmgec1p1.samsung.com (Symantec Messaging Gateway) with SMTP id B1.13.09696.9890C466; Tue, 21 May 2024 11:40:09 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240521024009epcas1p15a3290b675ee66339033c185a5a8c00b~RYKhv5DeV2349123491epcas1p1d; Tue, 21 May 2024 02:40:09 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240521024009epsmtrp29f58dea47f5a6d9d50601a9ccaf99022~RYKhvKn8k2496224962epsmtrp2m; Tue, 21 May 2024 02:40:09 +0000 (GMT) X-AuditID: b6c32a36-7a9f9700000025e0-4b-664c09895e29 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 9A.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 20240521024009epsmtip29f70c066144ebfba9efa858ec7c443e2~RYKhlFy_t1233912339epsmtip2F; 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 10/10] memblock: support memsize reusable to consider as reusable Date: Tue, 21 May 2024 11:39:57 +0900 Message-Id: <20240521023957.2587005-11-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+NgFupgk+LIzCtJLcpLzFFi42LZdlhTT7eT0yfN4OR9PYs569ewWXRvnslo 0fv+FZPF5V1z2CzurfnPanFk/XYmi9mNfYwO7B47Z91l99i0qpPNY9OnSeweJ2b8ZvHo27KK 0ePMgiPsHp83yQWwR2XbZKQmpqQWKaTmJeenZOal2yp5B8c7x5uaGRjqGlpamCsp5CXmptoq ufgE6Lpl5gAdpKRQlphTChQKSCwuVtK3synKLy1JVcjILy6xVUotSMkpMCvQK07MLS7NS9fL Sy2xMjQwMDIFKkzIzvi0YCZ7QZdURc/uC2wNjG9Euxg5OSQETCSmL5/N0sXIxSEksINRYtrt 24wQzidGiSOn5rJBON8YJQ7un88O03LxWTMrRGIvUGLlNqiqz4wSB6Y+B6tiE9CWeL9gEiuI LSJgJ/Ft9gEwm1mgVOLtmxPMXYwcHMICURKn95uAhFkEVCXeXD7CCGLzCjhIdH+5wAaxTF5i 5qXvYCM5geLzpyxmh6gRlDg58wkLxEh5ieats5lBbpAQ+MkusfrYRUaIZheJS2+7oa4Wlnh1 fAuULSXx+d1eqAX5EhcuvmICuUdCoEZi4URDiLC9xK6vM1hBwswCmhLrd+lDrOKTePe1hxWi mleio00IolpNouXZV1YIW0bi779nUCUeElNXJ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wmGtp7WDcs+qD3iFGJg7GQ4wSHMxKIrybtnim CfGmJFZWpRblxxeV5qQWH2KU5mBREuf99ro3RUggPbEkNTs1tSC1CCbLxMEp1cC068Zstxnt /dPPHGq8XygSeP7PjQN/898d+JK5y/6v1Kk2Dqk7Ofs2vmz6VhW5eCuHhXaNnUne7K6eso2V 0xudXj7cUb5vbdqkWZKbH6mLL74kMHPTScH9h/98yVih2ibEJh33dSVfxjLxhJ8yd95oNn1h jXG51v/4v+gn2Vn1E26eipm0sofLYNHSxV8f5BTLOVvPe7Ox9M7EhMgHxQtcbrYx7kpzndD5 zOlbEpP45Jc8MYFq0+o3rmNK6zP2Kti5ckdV6z4d0cfF7sYR22zXZQiw5Uw4VHTkodwi8W3J p17IGvi1bfz84qZTcVRL2t8pHZO/C6RduL/9VN7tj9w/5EpKHhbXXLj2YIKMw+KZhUosxRmJ hlrMRcWJAAbDn7PiAgAA X-CMS-MailID: 20240521024009epcas1p15a3290b675ee66339033c185a5a8c00b X-Msg-Generator: CA CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240521024009epcas1p15a3290b675ee66339033c185a5a8c00b References: <20240521023957.2587005-1-jaewon31.kim@samsung.com> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BA30E10000A X-Stat-Signature: 8bebh1srkagmqoxtdinu8pktiaazfa6z X-HE-Tag: 1716259213-633073 X-HE-Meta: U2FsdGVkX1/c+CAr0wFAknoTRZuqMFi3TIPJkFPY9BNaPb7eLbnYlSYinib5kzGue7m01p/NdKRE+f2t9MP37Zb2Q9GR9O8RS5isjl8/n3RV3KyoQcEar3Iyusz19owkzjk9kSztIdL9lFwGLFbxPYhHsymovsqGltTXl8BBUI2q1vLuJdYtsSDh1aTx+9LnUeKA51dXYcCjaPejilf/Hdf2D2oZbS4her6/XcyOuQey7/MdXi/KQUQft6bsgTaCn2Me+TFGSxs2YOf5Bn9t/zLXQzPzfJehlwnm8vz7VFB0HK0vHMRmhywxEvLaAJj7lWanxFKg/3zg9bI6IcH8knODTaijtT5V5ggRA9KqXbHjtDPrEOEu3oxZ2nPueT6FJGfsNxdP/1iskF0ky+rMm+JC8QkBVJ94vigHQDnvj7IvTZwQ68xSbhPeLNtQAfq7PnJW4axL6PVfpU+Azp1mBaTzEX7Ie32DdNM9Na7MZd+nbuTdvxlALU+JX5Y+hQz4OAcKthgX7ca3NNnou5gbFzw0dyu1UGTaCqCNP/52Z5gfZlN0fnrlntJjPvk27167Q0jV1CUTRR6qR7idOVs52p2mFYtU3FHcP6f54iegSHTaVRiBMxH/nqq8rn9RZ56yDRXl/OU5whwe8yASd3lvwR9Guj549rDj2Lciv0CLRvX+VoVCsoIuA8YvtoWWDmIT0BVRMBHyGFpGB3gjobyBEFuK9RlrIUg2CHCN8dBCJWV5Rs+bcRIuZx+rkr9/lpHFiZN6LUugFC+ebp0jwhgvoiA5HOE6XAQaJq9yXNvi7RclubEdgxVRVo+t6qAUzHJz28YuUVH7GjYU7FifVRMr7f6GUkJQyNtfnxSPJ5f7SWRbjAk3JflZAYYJesPlGOZDabBhjrRBwXKe6VhnYFuZ7QVTnAeJ2RlCMmdQc5i4p7vvxMe0xGBK8IanHyTdgUOB1tomD2kRtirGMLlViHb Yb761bwt S2BMFXspaFE/o08zyequiio33VTYChQdWrNcC6n8tLd2b+wvo+tFBDpHr5bcHjBTfagNH+HTwJ45m26aHEFJnUpw/QB5YaS9D4r/vgS9S7GvdTnaGo0hM2DyflajgHehDE8iVWN+G9DWQ3OPjzOdt2lCdw/O3xngQaZl4 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: Sometimes we'd like to include some memory region as reusable even though it is actually not CMA type. In that case, add reusable in its device tree description, then memsize will consider it is reusuable and add its size to the system total memory size. Signed-off-by: Jaewon Kim --- drivers/of/of_reserved_mem.c | 3 +++ include/linux/memblock.h | 2 ++ mm/memblock.c | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index ece678e07304..7aedac213995 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -468,6 +468,9 @@ void __init fdt_init_reserved_mem(void) memblock_memsize_record(rmem->name, rmem->base, rmem->size, nomap, reusable); + if (reusable && + !of_flat_dt_is_compatible(node, "shared-dma-pool")) + memblock_memsize_mod_reusable_size(rmem->size); } } } diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 7ab8b59bfbc1..0aa6202a7a6a 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -626,6 +626,7 @@ extern void memblock_memsize_mod_kernel_size(long size); extern void memblock_memsize_mod_memmap_size(long size); extern void memblock_memsize_kernel_code_data(unsigned long code, unsigned long data, unsigned long ro, unsigned long bss); +extern void memblock_memsize_mod_reusable_size(long size); #else static inline void memblock_memsize_record(const char *name, phys_addr_t base, phys_addr_t size, bool nomap, @@ -639,6 +640,7 @@ static inline void memblock_memsize_mod_kernel_size(long size) { } static inline void memblock_memsize_mod_memmap_size(long size) { } static inline void memblock_memsize_kernel_code_data(unsigned long code, unsigned long data, unsigned long ro, unsigned long bss) { } +static inline void memblock_memsize_mod_reusable_size(long size) { } #endif #endif /* _LINUX_MEMBLOCK_H */ diff --git a/mm/memblock.c b/mm/memblock.c index 2fe0dc2575c5..a20d60d3bb40 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -2066,6 +2066,7 @@ static unsigned long memsize_code __initdata_memblock; static unsigned long memsize_data __initdata_memblock; static unsigned long memsize_ro __initdata_memblock; static unsigned long memsize_bss __initdata_memblock; +static long memsize_reusable_size __initdata_memblock; static bool memblock_memsize_tracking __initdata_memblock = true; void __init memblock_memsize_enable_tracking(void) @@ -2117,6 +2118,11 @@ static void __init_memblock memsize_get_valid_name(char *valid_name, const char valid_name[val_size] = '\0'; } +void memblock_memsize_mod_reusable_size(long size) +{ + memsize_reusable_size += size; +} + static inline struct memsize_rgn_struct * __init_memblock memsize_get_new_rgn(void) { if (memsize_rgn_count == ARRAY_SIZE(memsize_rgn)) { @@ -2716,6 +2722,7 @@ static int memblock_memsize_show(struct seq_file *m, void *private) etc -= memsize_code + memsize_data + memsize_ro + memsize_bss + memsize_memap; + system += memsize_reusable_size; sort(memsize_rgn, memsize_rgn_count, sizeof(memsize_rgn[0]), memsize_rgn_cmp, NULL); for (i = 0; i < memsize_rgn_count; i++) {