[Devel] [PATCH RHEL7 COMMIT] mm: Do not drop __GFP_NOFAIL in __add_to_page_cache_locked
Vasily Averin
vvs at virtuozzo.com
Mon Oct 4 13:57:15 MSK 2021
The commit is pushed to "branch-rh7-3.10.0-1160.42.2.vz7.184.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.42.2.vz7.184.1
------>
commit 1a170c7dc6e79de9e8f4811c51e243c5daaec7f1
Author: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
Date: Mon Oct 4 13:57:15 2021 +0300
mm: Do not drop __GFP_NOFAIL in __add_to_page_cache_locked
It was found that the memory allocations described in PSBM-98265 fail
because 'mapping_gfp_constraint(mapping, gfp_mask)' drops __GFP_NOFAIL
from gfp_mask.
Restore __GFP_NOFAIL bit for mem_cgroup_try_charge_cache()
https://jira.sw.ru/browse/PSBM-98265
Suggested-by: Vasily Averin <vvs at virtuozzo.com>
Signed-off-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
---
mm/filemap.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index 2d35844b3123..579b274550f2 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -716,14 +716,21 @@ static int __add_to_page_cache_locked(struct page *page,
int huge = PageHuge(page);
struct mem_cgroup *memcg;
int error;
+ gfp_t gfp_mask_memcg = gfp_mask;
VM_BUG_ON(!PageLocked(page));
VM_BUG_ON(PageSwapBacked(page));
gfp_mask = mapping_gfp_constraint(mapping, gfp_mask);
+ /*
+ * mapping_gfp_constraint() could have dropped __GFP_NOFAIL -
+ * restore it for mem_cgroup_try_charge_cache() if it was present.
+ */
+ if (gfp_mask_memcg & __GFP_NOFAIL)
+ gfp_mask_memcg = gfp_mask | __GFP_NOFAIL;
if (!huge) {
- error = mem_cgroup_try_charge_cache(page, current->mm, gfp_mask,
+ error = mem_cgroup_try_charge_cache(page, current->mm, gfp_mask_memcg,
&memcg);
if (error)
return error;
More information about the Devel
mailing list