@@ -840,7 +840,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
unsigned long nr_scanned = 0, nr_isolated = 0;
struct lruvec *lruvec;
unsigned long flags = 0;
- struct lruvec *locked = NULL;
+ spinlock_t *locked = NULL;
struct folio *folio = NULL;
struct page *page = NULL, *valid_page = NULL;
struct address_space *mapping;
@@ -911,7 +911,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
*/
if (!(low_pfn % COMPACT_CLUSTER_MAX)) {
if (locked) {
- unlock_page_lruvec_irqrestore(locked, flags);
+ spin_unlock_irqrestore(locked, flags);
locked = NULL;
}
@@ -946,7 +946,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
if (PageHuge(page) && cc->alloc_contig) {
if (locked) {
- unlock_page_lruvec_irqrestore(locked, flags);
+ spin_unlock_irqrestore(locked, flags);
locked = NULL;
}
@@ -1035,7 +1035,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
if (unlikely(__PageMovable(page)) &&
!PageIsolated(page)) {
if (locked) {
- unlock_page_lruvec_irqrestore(locked, flags);
+ spin_unlock_irqrestore(locked, flags);
locked = NULL;
}
@@ -1120,12 +1120,11 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
lruvec = folio_lruvec(folio);
/* If we already hold the lock, we can skip some rechecking */
- if (lruvec != locked) {
+ if (&lruvec->lru_lock != locked) {
if (locked)
- unlock_page_lruvec_irqrestore(locked, flags);
+ spin_unlock_irqrestore(locked, flags);
- compact_lock_irqsave(&lruvec->lru_lock, &flags, cc);
- locked = lruvec;
+ locked = compact_lock_irqsave(&lruvec->lru_lock, &flags, cc);
lruvec_memcg_debug(lruvec, folio);
@@ -1188,7 +1187,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
isolate_fail_put:
/* Avoid potential deadlock in freeing page under lru_lock */
if (locked) {
- unlock_page_lruvec_irqrestore(locked, flags);
+ spin_unlock_irqrestore(locked, flags);
locked = NULL;
}
folio_put(folio);
@@ -1204,7 +1203,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
*/
if (nr_isolated) {
if (locked) {
- unlock_page_lruvec_irqrestore(locked, flags);
+ spin_unlock_irqrestore(locked, flags);
locked = NULL;
}
putback_movable_pages(&cc->migratepages);
@@ -1236,7 +1235,7 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn,
isolate_abort:
if (locked)
- unlock_page_lruvec_irqrestore(locked, flags);
+ spin_unlock_irqrestore(locked, flags);
if (folio) {
folio_set_lru(folio);
folio_put(folio);
Use "spinlock_t *" instead of "struct lruvec *" to record held lock in isolate_migratepages_block. This is a preparation to use compact_unlock_should_abort in isolate_migratepages_block to remove repeat code. Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> --- mm/compaction.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)