diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f1a0ae6e11b86b3020c90d7241ba12d47d2bbaa8..e3aff0175d4c65599dfd36f1c82f6d0bb4999619 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2696,6 +2696,9 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
 	if (unlikely(task_in_memcg_oom(current)))
 		goto bypass;
 
+	if (gfp_mask & __GFP_NOFAIL)
+		oom = false;
+
 	/*
 	 * We always charge the cgroup the mm_struct belongs to.
 	 * The mm_struct's mem_cgroup changes on task migration if the