Unverified Commit cf06096f authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7114 v2 backport patch for thp deferred list for 4.19

Merge Pull Request from: @ci-robot 
 
PR sync from: Wupeng Ma <mawupeng1@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/H52VXA6AS3Z22LSBDZP3TGRHUKZ4YS7W/ 
From: Ma Wupeng <mawupeng1@huawei.com>

backport patch for thp deferred list for 4.19.

changelog since v1:
- remove data_race since 4.19 does not have it

Jianxing Wang (1):
  mm/mmu_gather: limit free batch count and add schedule point in
    tlb_batch_pages_flush

Kirill A. Shutemov (1):
  mm, thp: do not queue fully unmapped pages for deferred split

Yin Fengwei (1):
  THP: avoid lock when check whether THP is in deferred list


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/I9NU9F 
 
Link:https://gitee.com/openeuler/kernel/pulls/7114

 

Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
Reviewed-by: default avatarLiu YongQiang <liuyongqiang13@huawei.com>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parents 97e5e2c5 15e8c484
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -2907,13 +2907,20 @@ void free_transhuge_page(struct page *page)
	struct deferred_split ds_queue;
	unsigned long flags;

	/*
	 * At this point, there is no one trying to add the folio to
	 * deferred_list. If folio is not in deferred_list, it's safe
	 * to check without acquiring the split_queue_lock.
	 */
	get_deferred_split_queue(page, &ds_queue);
	if (!list_empty(page_deferred_list(page))) {
		spin_lock_irqsave(ds_queue.split_queue_lock, flags);
		if (!list_empty(page_deferred_list(page))) {
			(*ds_queue.split_queue_len)--;
			list_del(page_deferred_list(page));
		}
		spin_unlock_irqrestore(ds_queue.split_queue_lock, flags);
	}
	free_compound_page(page);
}

+14 −2
Original line number Diff line number Diff line
@@ -71,8 +71,20 @@ void tlb_flush_mmu_free(struct mmu_gather *tlb)
	tlb_table_flush(tlb);
#endif
	for (batch = &tlb->local; batch && batch->nr; batch = batch->next) {
		free_pages_and_swap_cache(batch->pages, batch->nr);
		batch->nr = 0;
		struct page **pages = batch->pages;

		do {
			/*
			 * limit free batch count when PAGE_SIZE > 4K
			 */
			unsigned int nr = min(512U, batch->nr);

			free_pages_and_swap_cache(pages, nr);
			pages += nr;
			batch->nr -= nr;

			cond_resched();
		} while (batch->nr);
	}
	tlb->active = &tlb->local;
}
+10 −4
Original line number Diff line number Diff line
@@ -1281,12 +1281,20 @@ static void page_remove_anon_compound_rmap(struct page *page)
	if (TestClearPageDoubleMap(page)) {
		/*
		 * Subpages can be mapped with PTEs too. Check how many of
		 * themi are still mapped.
		 * them are still mapped.
		 */
		for (i = 0, nr = 0; i < HPAGE_PMD_NR; i++) {
			if (atomic_add_negative(-1, &page[i]._mapcount))
				nr++;
		}

		/*
		 * Queue the page for deferred split if at least one small
		 * page of the compound page is unmapped, but at least one
		 * small page is still mapped.
		 */
		if (nr && nr < HPAGE_PMD_NR)
			deferred_split_huge_page(page);
	} else {
		nr = HPAGE_PMD_NR;
	}
@@ -1294,10 +1302,8 @@ static void page_remove_anon_compound_rmap(struct page *page)
	if (unlikely(PageMlocked(page)))
		clear_page_mlock(page);

	if (nr) {
	if (nr)
		__mod_node_page_state(page_pgdat(page), NR_ANON_MAPPED, -nr);
		deferred_split_huge_page(page);
	}
}

/**