From: Yajun Deng <yajun.deng@linux.dev>
To: 21cnbao@gmail.com
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
song.bao.hua@hisilicon.com, anshuman.khandual@arm.com,
corbet@lwn.net, bhe@redhat.com, ardb@kernel.org,
thunder.leizhen@huawei.com, rostedt@goodmis.org,
kim.phillips@amd.com, rdunlap@infradead.org,
peterz@infradead.org, akpm@linux-foundation.org, bp@suse.de,
paulmck@kernel.org, robin.murphy@arm.com,
m.szyprowski@samsung.com, hch@lst.de, will@kernel.org,
catalin.marinas@arm.com, petr@tesarici.cz
Subject: Re: [PATCH] dma-contiguous: support per-numa CMA for all architectures
Date: Tue, 16 May 2023 09:55:46 +0800 [thread overview]
Message-ID: <0b4c1395-1884-c08d-2f8e-3847ec454886@linux.dev> (raw)
In-Reply-To: <20230512094210.141540-1-yajun.deng@linux.dev>
Hello, Barry
This patch changed the caller of dma_pernuma_cma_reserve() from
bootmem_init() to dma_contiguous_reserve(), do you think
would there be something wrong?
On 2023/5/12 17:42, Yajun Deng wrote:
> In the commit b7176c261cdb ("dma-contiguous: provide the ability to
> reserve per-numa CMA"), Barry adds DMA_PERNUMA_CMA for ARM64.
>
> But this feature is architecture independent, so support per-numa CMA
> for all architectures, and enable it by default if NUMA.
>
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> ---
> Documentation/admin-guide/kernel-parameters.txt | 2 +-
> arch/arm64/mm/init.c | 2 --
> include/linux/dma-map-ops.h | 6 ------
> kernel/dma/Kconfig | 6 +++---
> kernel/dma/contiguous.c | 8 +++++++-
> 5 files changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 56d9458276a6..ac0002b2e323 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -692,7 +692,7 @@
> kernel/dma/contiguous.c
>
> cma_pernuma=nn[MG]
> - [ARM64,KNL,CMA]
> + [KNL,CMA]
> Sets the size of kernel per-numa memory area for
> contiguous memory allocations. A value of 0 disables
> per-numa CMA altogether. And If this option is not
> diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
> index 66e70ca47680..d560aef6aafa 100644
> --- a/arch/arm64/mm/init.c
> +++ b/arch/arm64/mm/init.c
> @@ -410,8 +410,6 @@ void __init bootmem_init(void)
> arm64_hugetlb_cma_reserve();
> #endif
>
> - dma_pernuma_cma_reserve();
> -
> kvm_hyp_reserve();
>
> /*
> diff --git a/include/linux/dma-map-ops.h b/include/linux/dma-map-ops.h
> index 31f114f486c4..7af9949828ff 100644
> --- a/include/linux/dma-map-ops.h
> +++ b/include/linux/dma-map-ops.h
> @@ -168,12 +168,6 @@ static inline void dma_free_contiguous(struct device *dev, struct page *page,
> }
> #endif /* CONFIG_DMA_CMA*/
>
> -#ifdef CONFIG_DMA_PERNUMA_CMA
> -void dma_pernuma_cma_reserve(void);
> -#else
> -static inline void dma_pernuma_cma_reserve(void) { }
> -#endif /* CONFIG_DMA_PERNUMA_CMA */
> -
> #ifdef CONFIG_DMA_DECLARE_COHERENT
> int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
> dma_addr_t device_addr, size_t size);
> diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
> index 6677d0e64d27..79f83091e3a2 100644
> --- a/kernel/dma/Kconfig
> +++ b/kernel/dma/Kconfig
> @@ -140,10 +140,10 @@ if DMA_CMA
>
> config DMA_PERNUMA_CMA
> bool "Enable separate DMA Contiguous Memory Area for each NUMA Node"
> - default NUMA && ARM64
> + default NUMA
> help
> - Enable this option to get pernuma CMA areas so that devices like
> - ARM64 SMMU can get local memory by DMA coherent APIs.
> + Enable this option to get pernuma CMA areas so that NUMA devices
> + can get local memory by DMA coherent APIs.
>
> You can set the size of pernuma CMA by specifying "cma_pernuma=size"
> on the kernel's command line.
> diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
> index 6ea80ae42622..26a8e5365fcd 100644
> --- a/kernel/dma/contiguous.c
> +++ b/kernel/dma/contiguous.c
> @@ -128,7 +128,7 @@ static inline __maybe_unused phys_addr_t cma_early_percent_memory(void)
> #endif
>
> #ifdef CONFIG_DMA_PERNUMA_CMA
> -void __init dma_pernuma_cma_reserve(void)
> +static void __init dma_pernuma_cma_reserve(void)
> {
> int nid;
>
> @@ -153,6 +153,10 @@ void __init dma_pernuma_cma_reserve(void)
> (unsigned long long)pernuma_size_bytes / SZ_1M, nid);
> }
> }
> +#else
> +static inline void __init dma_pernuma_cma_reserve(void)
> +{
> +}
> #endif
>
> /**
> @@ -171,6 +175,8 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
> phys_addr_t selected_limit = limit;
> bool fixed = false;
>
> + dma_pernuma_cma_reserve();
> +
> pr_debug("%s(limit %08lx)\n", __func__, (unsigned long)limit);
>
> if (size_cmdline != -1) {
next prev parent reply other threads:[~2023-05-16 1:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-12 9:42 [PATCH] dma-contiguous: support per-numa CMA for all architectures Yajun Deng
2023-05-12 21:08 ` Andrew Morton
2023-05-15 9:49 ` Christoph Hellwig
2023-05-15 11:23 ` Yajun Deng
2023-05-15 11:38 ` Petr Tesařík
2023-05-16 1:57 ` Yajun Deng
2023-06-24 0:40 ` Andrew Morton
2023-06-25 7:30 ` Yajun Deng
2023-06-26 5:32 ` Barry Song
2023-06-29 1:41 ` Yicong Yang
2023-05-16 1:55 ` Yajun Deng [this message]
2023-07-31 16:02 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0b4c1395-1884-c08d-2f8e-3847ec454886@linux.dev \
--to=yajun.deng@linux.dev \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=bhe@redhat.com \
--cc=bp@suse.de \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=kim.phillips@amd.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=petr@tesarici.cz \
--cc=rdunlap@infradead.org \
--cc=robin.murphy@arm.com \
--cc=rostedt@goodmis.org \
--cc=song.bao.hua@hisilicon.com \
--cc=thunder.leizhen@huawei.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox