Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1718872 > unrolled thread
| Started by | js1304@gmail.com |
|---|---|
| First post | 2017-08-24 08:40 +0200 |
| Last post | 2017-08-24 08:40 +0200 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/3] mm/cma: manage the memory of the CMA area by using the ZONE_MOVABLE js1304@gmail.com - 2017-08-24 08:40 +0200
[PATCH 2/3] mm/cma: remove ALLOC_CMA js1304@gmail.com - 2017-08-24 08:40 +0200
[PATCH 3/3] ARM: CMA: avoid double mapping to the CMA area if CONFIG_HIGHMEM = y js1304@gmail.com - 2017-08-24 08:40 +0200
| From | js1304@gmail.com |
|---|---|
| Date | 2017-08-24 08:40 +0200 |
| Subject | [PATCH 0/3] mm/cma: manage the memory of the CMA area by using the ZONE_MOVABLE |
| Message-ID | <uhTY6-2SA-19@gated-at.bofh.it> |
From: Joonsoo Kim <iamjoonsoo.kim@lge.com> This patchset is the follow-up of the discussion about the "Introduce ZONE_CMA (v7)" [1]. Please reference it if more information is needed. In this patchset, the memory of the CMA area is managed by using the ZONE_MOVABLE. Since there is another type of the memory in this zone, we need to maintain a migratetype for the CMA memory to account the number of the CMA memory. So, unlike previous patchset, there is less deletion of the code. Otherwise, there is no big change. Motivation of this patchset is described in the commit description of the patch "mm/cma: manage the memory of the CMA area by using the ZONE_MOVABLE". Please refer it for more information. This patchset is based on linux-next-20170822 plus "mm/page_alloc: don't reserve ZONE_HIGHMEM for ZONE_MOVABLE". Thanks. [1]: lkml.kernel.org/r/1491880640-9944-1-git-send-email-iamjoonsoo.kim@lge.com Joonsoo Kim (3): mm/cma: manage the memory of the CMA area by using the ZONE_MOVABLE mm/cma: remove ALLOC_CMA ARM: CMA: avoid double mapping to the CMA area if CONFIG_HIGHMEM = y arch/arm/mm/dma-mapping.c | 8 +++- include/linux/memory_hotplug.h | 3 -- include/linux/mm.h | 1 + mm/cma.c | 83 ++++++++++++++++++++++++++++++++++++------ mm/compaction.c | 4 +- mm/internal.h | 4 +- mm/page_alloc.c | 83 +++++++++++++++++++++++++++--------------- 7 files changed, 137 insertions(+), 49 deletions(-) -- 2.7.4
[toc] | [next] | [standalone]
| From | js1304@gmail.com |
|---|---|
| Date | 2017-08-24 08:40 +0200 |
| Subject | [PATCH 2/3] mm/cma: remove ALLOC_CMA |
| Message-ID | <uhTY7-2SA-33@gated-at.bofh.it> |
| In reply to | #1718872 |
From: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Now, all reserved pages for CMA region are belong to the ZONE_MOVABLE
and it only serves for a request with GFP_HIGHMEM && GFP_MOVABLE.
Therefore, we don't need to maintain ALLOC_CMA at all.
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
mm/compaction.c | 4 +---
mm/internal.h | 1 -
mm/page_alloc.c | 28 +++-------------------------
3 files changed, 4 insertions(+), 29 deletions(-)
diff --git a/mm/compaction.c b/mm/compaction.c
index bf018d8..ee16d4a 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -1457,14 +1457,12 @@ static enum compact_result __compaction_suitable(struct zone *zone, int order,
* if compaction succeeds.
* For costly orders, we require low watermark instead of min for
* compaction to proceed to increase its chances.
- * ALLOC_CMA is used, as pages in CMA pageblocks are considered
- * suitable migration targets
*/
watermark = (order > PAGE_ALLOC_COSTLY_ORDER) ?
low_wmark_pages(zone) : min_wmark_pages(zone);
watermark += compact_gap(order);
if (!__zone_watermark_ok(zone, 0, watermark, classzone_idx,
- ALLOC_CMA, wmark_target))
+ 0, wmark_target))
return COMPACT_SKIPPED;
return COMPACT_CONTINUE;
diff --git a/mm/internal.h b/mm/internal.h
index b4f9ebc..0aaa05a 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -497,7 +497,6 @@ unsigned long reclaim_clean_pages_from_list(struct zone *zone,
#define ALLOC_HARDER 0x10 /* try to alloc harder */
#define ALLOC_HIGH 0x20 /* __GFP_HIGH set */
#define ALLOC_CPUSET 0x40 /* check for correct cpuset */
-#define ALLOC_CMA 0x80 /* allow allocations from CMA areas */
enum ttu_flags;
struct tlbflush_unmap_batch;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bbd00f1..b74bd78 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2710,7 +2710,7 @@ int __isolate_free_page(struct page *page, unsigned int order)
* exists.
*/
watermark = min_wmark_pages(zone) + (1UL << order);
- if (!zone_watermark_ok(zone, 0, watermark, 0, ALLOC_CMA))
+ if (!zone_watermark_ok(zone, 0, watermark, 0, 0))
return 0;
__mod_zone_freepage_state(zone, -(1UL << order), mt);
@@ -2987,12 +2987,6 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
}
-#ifdef CONFIG_CMA
- /* If allocation can't use CMA areas don't use free CMA pages */
- if (!(alloc_flags & ALLOC_CMA))
- free_pages -= zone_page_state(z, NR_FREE_CMA_PAGES);
-#endif
-
/*
* Check watermarks for an order-0 allocation request. If these
* are not met, then a high-order request also cannot go ahead
@@ -3022,10 +3016,8 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
}
#ifdef CONFIG_CMA
- if ((alloc_flags & ALLOC_CMA) &&
- !list_empty(&area->free_list[MIGRATE_CMA])) {
+ if (!list_empty(&area->free_list[MIGRATE_CMA]))
return true;
- }
#endif
}
return false;
@@ -3042,13 +3034,6 @@ static inline bool zone_watermark_fast(struct zone *z, unsigned int order,
unsigned long mark, int classzone_idx, unsigned int alloc_flags)
{
long free_pages = zone_page_state(z, NR_FREE_PAGES);
- long cma_pages = 0;
-
-#ifdef CONFIG_CMA
- /* If allocation can't use CMA areas don't use free CMA pages */
- if (!(alloc_flags & ALLOC_CMA))
- cma_pages = zone_page_state(z, NR_FREE_CMA_PAGES);
-#endif
/*
* Fast check for order-0 only. If this fails then the reserves
@@ -3057,7 +3042,7 @@ static inline bool zone_watermark_fast(struct zone *z, unsigned int order,
* the caller is !atomic then it'll uselessly search the free
* list. That corner case is then slower but it is harmless.
*/
- if (!order && (free_pages - cma_pages) > mark + z->lowmem_reserve[classzone_idx])
+ if (!order && free_pages > mark + z->lowmem_reserve[classzone_idx])
return true;
return __zone_watermark_ok(z, order, mark, classzone_idx, alloc_flags,
@@ -3676,10 +3661,6 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
} else if (unlikely(rt_task(current)) && !in_interrupt())
alloc_flags |= ALLOC_HARDER;
-#ifdef CONFIG_CMA
- if (gfpflags_to_migratetype(gfp_mask) == MIGRATE_MOVABLE)
- alloc_flags |= ALLOC_CMA;
-#endif
return alloc_flags;
}
@@ -4156,9 +4137,6 @@ static inline bool prepare_alloc_pages(gfp_t gfp_mask, unsigned int order,
if (should_fail_alloc_page(gfp_mask, order))
return false;
- if (IS_ENABLED(CONFIG_CMA) && ac->migratetype == MIGRATE_MOVABLE)
- *alloc_flags |= ALLOC_CMA;
-
return true;
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | js1304@gmail.com |
|---|---|
| Date | 2017-08-24 08:40 +0200 |
| Subject | [PATCH 3/3] ARM: CMA: avoid double mapping to the CMA area if CONFIG_HIGHMEM = y |
| Message-ID | <uhTY7-2SA-41@gated-at.bofh.it> |
| In reply to | #1718872 |
From: Joonsoo Kim <iamjoonsoo.kim@lge.com> CMA area is now managed by the separate zone, ZONE_MOVABLE, to fix many MM related problems. In this implementation, if CONFIG_HIGHMEM = y, then ZONE_MOVABLE is considered as HIGHMEM and the memory of the CMA area is also considered as HIGHMEM. That means that they are considered as the page without direct mapping. However, CMA area could be in a lowmem and the memory could have direct mapping. In ARM, when establishing a new mapping for DMA, direct mapping should be cleared since two mapping with different cache policy could cause unknown problem. With this patch, PageHighmem() for the CMA memory located in lowmem returns true so that the function for DMA mapping cannot notice whether it needs to clear direct mapping or not, correctly. To handle this situation, this patch always clears direct mapping for such CMA memory. Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> --- arch/arm/mm/dma-mapping.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index fcf1473..38f0fde 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -513,7 +513,13 @@ void __init dma_contiguous_remap(void) flush_tlb_kernel_range(__phys_to_virt(start), __phys_to_virt(end)); - iotable_init(&map, 1); + /* + * For highmem system, all the memory in CMA region will be + * considered as highmem even if it's physical address belong + * to lowmem. Therefore, re-mapping isn't required. + */ + if (!IS_ENABLED(CONFIG_HIGHMEM)) + iotable_init(&map, 1); } } -- 2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web