Commit 3b6fa550 authored by Liu Shixin's avatar Liu Shixin
Browse files

mm: limit order to 0 when allocated from dynamic pool

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAO6NS



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

The large folios is not supported in dynamic pool, so we have to limit
order to 0 when it will be allocated from dynamic pool. The allocation
in shmem has already been limited in commit d0ef72eca876 ("mm: shmem: add
mTHP support for anonymous shmem"), and now we are limit the allocation
in anon/file path.

Fixes: ba572bea ("mm: thp: support allocation of anonymous multi-size THP")
Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
parent db19e032
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#include <linux/splice.h>
#include <linux/huge_mm.h>
#include <linux/pgtable.h>
#include <linux/dynamic_pool.h>
#include <asm/pgalloc.h>
#include <asm/tlbflush.h>
#include "internal.h"
@@ -1931,6 +1932,8 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,

		if (!mapping_large_folio_support(mapping))
			order = 0;
		if (order && mm_in_dynamic_pool(current->mm))
			order = 0;
		if (order > MAX_PAGECACHE_ORDER)
			order = MAX_PAGECACHE_ORDER;
		/* If we're not aligned, allocate a smaller folio */
+2 −0
Original line number Diff line number Diff line
@@ -4395,6 +4395,8 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf)
	 */
	if (unlikely(userfaultfd_armed(vma)))
		goto fallback;
	if (mm_in_dynamic_pool(vma->vm_mm))
		goto fallback;

	/*
	 * Get a list of all the (large) orders below PMD_ORDER that are enabled
+3 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@
#include <linux/blk-cgroup.h>
#include <linux/fadvise.h>
#include <linux/sched/mm.h>
#include <linux/dynamic_pool.h>

#include "internal.h"

@@ -503,6 +504,8 @@ void page_cache_ra_order(struct readahead_control *ractl,

	if (!mapping_large_folio_support(mapping) || ra->size < 4)
		goto fallback;
	if (mm_in_dynamic_pool(current->mm))
		goto fallback;

	limit = min(limit, index + ra->size - 1);