diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2a853686775eeaa04f25d451c58fe926d45dae8e..dfd98ff2a3f0045f80638b847374ae9f72104731 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2436,6 +2436,12 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask, case OOM_SUCCESS: nr_retries = MEM_CGROUP_RECLAIM_RETRIES; oomed = true; + /* + * With !PREEMPT kernel if the memcg doesn't have reclaimable + * memory, the reclaim retry and oom logic may block scheduling + * indefinitely. + */ + cond_resched(); goto retry; case OOM_FAILED: goto force;