diff mbox

[v2] arm64: mm: use macro instead of if judgement of ZONE_DMA

Message ID CAGZxSSSBpCvJt=PFbihTmPneJqiocU8VZSDHpXgkf5dhWZ850Q@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yifan Zhang Oct. 16, 2014, 9:41 a.m. UTC
if disable CONFIG_ZONE_DMA, ZONE_DMA becomes undefined.

Signed-off-by: Yifan Zhang <zhangyf@marvell.com>
---
 arch/arm64/mm/init.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

    memcpy(zhole_size, zone_size, sizeof(zhole_size));
@@ -97,10 +97,12 @@ static void __init zone_sizes_init(unsigned long
min, unsigned long max)
        if (start >= max)
            continue;

-       if (IS_ENABLED(CONFIG_ZONE_DMA) && start < max_dma) {
+#ifdef CONFIG_ZONE_DMA
+       if (start < max_dma) {
            unsigned long dma_end = min(end, max_dma);
            zhole_size[ZONE_DMA] -= dma_end - start;
        }
+#endif

        if (end > max_dma) {
            unsigned long normal_end = min(end, max);
--
1.7.9.5

Comments

Catalin Marinas Oct. 16, 2014, 5:10 p.m. UTC | #1
On Thu, Oct 16, 2014 at 10:41:01AM +0100, Yifan Zhang wrote:
> if disable CONFIG_ZONE_DMA, ZONE_DMA becomes undefined.

I agree that this is the case but can you explain why you need to
disable ZONE_DMA? It currently is def_bool y, so it cannot be disabled
unless you hack the Kconfig.
Yifan Zhang Oct. 17, 2014, 3:08 a.m. UTC | #2
Hi Catalin,

I found In current arm64 code, there is no normal zone, only DMA zone.

Number of blocks type     Unmovable  Reclaimable      Movable
Reserve          CMA      Isolate

Node 0, zone    DMA          142           12           69
1           28            0


When zone_sizes_init, zone_size[ZONE_NORMAL] is initialized to 0. (it
is 3.10, I didn't try the latest code base)

static void __init zone_sizes_init(unsigned long min, unsigned long max)
{
    struct memblock_region *reg;
    unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
    unsigned long max_dma = min;

    memset(zone_size, 0, sizeof(zone_size));

#ifdef CONFIG_ZONE_DMA
    /* 4GB maximum for 32-bit only capable devices */
    unsigned long max_dma_phys =
        (unsigned long)(dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1);
    max_dma = max(min, min(max, max_dma_phys >> PAGE_SHIFT));
    zone_size[ZONE_DMA] = max_dma - min;
#endif
    zone_size[ZONE_NORMAL] = max - max_dma;


Then I just tried to enable ZONE_NORMAL in our platform, and found
this compiling error.

Is this ZONE_DMA cover full memory and ZONE_NORMAL = 0 strategy on
purpose ? We will not use ZONE_NORMAL on arm64 ?



On Fri, Oct 17, 2014 at 1:10 AM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Thu, Oct 16, 2014 at 10:41:01AM +0100, Yifan Zhang wrote:
>> if disable CONFIG_ZONE_DMA, ZONE_DMA becomes undefined.
>
> I agree that this is the case but can you explain why you need to
> disable ZONE_DMA? It currently is def_bool y, so it cannot be disabled
> unless you hack the Kconfig.
>
> --
> Catalin
Catalin Marinas Oct. 17, 2014, 1:28 p.m. UTC | #3
On Fri, Oct 17, 2014 at 04:08:43AM +0100, Yifan Zhang wrote:
> I found In current arm64 code, there is no normal zone, only DMA zone.
> 
> Number of blocks type     Unmovable  Reclaimable      Movable
> Reserve          CMA      Isolate
> 
> Node 0, zone    DMA          142           12           69
> 1           28            0
> 
> When zone_sizes_init, zone_size[ZONE_NORMAL] is initialized to 0. (it
> is 3.10, I didn't try the latest code base)
[...]
> Is this ZONE_DMA cover full memory and ZONE_NORMAL = 0 strategy on
> purpose ? We will not use ZONE_NORMAL on arm64 ?

The normal zone is still there, only that it doesn't have any pages. The
page allocator falls back to the DMA zone, so you would not see any
problems with normal page allocation.

Are you trying to solve anything (performance?) or just what the kernel
shows as part of the normal zone?
Yifan Zhang Oct. 20, 2014, 1:58 a.m. UTC | #4
Catalin,

No, we don't have any issues w/ current configuration. I'm just
confused why normal zone is empty in arm64 when I dumped zone info. If
it is on purpose, then I'm fine.

THX all for feedback!

BR,
Yifan

On Fri, Oct 17, 2014 at 9:28 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> On Fri, Oct 17, 2014 at 04:08:43AM +0100, Yifan Zhang wrote:
>> I found In current arm64 code, there is no normal zone, only DMA zone.
>>
>> Number of blocks type     Unmovable  Reclaimable      Movable
>> Reserve          CMA      Isolate
>>
>> Node 0, zone    DMA          142           12           69
>> 1           28            0
>>
>> When zone_sizes_init, zone_size[ZONE_NORMAL] is initialized to 0. (it
>> is 3.10, I didn't try the latest code base)
> [...]
>> Is this ZONE_DMA cover full memory and ZONE_NORMAL = 0 strategy on
>> purpose ? We will not use ZONE_NORMAL on arm64 ?
>
> The normal zone is still there, only that it doesn't have any pages. The
> page allocator falls back to the DMA zone, so you would not see any
> problems with normal page allocation.
>
> Are you trying to solve anything (performance?) or just what the kernel
> shows as part of the normal zone?
>
> --
> Catalin
diff mbox

Patch

diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 494297c..887ca5d 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -82,10 +82,10 @@  static void __init zone_sizes_init(unsigned long
min, unsigned long max)
    memset(zone_size, 0, sizeof(zone_size));

    /* 4GB maximum for 32-bit only capable devices */
-   if (IS_ENABLED(CONFIG_ZONE_DMA)) {
-       max_dma = PFN_DOWN(max_zone_dma_phys());
-       zone_size[ZONE_DMA] = max_dma - min;
-   }
+#ifdef CONFIG_ZONE_DMA
+   max_dma = PFN_DOWN(max_zone_dma_phys());
+   zone_size[ZONE_DMA] = max_dma - min;
+#endif
    zone_size[ZONE_NORMAL] = max - max_dma;