Commit e0e45311 authored by Baolin Wang's avatar Baolin Wang Committed by Kefeng Wang
Browse files

mm: huge_memory: add the missing folio_test_pmd_mappable() for THP split statistics

mainline inclusion
from mainline-v6.9-rc2
commit 835c3a25aa373d486514e4e0f5a7450ea82ae489
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9S4Z4
CVE: NA

-------------------------------------------------

Now the mTHP can also be split or added into the deferred list, so add
folio_test_pmd_mappable() validation for PMD mapped THP, to avoid
confusion with PMD mapped THP related statistics.

[baolin.wang@linux.alibaba.com: check THP earlier in case folio is split, per Lance]
  Link: https://lkml.kernel.org/r/b99f8cb14bc85fdb6ab43721d1331cb5ebed2581.1713771041.git.baolin.wang@linux.alibaba.com
Link: https://lkml.kernel.org/r/a5341defeef27c9ac7b85c97f030f93e4368bbc1.1711694852.git.baolin.wang@linux.alibaba.com


Signed-off-by: default avatarBaolin Wang <baolin.wang@linux.alibaba.com>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarLance Yang <ioworker0@gmail.com>
Cc: Muchun Song <muchun.song@linux.dev>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 835c3a25aa373d486514e4e0f5a7450ea82ae489)
Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
parent 0e81922d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -3155,6 +3155,7 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
	XA_STATE_ORDER(xas, &folio->mapping->i_pages, folio->index, new_order);
	struct anon_vma *anon_vma = NULL;
	struct address_space *mapping = NULL;
	bool is_thp = folio_test_pmd_mappable(folio);
	int extra_pins, ret;
	pgoff_t end;
	bool is_hzp;
@@ -3333,6 +3334,7 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list,
		i_mmap_unlock_read(mapping);
out:
	xas_destroy(&xas);
	if (is_thp)
		count_vm_event(!ret ? THP_SPLIT_PAGE : THP_SPLIT_PAGE_FAILED);
	return ret;
}
@@ -3395,6 +3397,7 @@ void deferred_split_folio(struct folio *folio)

	spin_lock_irqsave(&ds_queue->split_queue_lock, flags);
	if (list_empty(&folio->_deferred_list)) {
		if (folio_test_pmd_mappable(folio))
			count_vm_event(THP_DEFERRED_SPLIT_PAGE);
		list_add_tail(&folio->_deferred_list, &ds_queue->split_queue);
		ds_queue->split_queue_len++;