FAILED: patch "[PATCH] mm/filemap.c: fix NULL pointer in page_cache_tree_insert()" failed to apply to 4.4-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
Quoted 1 line
From
abc1be13fd113ddef5e2d807a466286b864caed3Mon Sep 17 00:00:00 2001
From: Matthew Wilcox <[email protected]>
Date: Fri, 20 Apr 2018 14:56:20 -0700
Subject: [PATCH] mm/filemap.c: fix NULL pointer in page_cache_tree_insert()
f2fs specifies the __GFP_ZERO flag for allocating some of its pages. Unfortunately, the page cache also uses the mapping's GFP flags for allocating radix tree nodes. It always masked off the __GFP_HIGHMEM flag, and masks off __GFP_ZERO in some paths, but not all. That causes radix tree nodes to be allocated with a NULL list_head, which causes backtraces like:
__list_del_entry+0x30/0xd0 list_lru_del+0xac/0x1ac page_cache_tree_insert+0xd8/0x110
The __GFP_DMA and __GFP_DMA32 flags would also be able to sneak through if they are ever used. Fix them all by using GFP_RECLAIM_MASK at the innermost location, and remove it from earlier in the callchain.
mm/filemap.c +4 -5
@@ -786,7 +786,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)VM_BUG_ON_PAGE (!PageLocked (new), new);VM_BUG_ON_PAGE (new->mapping, new); - error =radix_tree_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_preload (gfp_mask &GFP_RECLAIM_MASK );if (!error) {struct address_space *mapping = old->mapping;void (*freepage)(struct page *);
@@ -842,7 +842,7 @@ static int __add_to_page_cache_locked(struct page *page,return error; } - error =radix_tree_maybe_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_maybe_preload (gfp_mask &GFP_RECLAIM_MASK );if (error) {if (!huge)mem_cgroup_cancel_charge (page, memcg, false);
@@ -1585,8 +1585,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,if (fgp_flags &FGP_ACCESSED )__SetPageReferenced (page); - err =add_to_page_cache_lru (page, mapping, offset, - gfp_mask &GFP_RECLAIM_MASK ); + err =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (unlikely (err)) {put_page (page); page =NULL ;
@@ -2387,7 +2386,7 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)if (!page)return -ENOMEM ; - ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask &GFP_KERNEL ); + ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (ret ==0 ) ret = mapping->a_ops->readpage (file, page);else if (ret == -EEXIST )
Quoted 78 lines · On Sun, Apr 22, 2018 at 11:33:42AM +0200, [email protected] wrote:
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
abc1be13fd113ddef5e2d807a466286b864caed3Mon Sep 17 00:00:00 2001
From: Matthew Wilcox <[email protected]>
Date: Fri, 20 Apr 2018 14:56:20 -0700
Subject: [PATCH]mm/filemap.c: fix NULL pointer inpage_cache_tree_insert()f2fs specifies the
__GFP_ZEROflag for allocating some of its pages. Unfortunately, the page cache also uses the mapping's GFP flags for allocating radix tree nodes. It always masked off the__GFP_HIGHMEMflag, and masks off__GFP_ZEROin some paths, but not all. That causes radix tree nodes to be allocated with a NULLlist_head, which causes backtraces like:__list_del_entry+0x30/0xd0 list_lru_del+0xac/0x1ac page_cache_tree_insert+0xd8/0x110The
__GFP_DMAand__GFP_DMA32flags would also be able to sneak through if they are ever used. Fix them all by usingGFP_RECLAIM_MASKat the innermost location, and remove it from earlier in the callchain.Fixes 449dd6984d0e ("mm: keep page cache radix tree nodes in check")Signed-off-by Matthew Wilcox <[email protected]>Reported-by Chris Fries <[email protected]>Debugged-by Minchan Kim <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Michal Hocko <[email protected]>Reviewed-by Jan Kara <[email protected]>Cc <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>mm/filemap.c +3
-4@@ -786,7 +786,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)VM_BUG_ON_PAGE (!PageLocked (new), new);VM_BUG_ON_PAGE (new->mapping, new); - error =radix_tree_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_preload (gfp_mask &GFP_RECLAIM_MASK );if (!error) {struct address_space *mapping = old->mapping;void (*freepage)(struct page *);@@ -842,7 +842,7 @@ static int __add_to_page_cache_locked(struct page *page,return error; } - error =radix_tree_maybe_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_maybe_preload (gfp_mask &GFP_RECLAIM_MASK );if (error) {if (!huge)mem_cgroup_cancel_charge (page, memcg, false);@@ -1585,8 +1585,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,if (fgp_flags &FGP_ACCESSED )__SetPageReferenced (page); - err =add_to_page_cache_lru (page, mapping, offset, - gfp_mask &GFP_RECLAIM_MASK ); + err =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (unlikely (err)) {put_page (page); page =NULL ;
mm/filemap.c static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask) · line 2392
Quoted 8 lines
mm/filemap.c +1
-1@@ -2387,7 +2386,7 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)if (!page)return -ENOMEM ; - ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask &GFP_KERNEL ); + ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (ret ==0 ) ret = mapping->a_ops->readpage (file, page);else if (ret == -EEXIST )
It looks like c20cd45eb017 ("mm: allow GFP_{FS,IO} for page_cache_read page cache allocation") came in during 4.5 and reorganized a few things around the last section.
If you pick that commit then this one, it will be clean (just tested on 4.4.128).
Nathan
Greg KH
maintainerQuoted 92 lines · Nathan Chancellor
Quoted 78 lines · On Sun, Apr 22, 2018 at 11:33:42AM +0200, [email protected] wrote:
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
abc1be13fd113ddef5e2d807a466286b864caed3Mon Sep 17 00:00:00 2001
From: Matthew Wilcox <[email protected]>
Date: Fri, 20 Apr 2018 14:56:20 -0700
Subject: [PATCH]mm/filemap.c: fix NULL pointer inpage_cache_tree_insert()f2fs specifies the
__GFP_ZEROflag for allocating some of its pages. Unfortunately, the page cache also uses the mapping's GFP flags for allocating radix tree nodes. It always masked off the__GFP_HIGHMEMflag, and masks off__GFP_ZEROin some paths, but not all. That causes radix tree nodes to be allocated with a NULLlist_head, which causes backtraces like:__list_del_entry+0x30/0xd0 list_lru_del+0xac/0x1ac page_cache_tree_insert+0xd8/0x110The
__GFP_DMAand__GFP_DMA32flags would also be able to sneak through if they are ever used. Fix them all by usingGFP_RECLAIM_MASKat the innermost location, and remove it from earlier in the callchain.Fixes 449dd6984d0e ("mm: keep page cache radix tree nodes in check")Signed-off-by Matthew Wilcox <[email protected]>Reported-by Chris Fries <[email protected]>Debugged-by Minchan Kim <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Michal Hocko <[email protected]>Reviewed-by Jan Kara <[email protected]>Cc <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>mm/filemap.c +3
-4@@ -786,7 +786,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)VM_BUG_ON_PAGE (!PageLocked (new), new);VM_BUG_ON_PAGE (new->mapping, new); - error =radix_tree_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_preload (gfp_mask &GFP_RECLAIM_MASK );if (!error) {struct address_space *mapping = old->mapping;void (*freepage)(struct page *);@@ -842,7 +842,7 @@ static int __add_to_page_cache_locked(struct page *page,return error; } - error =radix_tree_maybe_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_maybe_preload (gfp_mask &GFP_RECLAIM_MASK );if (error) {if (!huge)mem_cgroup_cancel_charge (page, memcg, false);@@ -1585,8 +1585,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,if (fgp_flags &FGP_ACCESSED )__SetPageReferenced (page); - err =add_to_page_cache_lru (page, mapping, offset, - gfp_mask &GFP_RECLAIM_MASK ); + err =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (unlikely (err)) {put_page (page); page =NULL ;mm/filemap.c static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask) · line 2392
Quoted 8 lines
mm/filemap.c +1
-1@@ -2387,7 +2386,7 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)if (!page)return -ENOMEM ; - ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask &GFP_KERNEL ); + ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (ret ==0 ) ret = mapping->a_ops->readpage (file, page);else if (ret == -EEXIST )It looks like
c20cd45eb017("mm: allow GFP_{FS,IO} forpage_cache_readpage cache allocation") came in during 4.5 and reorganized a few things around the last section.
Quoted 2 lines
If you pick that commit then this one, it will be clean (just tested on 4.4.128).
Ah yes, thanks!
Doesn't work for 3.18.y, let me go dig a bit into why that is...
greg k-h
Greg KH
maintainerQuoted 93 lines · Greg KH
Quoted 92 lines · Nathan Chancellor
Quoted 78 lines · On Sun, Apr 22, 2018 at 11:33:42AM +0200, [email protected] wrote:
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
abc1be13fd113ddef5e2d807a466286b864caed3Mon Sep 17 00:00:00 2001
From: Matthew Wilcox <[email protected]>
Date: Fri, 20 Apr 2018 14:56:20 -0700
Subject: [PATCH]mm/filemap.c: fix NULL pointer inpage_cache_tree_insert()f2fs specifies the
__GFP_ZEROflag for allocating some of its pages. Unfortunately, the page cache also uses the mapping's GFP flags for allocating radix tree nodes. It always masked off the__GFP_HIGHMEMflag, and masks off__GFP_ZEROin some paths, but not all. That causes radix tree nodes to be allocated with a NULLlist_head, which causes backtraces like:__list_del_entry+0x30/0xd0 list_lru_del+0xac/0x1ac page_cache_tree_insert+0xd8/0x110The
__GFP_DMAand__GFP_DMA32flags would also be able to sneak through if they are ever used. Fix them all by usingGFP_RECLAIM_MASKat the innermost location, and remove it from earlier in the callchain.Fixes 449dd6984d0e ("mm: keep page cache radix tree nodes in check")Signed-off-by Matthew Wilcox <[email protected]>Reported-by Chris Fries <[email protected]>Debugged-by Minchan Kim <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Michal Hocko <[email protected]>Reviewed-by Jan Kara <[email protected]>Cc <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>mm/filemap.c +3
-4@@ -786,7 +786,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)VM_BUG_ON_PAGE (!PageLocked (new), new);VM_BUG_ON_PAGE (new->mapping, new); - error =radix_tree_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_preload (gfp_mask &GFP_RECLAIM_MASK );if (!error) {struct address_space *mapping = old->mapping;void (*freepage)(struct page *);@@ -842,7 +842,7 @@ static int __add_to_page_cache_locked(struct page *page,return error; } - error =radix_tree_maybe_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_maybe_preload (gfp_mask &GFP_RECLAIM_MASK );if (error) {if (!huge)mem_cgroup_cancel_charge (page, memcg, false);@@ -1585,8 +1585,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,if (fgp_flags &FGP_ACCESSED )__SetPageReferenced (page); - err =add_to_page_cache_lru (page, mapping, offset, - gfp_mask &GFP_RECLAIM_MASK ); + err =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (unlikely (err)) {put_page (page); page =NULL ;mm/filemap.c static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask) · line 2392
Quoted 8 lines
mm/filemap.c +1
-1@@ -2387,7 +2386,7 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)if (!page)return -ENOMEM ; - ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask &GFP_KERNEL ); + ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (ret ==0 ) ret = mapping->a_ops->readpage (file, page);else if (ret == -EEXIST )It looks like
c20cd45eb017("mm: allow GFP_{FS,IO} forpage_cache_readpage cache allocation") came in during 4.5 and reorganized a few things around the last section.
Quoted 6 lines
Quoted 2 lines
If you pick that commit then this one, it will be clean (just tested on 4.4.128).
Ah yes, thanks!
Doesn't work for 3.18.y, let me go dig a bit into why that is...
Ick, 3.18.y is a mess in this area, I'll just leave that alone :)
greg k-h
Quoted 120 lines · Greg KH
Quoted 2 lines · Greg KH
Quoted 1 line · Nathan Chancellor
On Sun, Apr 22, 2018 at 11:33:42AM +0200,
Quoted 3 lines · [email protected] wrote:
Quoted 3 lines
Quoted 3 lines
The patch below does not apply to the 4.4-stable tree. If someone wants it applied there, or to any other stable or
longterm
Quoted 1 line
Quoted 1 line
Quoted 1 line
tree, then please email the backport, including the original git
commit
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree
------------------
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
From
abc1be13fd113ddef5e2d807a466286b864caed3Mon Sep 17 00:00:002001
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
From: Matthew Wilcox <[email protected]>
Date: Fri, 20 Apr 2018 14:56:20 -0700
Subject: [PATCH]mm/filemap.c: fix NULL pointer in
page_cache_tree_insert()Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
f2fs specifies the
__GFP_ZEROflag for allocating some of itspages.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Unfortunately, the page cache also uses the mapping's GFP flags
for
Quoted 1 line
Quoted 1 line
Quoted 1 line
allocating radix tree nodes. It always masked off the
__GFP_HIGHMEMQuoted 1 line
Quoted 1 line
Quoted 1 line
flag, and masks off
__GFP_ZEROin some paths, but not all. Thatcauses
Quoted 1 line
Quoted 1 line
Quoted 1 line
radix tree nodes to be allocated with a NULL
list_head, whichcauses
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
backtraces like:
__list_del_entry+0x30/0xd0 list_lru_del+0xac/0x1ac page_cache_tree_insert+0xd8/0x110The
__GFP_DMAand__GFP_DMA32flags would also be able to sneakthrough
Quoted 1 line
Quoted 1 line
Quoted 1 line
if they are ever used. Fix them all by using
GFP_RECLAIM_MASKatthe
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
innermost location, and remove it from earlier in the callchain.
Link:
http://lkml.kernel.org/r/[email protected]
Quoted 1 line
Quoted 1 line
Quoted 1 line
Fixes 449dd6984d0e ("mm: keep page cache radix tree nodes incheck")
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Signed-off-by Matthew Wilcox <[email protected]>Reported-by Chris Fries <[email protected]>Debugged-by Minchan Kim <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Michal Hocko <[email protected]>Reviewed-by Jan Kara <[email protected]>Cc <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>Quoted 5 lines
Quoted 5 lines
mm/filemap.c int replace_page_cache_page(struct page *old,
Quoted 5 lines
mm/filemap.c +0
-0@@ -786,7 +786,7 @@ int replace_page_cache_page(struct page *old,struct page *new,
gfp_tgfp_mask)Quoted 9 lines
Quoted 9 lines
mm/filemap.c static int __add_to_page_cache_locked(struct
Quoted 9 lines
mm/filemap.c +1
-1VM_BUG_ON_PAGE (!PageLocked (new), new);VM_BUG_ON_PAGE (new->mapping, new); - error =radix_tree_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_preload (gfp_mask &GFP_RECLAIM_MASK );if (!error) {struct address_space *mapping = old->mapping;void (*freepage)(struct page *);@@ -842,7 +842,7 @@ static int __add_to_page_cache_locked(structpage *page,
Quoted 9 lines
Quoted 9 lines
mm/filemap.c struct page *pagecache_get_page(struct
Quoted 9 lines
mm/filemap.c +1
-1return error; } - error =radix_tree_maybe_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_maybe_preload (gfp_mask &GFP_RECLAIM_MASK );if (error) {if (!huge)mem_cgroup_cancel_charge (page, memcg, false);@@ -1585,8 +1585,7 @@ struct page *pagecache_get_page(struct
address_space*mapping,pgoff_toffset,Quoted 10 lines
Quoted 10 lines
mm/filemap.c static int page_cache_read(struct file
Quoted 10 lines
mm/filemap.c +1
-2if (fgp_flags &FGP_ACCESSED )__SetPageReferenced (page); - err =add_to_page_cache_lru (page, mapping, offset, - gfp_mask &GFP_RECLAIM_MASK ); + err =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (unlikely (err)) {put_page (page); page =NULL ;@@ -2387,7 +2386,7 @@ static int page_cache_read(struct file*file,
pgoff_toffset,gfp_tgfp_mask)Quoted 4 lines
Quoted 4 lines
mm/filemap.c static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)
Quoted 4 lines
mm/filemap.c +0
-1if (!page)return -ENOMEM ; - ret = add_to_page_cache_lru(page, mapping, offset, gfp_mask &
GFP_KERNEL);Quoted 7 lines
Quoted 7 lines
mm/filemap.c static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask) · line 2392
Quoted 5 lines
mm/filemap.c +1
-0+ ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (ret ==0 ) ret = mapping->a_ops->readpage (file, page);else if (ret == -EEXIST )It looks like
c20cd45eb017("mm: allow GFP_{FS,IO} for
page_cache_readQuoted 1 line
Quoted 1 line
page cache allocation") came in during 4.5 and reorganized a few
things
Quoted 3 lines
Quoted 3 lines
around the last section.
If you pick that commit then this one, it will be clean (just
tested on
Quoted 2 lines
Quoted 1 line
4.4.128).
Quoted 7 lines
Quoted 3 lines
Ah yes, thanks!
Doesn't work for 3.18.y, let me go dig a bit into why that is...
Ick, 3.18.y is a mess in this area, I'll just leave that alone :)
greg k-h
Good ol' 3.18 :p
I'm keeping track of all the patches Nathan has been sending, I'll spin up another series of backports for 3.18.y tonight or tomorrow.
Signature · 1 line
Harsh Shandilya, PRJKT Development LLC
Quoted 81 lines · Nathan Chancellor
Quoted 80 lines · On Sun, Apr 22, 2018 at 11:33:42AM +0200, [email protected] wrote:
The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
abc1be13fd113ddef5e2d807a466286b864caed3Mon Sep 17 00:00:00 2001
From: Matthew Wilcox <[email protected]>
Date: Fri, 20 Apr 2018 14:56:20 -0700
Subject: [PATCH]mm/filemap.c: fix NULL pointer inpage_cache_tree_insert()f2fs specifies the
__GFP_ZEROflag for allocating some of its pages. Unfortunately, the page cache also uses the mapping's GFP flags for allocating radix tree nodes. It always masked off the__GFP_HIGHMEMflag, and masks off__GFP_ZEROin some paths, but not all. That causes radix tree nodes to be allocated with a NULLlist_head, which causes backtraces like:__list_del_entry+0x30/0xd0 list_lru_del+0xac/0x1ac page_cache_tree_insert+0xd8/0x110The
__GFP_DMAand__GFP_DMA32flags would also be able to sneak through if they are ever used. Fix them all by usingGFP_RECLAIM_MASKat the innermost location, and remove it from earlier in the callchain.Fixes 449dd6984d0e ("mm: keep page cache radix tree nodes in check")Signed-off-by Matthew Wilcox <[email protected]>Reported-by Chris Fries <[email protected]>Debugged-by Minchan Kim <[email protected]>Acked-by Johannes Weiner <[email protected]>Acked-by Michal Hocko <[email protected]>Reviewed-by Jan Kara <[email protected]>Cc <[email protected]>Signed-off-by Andrew Morton <[email protected]>Signed-off-by Linus Torvalds <[email protected]>mm/filemap.c +3
-4@@ -786,7 +786,7 @@ int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)VM_BUG_ON_PAGE (!PageLocked (new), new);VM_BUG_ON_PAGE (new->mapping, new); - error =radix_tree_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_preload (gfp_mask &GFP_RECLAIM_MASK );if (!error) {struct address_space *mapping = old->mapping;void (*freepage)(struct page *);@@ -842,7 +842,7 @@ static int __add_to_page_cache_locked(struct page *page,return error; } - error =radix_tree_maybe_preload (gfp_mask & ~__GFP_HIGHMEM); + error =radix_tree_maybe_preload (gfp_mask &GFP_RECLAIM_MASK );if (error) {if (!huge)mem_cgroup_cancel_charge (page, memcg, false);@@ -1585,8 +1585,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t offset,if (fgp_flags &FGP_ACCESSED )__SetPageReferenced (page); - err =add_to_page_cache_lru (page, mapping, offset, - gfp_mask &GFP_RECLAIM_MASK ); + err =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (unlikely (err)) {put_page (page); page =NULL ;@@ -2387,7 +2386,7 @@ static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask)if (!page)return -ENOMEM ;
Quoted 10 lines
mm/filemap.c static int page_cache_read(struct file *file, pgoff_t offset, gfp_t gfp_mask) · line 2392
Quoted 6 lines
mm/filemap.c +1
-1- ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask &GFP_KERNEL ); + ret =add_to_page_cache_lru (page, mapping, offset, gfp_mask);if (ret ==0 ) ret = mapping->a_ops->readpage (file, page);else if (ret == -EEXIST )It looks like
c20cd45eb017("mm: allow GFP_{FS,IO} forpage_cache_readpage cache allocation") came in during 4.5 and reorganized a few things around the last section.
right
Quoted 2 lines
If you pick that commit then this one, it will be clean (just tested on 4.4.128).
Or simply patch all radix_tree_*preload calls to restrict their gfp mask to GFP_RECLAIM_MASK. Or even simpler to hook into __radix_tree_preload...
Signature · 2 lines
Michal Hocko SUSE Labs