Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 4c1aadd

Browse files
Charan Teja ReddyTreehugger Robot
Charan Teja Reddy
authored and
Treehugger Robot
committed
ANDROID: implement wrapper for reverse migration
Reverse migration is used to do the balancing the occupancy of memory zones in a node in the system whose imabalance may be caused by migration of pages to other zones by an operation, eg: hotremove and then hotadding the same memory. In this case there is a lot of free memory in newly hotadd memory which can be filled up by the previous migrated pages(as part of offline/hotremove) thus may free up some pressure in other zones of the node. Upstream discussion: https://lore.kernel.org/all/[email protected]/ Port to ACK6.6: Fold in following simple fixes from ACK6.1: commit d0652b3 ("ANDROID: inline isolate_and_split_free_page") commit 8a98feb ("ANDROID: mm: compaction: fix isolate_and_split_free_page() redefinition") Bug: 201263307 Signed-off-by: Charan Teja Reddy <[email protected]> Signed-off-by: Sukadev Bhattiprolu <[email protected]> Change-Id: Ib3137dab0db66ecf6858c4077dcadb9dfd0c6b1c
1 parent eb9f0af commit 4c1aadd

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

include/linux/compaction.h

+8
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order,
101101
extern void __meminit kcompactd_run(int nid);
102102
extern void __meminit kcompactd_stop(int nid);
103103
extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int highest_zoneidx);
104+
extern unsigned long isolate_and_split_free_page(struct page *page,
105+
struct list_head *list);
104106

105107
#else
106108
static inline void reset_isolation_suitable(pg_data_t *pgdat)
@@ -125,6 +127,12 @@ static inline void wakeup_kcompactd(pg_data_t *pgdat,
125127
{
126128
}
127129

130+
static inline unsigned long isolate_and_split_free_page(struct page *page,
131+
struct list_head *list)
132+
{
133+
return 0;
134+
}
135+
128136
#endif /* CONFIG_COMPACTION */
129137

130138
struct node;

include/linux/mmzone.h

+1
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,7 @@ static inline struct pglist_data *NODE_DATA(int nid)
15691569
extern struct pglist_data *first_online_pgdat(void);
15701570
extern struct pglist_data *next_online_pgdat(struct pglist_data *pgdat);
15711571
extern struct zone *next_zone(struct zone *zone);
1572+
extern int isolate_anon_lru_page(struct page *page);
15721573

15731574
/**
15741575
* for_each_online_pgdat - helper macro to iterate over all online nodes

mm/compaction.c

+25
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,31 @@ isolate_freepages_range(struct compact_control *cc,
784784
return pfn;
785785
}
786786

787+
#ifdef CONFIG_COMPACTION
788+
unsigned long isolate_and_split_free_page(struct page *page,
789+
struct list_head *list)
790+
{
791+
unsigned long isolated;
792+
unsigned int order;
793+
794+
if (!PageBuddy(page))
795+
return 0;
796+
797+
order = buddy_order(page);
798+
isolated = __isolate_free_page(page, order);
799+
if (!isolated)
800+
return 0;
801+
802+
set_page_private(page, order);
803+
list_add(&page->lru, list);
804+
805+
split_map_pages(list);
806+
807+
return isolated;
808+
}
809+
EXPORT_SYMBOL_GPL(isolate_and_split_free_page);
810+
#endif
811+
787812
/* Similar to reclaim, but different enough that they don't share logic */
788813
static bool too_many_isolated(struct compact_control *cc)
789814
{

mm/migrate.c

+2
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ void putback_movable_pages(struct list_head *l)
176176
}
177177
}
178178
}
179+
EXPORT_SYMBOL_GPL(putback_movable_pages);
179180

180181
/*
181182
* Restore a potential migration pte to a working pte entry
@@ -1987,6 +1988,7 @@ int migrate_pages(struct list_head *from, new_folio_t get_new_folio,
19871988

19881989
return rc_gather;
19891990
}
1991+
EXPORT_SYMBOL_GPL(migrate_pages);
19901992

19911993
struct folio *alloc_migration_target(struct folio *src, unsigned long private)
19921994
{

mm/page_alloc.c

+18
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,24 @@ unsigned long get_pfnblock_flags_mask(const struct page *page,
387387
word = READ_ONCE(bitmap[word_bitidx]);
388388
return (word >> bitidx) & mask;
389389
}
390+
EXPORT_SYMBOL_GPL(get_pfnblock_flags_mask);
391+
392+
int isolate_anon_lru_page(struct page *page)
393+
{
394+
int ret;
395+
396+
if (!PageLRU(page) || !PageAnon(page))
397+
return -EINVAL;
398+
399+
if (!get_page_unless_zero(page))
400+
return -EINVAL;
401+
402+
ret = isolate_lru_page(page);
403+
put_page(page);
404+
405+
return ret;
406+
}
407+
EXPORT_SYMBOL_GPL(isolate_anon_lru_page);
390408

391409
static __always_inline int get_pfnblock_migratetype(const struct page *page,
392410
unsigned long pfn)

0 commit comments

Comments
 (0)