From patchwork Mon May 29 14:40:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13258661 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 A66E8C77B7E for ; Mon, 29 May 2023 14:24:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CCE5900003; Mon, 29 May 2023 10:24:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 27D93900002; Mon, 29 May 2023 10:24:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 145AE900003; Mon, 29 May 2023 10:24:30 -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 04D6D900002 for ; Mon, 29 May 2023 10:24:30 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CD7E240227 for ; Mon, 29 May 2023 14:24:29 +0000 (UTC) X-FDA: 80843513058.04.82A29A6 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf30.hostedemail.com (Postfix) with ESMTP id F2C7380015 for ; Mon, 29 May 2023 14:24:25 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685370268; 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: references; bh=/2MaV0KNaymjWa/QmfNWdkHqutIHDLmXnraiPd+bz3w=; b=DavcJiLqEOohu2j8FN1h8zfBR9PmjvJMD2AlicuKjda2AVhUQr5jVzlxRE0MgPawvu8bxk nVEpu6HZfTIuC2o/JKP1vFMztafh7qF2uP9w/m9jP/MDIpIUJZStPSJtAWCFCLSHMpGvgr i66lUNpoBbxx7JRQTsnhgERULJUVToI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685370268; a=rsa-sha256; cv=none; b=RqkmDDpBhm6CAMpKPIGVaIMs3XWbkz1qg1AeTb+iP8yWhIslKTNLL5xbKR5nVzz91EoDyj DSJ8Ier1Grgw7/1IPwB/l3F9a28iok6Zyk2MkBiwcz14d8crWGNhtN3/NQXnItXwI0iQsY fST6G1vUR5/7yQeMjcmnEO0Q9mF5H2k= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QVHmh030kzLmPC; Mon, 29 May 2023 22:22:44 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 29 May 2023 22:24:17 +0800 From: Kefeng Wang To: Andrew Morton , , CC: Kefeng Wang , Baoquan He Subject: [PATCH -next] mm: page_alloc: simplify has_managed_dma() Date: Mon, 29 May 2023 22:40:22 +0800 Message-ID: <20230529144022.42927-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: F2C7380015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4fyfispxkpjp4dysei5diixxsmgi8b96 X-HE-Tag: 1685370265-324584 X-HE-Meta: U2FsdGVkX19av4eg/xj77lKKJUx8LwzMbEsnoyFcWXwxCUOc6T4NAx5+a5OxNLFkeyrfDJwKXlGyW7voYlfgLV48yU0jiMPczRRSH/7CCVlbt7eruhyL2K24imNvqRjj00FFs0L6ZnmQ2YhoZ7HzZVKLqOPyKBcw5n1CQ/VrvNEYJEf47aendTB2YeK/fHJNSRBPXVt/t84en+bIx2ROzAPanbm/vh1a9aA5OhB6Gu5x2BNcuDKfK0wE4syC8IuykRsRDn4jwYGngGc/3UJbYRhcVI+yICx8/y9fv3qV4kyYNCvHBuQOuiny42Yyay5khbcXdLXjkROezURMcMpdgOC2z+tKQ1vkCuq2f0m+5BCMKiVaBQmpyUeGcQtHsoIseQ3MOHASsDOfQ18ytm8Czw5wwb9dDnfgreaCSXUlEb1cIjm6GevdRcguLhFwRGxn6f4yh0ZnpUl/365Dcnpd1uaO1kC64PtNctI9hBwTuzf3tvbd3u/jYd1mB3/082Tm9PCOvRq4jcHnW0qodGG3bKHSvqwYe/ZadGDdvXvvwSuXCN8NXJqwwNVbXfCcXfz7rsVBQLUlPnra68c84x1tEefd5QKjpPNzUGTDusK/A7Pmu0IHYSwmhj29b7BhUNwt+exg136+ofFguRIYyPTDn0ZwUHCgwHQfRnAcRrrmfzn+CNk0o5pT6aOaBHgFc4qQiLV/iuEcTn62veeaszIR7HzgCv4b6rKcmBRU4aaTni1RnusT+f5F6Omxek5AKwm40303nC5WN4EeIq/VXZZghovBIasu3KB+JgexE7qF8NHcMGAqHYlIh1GFOcWBlF4yjOwu+jtEbnCi1UIftSA0x+/PSzJMNrbdmbSdn76uOv3kVcNUGQQCmqouqsXO7P9A4N0ubMrNFKktKoR75jOPvnNrF0EU9Wc4MjqOyWXODmy553jqq4xpkjKqnClqQ8jiHh9GNkY37i1TXXFP/yL UD6RlYLW cfgPneYnh++Ifqur3TXz+QlwRK7jI1zYkRvNGKz5A9OFZ9ETW9DXZldujlNC+0H4fa3I/rMDILyuSj1KFRO34N1qQM5h7Kvv7kTOC9cB/gz9/AOi6KxJTaJV97E1k1XKx3yWuhvuDW2o9vFdjKXgrAOQHACiKnynDtR0dTd/TNW0zZRfALulqF+xs87/VNjNWCtKr4+6g+kdMHZSOP1RdAZbJsA== 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: The ZONE_DMA should only exists on Node 0, only check NODE_DATA(0) is enough, so simplify has_managed_dma() and make it inline. Cc: Baoquan He Signed-off-by: Kefeng Wang --- include/linux/mmzone.h | 21 +++++++++++---------- mm/page_alloc.c | 15 --------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 5a7ada0413da..48e9fd8eccb4 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1503,16 +1503,6 @@ static inline int is_highmem(struct zone *zone) return is_highmem_idx(zone_idx(zone)); } -#ifdef CONFIG_ZONE_DMA -bool has_managed_dma(void); -#else -static inline bool has_managed_dma(void) -{ - return false; -} -#endif - - #ifndef CONFIG_NUMA extern struct pglist_data contig_page_data; @@ -1527,6 +1517,17 @@ static inline struct pglist_data *NODE_DATA(int nid) #endif /* !CONFIG_NUMA */ +static inline bool has_managed_dma(void) +{ +#ifdef CONFIG_ZONE_DMA + struct zone *zone = NODE_DATA(0)->node_zones + ZONE_DMA; + + if (managed_zone(zone)) + return true; +#endif + return false; +} + extern struct pglist_data *first_online_pgdat(void); extern struct pglist_data *next_online_pgdat(struct pglist_data *pgdat); extern struct zone *next_zone(struct zone *zone); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e671c747892f..e847b39939b8 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6613,18 +6613,3 @@ bool put_page_back_buddy(struct page *page) return ret; } #endif - -#ifdef CONFIG_ZONE_DMA -bool has_managed_dma(void) -{ - struct pglist_data *pgdat; - - for_each_online_pgdat(pgdat) { - struct zone *zone = &pgdat->node_zones[ZONE_DMA]; - - if (managed_zone(zone)) - return true; - } - return false; -} -#endif /* CONFIG_ZONE_DMA */