diff options
author | Rik van Riel <riel@surriel.com> | 2021-02-25 17:16:29 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2021-02-26 09:40:59 -0800 |
commit | 187df5dde943ae28f260db7377467ffb3b51a6de (patch) | |
tree | 3df0c61490e9a16e2d1b957232f5efe1c879aa39 /mm/shmem.c | |
parent | cd89fb06509903f942a0ffe97ffa63034671ed0c (diff) | |
download | linux-187df5dde943ae28f260db7377467ffb3b51a6de.tar.gz linux-187df5dde943ae28f260db7377467ffb3b51a6de.tar.bz2 linux-187df5dde943ae28f260db7377467ffb3b51a6de.zip |
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>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index 06c771d23127..b2db4ed0fbc7 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1513,7 +1513,11 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp) { gfp_t allowflags = __GFP_IO | __GFP_FS | __GFP_RECLAIM; gfp_t denyflags = __GFP_NOWARN | __GFP_NORETRY; - gfp_t result = huge_gfp & ~allowflags; + gfp_t zoneflags = limit_gfp & GFP_ZONEMASK; + gfp_t result = huge_gfp & ~(allowflags | GFP_ZONEMASK); + + /* Allow allocations only from the originally specified zones. */ + result |= zoneflags; /* * Minimize the result gfp by taking the union with the deny flags, |