Skip to content

Commit 187df5d

Browse files
rikvanrieltorvalds
authored andcommitted
mm,shmem,thp: limit shmem THP allocations to requested zones
Hugh pointed out that the gma500 driver uses shmem pages, but needs to limit them to the DMA32 zone. Ensure the allocations resulting from the gfp_mask returned by limit_gfp_mask use the zone flags that were originally passed to shmem_getpage_gfp. Link: https://lkml.kernel.org/r/20210224121016.1314ed6d@imladris.surriel.com Signed-off-by: Rik van Riel <riel@surriel.com> Suggested-by: Hugh Dickins <hughd@google.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Xu Yu <xuyu@linux.alibaba.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent cd89fb0 commit 187df5d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mm/shmem.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,11 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp)
15131513
{
15141514
gfp_t allowflags = __GFP_IO | __GFP_FS | __GFP_RECLAIM;
15151515
gfp_t denyflags = __GFP_NOWARN | __GFP_NORETRY;
1516-
gfp_t result = huge_gfp & ~allowflags;
1516+
gfp_t zoneflags = limit_gfp & GFP_ZONEMASK;
1517+
gfp_t result = huge_gfp & ~(allowflags | GFP_ZONEMASK);
1518+
1519+
/* Allow allocations only from the originally specified zones. */
1520+
result |= zoneflags;
15171521

15181522
/*
15191523
* Minimize the result gfp by taking the union with the deny flags,

0 commit comments

Comments
 (0)