mirror of
https://github.com/revyos/thead-kernel.git
synced 2026-09-17 21:02:13 +02:00
Linux_SDK_V1.3.3
Signed-off-by: thead_admin <occ_thead@service.alibaba.com>
This commit is contained in:
committed by
Han Gao/Revy/Rabenda
parent
2bd2eac4a7
commit
e17ac7bab2
139
mm/page_alloc.c
139
mm/page_alloc.c
@@ -310,10 +310,10 @@ const char * const migratetype_names[MIGRATE_TYPES] = {
|
||||
"Unmovable",
|
||||
"Movable",
|
||||
"Reclaimable",
|
||||
"HighAtomic",
|
||||
#ifdef CONFIG_CMA
|
||||
"CMA",
|
||||
#endif
|
||||
"HighAtomic",
|
||||
#ifdef CONFIG_MEMORY_ISOLATION
|
||||
"Isolate",
|
||||
#endif
|
||||
@@ -2452,17 +2452,6 @@ static int fallbacks[MIGRATE_TYPES][3] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CMA
|
||||
static __always_inline struct page *__rmqueue_cma_fallback(struct zone *zone,
|
||||
unsigned int order)
|
||||
{
|
||||
return __rmqueue_smallest(zone, order, MIGRATE_CMA);
|
||||
}
|
||||
#else
|
||||
static inline struct page *__rmqueue_cma_fallback(struct zone *zone,
|
||||
unsigned int order) { return NULL; }
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Move the free pages in a range to the freelist tail of the requested type.
|
||||
* Note that start_page and end_pages are not aligned on a pageblock
|
||||
@@ -2954,33 +2943,16 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype,
|
||||
|
||||
retry:
|
||||
page = __rmqueue_smallest(zone, order, migratetype);
|
||||
|
||||
if (unlikely(!page) && __rmqueue_fallback(zone, order, migratetype,
|
||||
alloc_flags))
|
||||
goto retry;
|
||||
if (unlikely(!page)) {
|
||||
if (!page && __rmqueue_fallback(zone, order, migratetype,
|
||||
alloc_flags))
|
||||
goto retry;
|
||||
}
|
||||
|
||||
trace_mm_page_alloc_zone_locked(page, order, migratetype);
|
||||
return page;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CMA
|
||||
static struct page *__rmqueue_cma(struct zone *zone, unsigned int order,
|
||||
int migratetype,
|
||||
unsigned int alloc_flags)
|
||||
{
|
||||
struct page *page = __rmqueue_cma_fallback(zone, order);
|
||||
trace_mm_page_alloc_zone_locked(page, order, MIGRATE_CMA);
|
||||
return page;
|
||||
}
|
||||
#else
|
||||
static inline struct page *__rmqueue_cma(struct zone *zone, unsigned int order,
|
||||
int migratetype,
|
||||
unsigned int alloc_flags)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Obtain a specified number of elements from the buddy allocator, all under
|
||||
* a single hold of the lock, for efficiency. Add them to the supplied list.
|
||||
@@ -2994,14 +2966,8 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
|
||||
|
||||
spin_lock(&zone->lock);
|
||||
for (i = 0; i < count; ++i) {
|
||||
struct page *page;
|
||||
|
||||
if (is_migrate_cma(migratetype))
|
||||
page = __rmqueue_cma(zone, order, migratetype,
|
||||
alloc_flags);
|
||||
else
|
||||
page = __rmqueue(zone, order, migratetype, alloc_flags);
|
||||
|
||||
struct page *page = __rmqueue(zone, order, migratetype,
|
||||
alloc_flags);
|
||||
if (unlikely(page == NULL))
|
||||
break;
|
||||
|
||||
@@ -3036,28 +3002,6 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order,
|
||||
return alloced;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the pcp list that corresponds to the migrate type if that list isn't
|
||||
* empty.
|
||||
* If the list is empty return NULL.
|
||||
*/
|
||||
static struct list_head *get_populated_pcp_list(struct zone *zone,
|
||||
unsigned int order, struct per_cpu_pages *pcp,
|
||||
int migratetype, unsigned int alloc_flags)
|
||||
{
|
||||
struct list_head *list = &pcp->lists[migratetype];
|
||||
|
||||
if (list_empty(list)) {
|
||||
pcp->count += rmqueue_bulk(zone, order,
|
||||
pcp->batch, list,
|
||||
migratetype, alloc_flags);
|
||||
|
||||
if (list_empty(list))
|
||||
list = NULL;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NUMA
|
||||
/*
|
||||
* Called from the vmstat counter updater to drain pagesets of this
|
||||
@@ -3320,6 +3264,7 @@ static void free_unref_page_commit(struct page *page, unsigned long pfn)
|
||||
trace_android_vh_pcplist_add_cma_pages_bypass(migratetype,
|
||||
&pcp_skip_cma_pages);
|
||||
if (unlikely(is_migrate_isolate(migratetype)) ||
|
||||
is_migrate_cma(migratetype) ||
|
||||
pcp_skip_cma_pages) {
|
||||
free_one_page(zone, page, pfn, 0, migratetype,
|
||||
FPI_NONE);
|
||||
@@ -3513,28 +3458,16 @@ static inline void zone_statistics(struct zone *preferred_zone, struct zone *z)
|
||||
static struct page *__rmqueue_pcplist(struct zone *zone, int migratetype,
|
||||
unsigned int alloc_flags,
|
||||
struct per_cpu_pages *pcp,
|
||||
gfp_t gfp_flags)
|
||||
struct list_head *list)
|
||||
{
|
||||
struct page *page = NULL;
|
||||
struct list_head *list = NULL;
|
||||
struct page *page;
|
||||
|
||||
do {
|
||||
/* First try to get CMA pages */
|
||||
if (migratetype == MIGRATE_MOVABLE &&
|
||||
alloc_flags & ALLOC_CMA) {
|
||||
list = get_populated_pcp_list(zone, 0, pcp,
|
||||
get_cma_migrate_type(), alloc_flags);
|
||||
}
|
||||
|
||||
if (list == NULL) {
|
||||
/*
|
||||
* Either CMA is not suitable or there are no
|
||||
* free CMA pages.
|
||||
*/
|
||||
list = get_populated_pcp_list(zone, 0, pcp,
|
||||
if (list_empty(list)) {
|
||||
pcp->count += rmqueue_bulk(zone, 0,
|
||||
pcp->batch, list,
|
||||
migratetype, alloc_flags);
|
||||
if (unlikely(list == NULL) ||
|
||||
unlikely(list_empty(list)))
|
||||
if (unlikely(list_empty(list)))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3552,13 +3485,14 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone,
|
||||
int migratetype, unsigned int alloc_flags)
|
||||
{
|
||||
struct per_cpu_pages *pcp;
|
||||
struct list_head *list;
|
||||
struct page *page;
|
||||
unsigned long flags;
|
||||
|
||||
local_irq_save(flags);
|
||||
pcp = &this_cpu_ptr(zone->pageset)->pcp;
|
||||
page = __rmqueue_pcplist(zone, migratetype, alloc_flags, pcp,
|
||||
gfp_flags);
|
||||
list = &pcp->lists[migratetype];
|
||||
page = __rmqueue_pcplist(zone, migratetype, alloc_flags, pcp, list);
|
||||
if (page) {
|
||||
__count_zid_vm_events(PGALLOC, page_zonenum(page), 1);
|
||||
zone_statistics(preferred_zone, zone);
|
||||
@@ -3580,9 +3514,16 @@ struct page *rmqueue(struct zone *preferred_zone,
|
||||
struct page *page;
|
||||
|
||||
if (likely(order == 0)) {
|
||||
page = rmqueue_pcplist(preferred_zone, zone, gfp_flags,
|
||||
migratetype, alloc_flags);
|
||||
goto out;
|
||||
/*
|
||||
* MIGRATE_MOVABLE pcplist could have the pages on CMA area and
|
||||
* we need to skip it when CMA area isn't allowed.
|
||||
*/
|
||||
if (!IS_ENABLED(CONFIG_CMA) || alloc_flags & ALLOC_CMA ||
|
||||
migratetype != MIGRATE_MOVABLE) {
|
||||
page = rmqueue_pcplist(preferred_zone, zone, gfp_flags,
|
||||
migratetype, alloc_flags);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3605,15 +3546,8 @@ struct page *rmqueue(struct zone *preferred_zone,
|
||||
if (page)
|
||||
trace_mm_page_alloc_zone_locked(page, order, migratetype);
|
||||
}
|
||||
if (!page) {
|
||||
if (migratetype == MIGRATE_MOVABLE &&
|
||||
alloc_flags & ALLOC_CMA)
|
||||
page = __rmqueue_cma(zone, order, migratetype,
|
||||
alloc_flags);
|
||||
if (!page)
|
||||
page = __rmqueue(zone, order, migratetype,
|
||||
alloc_flags);
|
||||
}
|
||||
if (!page)
|
||||
page = __rmqueue(zone, order, migratetype, alloc_flags);
|
||||
} while (page && check_new_pages(page, order));
|
||||
spin_unlock(&zone->lock);
|
||||
if (!page)
|
||||
@@ -3793,14 +3727,6 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark,
|
||||
continue;
|
||||
|
||||
for (mt = 0; mt < MIGRATE_PCPTYPES; mt++) {
|
||||
#ifdef CONFIG_CMA
|
||||
/*
|
||||
* Note that this check is needed only
|
||||
* when MIGRATE_CMA < MIGRATE_PCPTYPES.
|
||||
*/
|
||||
if (mt == MIGRATE_CMA)
|
||||
continue;
|
||||
#endif
|
||||
if (!free_area_empty(area, mt))
|
||||
return true;
|
||||
}
|
||||
@@ -3938,8 +3864,7 @@ static inline unsigned int current_alloc_flags(gfp_t gfp_mask,
|
||||
unsigned int pflags = current->flags;
|
||||
|
||||
if (!(pflags & PF_MEMALLOC_NOCMA) &&
|
||||
gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE &&
|
||||
gfp_mask & __GFP_CMA)
|
||||
gfp_migratetype(gfp_mask) == MIGRATE_MOVABLE)
|
||||
alloc_flags |= ALLOC_CMA;
|
||||
|
||||
#endif
|
||||
@@ -8782,7 +8707,7 @@ int alloc_contig_range(unsigned long start, unsigned long end,
|
||||
|
||||
trace_android_vh_cma_drain_all_pages_bypass(migratetype,
|
||||
&skip_drain_all_pages);
|
||||
if (skip_drain_all_pages)
|
||||
if (!skip_drain_all_pages)
|
||||
drain_all_pages(cc.zone);
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user