[Devel] [PATCH RH7 v2] mm: Do not drop __GFP_NOFAIL in __add_to_page_cache_locked
Evgenii Shatokhin
eshatokhin at virtuozzo.com
Sun Sep 26 22:49:28 MSK 2021
https://jira.sw.ru/browse/PSBM-98265
It is suspected that the memory allocations described in this bug fail
because 'mapping_gfp_constraint(mapping, gfp_mask)' drops __GFP_NOFAIL
from gfp_mask.
Restore __GFP_NOFAIL bit for mem_cgroup_try_charge_cache() - this might
help fix PSBM-98265.
Changes in v2:
- do not issue warning if __GFP_NOFAIL has been dropped: it triggers
too often.
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;
--
2.30.2
More information about the Devel
mailing list