Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f4f9019 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mm: fix the use of ALLOC_CMA"

parents 0300f957 3f23e820
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1360,13 +1360,14 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec,
				__GFP_KSWAPD_RECLAIM |
				__GFP_NOWARN |
				__GFP_HIGHMEM |
				__GFP_MOVABLE);
				__GFP_MOVABLE |
				__GFP_CMA);
	if (!handle) {
		zcomp_stream_put(zram->comp);
		atomic64_inc(&zram->stats.writestall);
		handle = zs_malloc(zram->mem_pool, comp_len,
				GFP_NOIO | __GFP_HIGHMEM |
				__GFP_MOVABLE);
				__GFP_MOVABLE | __GFP_CMA);
		if (handle)
			goto compress_again;
		return -ENOMEM;
+15 −1
Original line number Diff line number Diff line
@@ -39,8 +39,17 @@ struct vm_area_struct;
#define ___GFP_HARDWALL		0x100000u
#define ___GFP_THISNODE		0x200000u
#define ___GFP_ACCOUNT		0x400000u
#ifdef CONFIG_CMA_DIRECT_UTILIZATION
#define ___GFP_CMA		0x800000u
#else
#define ___GFP_CMA		0
#endif
#ifdef CONFIG_LOCKDEP
#define ___GFP_NOLOCKDEP	0x800000u
#ifdef CONFIG_CMA_DIRECT_UTILIZATION
#define ___GFP_NOLOCKDEP	0x1000000u
#else
#define __GFP_NOLOCKDEP		0x800000u
#endif
#else
#define ___GFP_NOLOCKDEP	0
#endif
@@ -57,6 +66,7 @@ struct vm_area_struct;
#define __GFP_HIGHMEM	((__force gfp_t)___GFP_HIGHMEM)
#define __GFP_DMA32	((__force gfp_t)___GFP_DMA32)
#define __GFP_MOVABLE	((__force gfp_t)___GFP_MOVABLE)  /* ZONE_MOVABLE allowed */
#define __GFP_CMA	((__force gfp_t)___GFP_CMA)
#define GFP_ZONEMASK	(__GFP_DMA|__GFP_HIGHMEM|__GFP_DMA32|__GFP_MOVABLE)

/**
@@ -217,7 +227,11 @@ struct vm_area_struct;
#define __GFP_NOLOCKDEP ((__force gfp_t)___GFP_NOLOCKDEP)

/* Room for N __GFP_FOO bits */
#ifdef CONFIG_CMA_DIRECT_UTILIZATION
#define __GFP_BITS_SHIFT (24 + IS_ENABLED(CONFIG_LOCKDEP))
#else
#define __GFP_BITS_SHIFT (23 + IS_ENABLED(CONFIG_LOCKDEP))
#endif
#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))

/**
+5 −0
Original line number Diff line number Diff line
@@ -205,7 +205,12 @@ static inline struct page *
alloc_zeroed_user_highpage_movable(struct vm_area_struct *vma,
					unsigned long vaddr)
{
#ifndef CONFIG_CMA_DIRECT_UTILIZATION
	return __alloc_zeroed_user_highpage(__GFP_MOVABLE, vma, vaddr);
#else
	return __alloc_zeroed_user_highpage(__GFP_MOVABLE|__GFP_CMA, vma,
						vaddr);
#endif
}

static inline void clear_highpage(struct page *page)
+16 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ enum migratetype {
	MIGRATE_UNMOVABLE,
	MIGRATE_MOVABLE,
	MIGRATE_RECLAIMABLE,
#ifndef CONFIG_CMA_PCP_LISTS
	MIGRATE_PCPTYPES,	/* the number of types on the pcp lists */
	MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES,
#ifdef CONFIG_CMA
@@ -60,6 +61,11 @@ enum migratetype {
	 */
	MIGRATE_CMA,
#endif
#else
	MIGRATE_CMA,
	MIGRATE_PCPTYPES,	/* the number of types on the pcp lists */
	MIGRATE_HIGHATOMIC = MIGRATE_PCPTYPES,
#endif
#ifdef CONFIG_MEMORY_ISOLATION
	MIGRATE_ISOLATE,	/* can't allocate from here */
#endif
@@ -72,9 +78,15 @@ extern const char * const migratetype_names[MIGRATE_TYPES];
#ifdef CONFIG_CMA
#  define is_migrate_cma(migratetype) unlikely((migratetype) == MIGRATE_CMA)
#  define is_migrate_cma_page(_page) (get_pageblock_migratetype(_page) == MIGRATE_CMA)
#ifdef CONFIG_CMA_PCP_LISTS
#  define get_cma_migrate_type() MIGRATE_CMA
#else
#  define get_cma_migrate_type() MIGRATE_MOVABLE
#endif
#else
#  define is_migrate_cma(migratetype) false
#  define is_migrate_cma_page(_page) false
#  define get_cma_migrate_type() MIGRATE_MOVABLE
#endif

static inline bool is_migrate_movable(int mt)
@@ -444,6 +456,10 @@ struct zone {
	struct pglist_data	*zone_pgdat;
	struct per_cpu_pageset __percpu *pageset;

#ifdef CONFIG_CMA_DIRECT_UTILIZATION
	bool			cma_alloc;
#endif

#ifndef CONFIG_SPARSEMEM
	/*
	 * Flags for a pageblock_nr_pages block. See pageblock-flags.h.
+29 −0
Original line number Diff line number Diff line
@@ -530,6 +530,35 @@ config CMA_AREAS

	  If unsure, leave the default value "7".

config CMA_DIRECT_UTILIZATION
	bool "Allow clients to directly use CMA for page allocations"
	depends on CMA && QGKI
	help
	  CMA pages are currently used as a fallback for moveable page
	  allocations only when all regular moveable pages have been
	  allocated. This can cause stalls for non-movable allocations,
	  as non-movable allocations will not consider CMA memory as free
	  memory, and thus, will cause the system to reclaim movable pages
	  to satisfy non-movable allocations, ignoring the CMA pages. Since
	  the system now has movable memory, CMA pages will also be ignored,
	  since they are used only when there is not enough movable memory
	  to satisfy a movable request. Enable this option to specify to the
	  page allocator that movable allocations should be satisfied with
	  CMA pages, so that CMA pages can be used directly for allocations,
	  instead of as a fallback, thus, improving CMA utilization.

config CMA_PCP_LISTS
	bool "Create PCP lists for CMA memory"
	depends on CMA && CMA_DIRECT_UTILIZATION && QGKI
	help
	  Improve memory utilization by creating PCP lists that contain CMA
	  pages to satisfy order-0 allocations when appropriate. Increased
	  CMA usage results in better memory utilization, as the system will
	  can use CMA pages to satisfy movable allocations. This results in
	  more efficient reclaim when trying to satisfy non-movable
	  allocations, as the amount of non-CMA memory to be reclaimed should
	  be smaller.

config MEM_SOFT_DIRTY
	bool "Track memory changes"
	depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS
Loading