Unverified Commit 9fac591d authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7205 mm: memcontrol: do not miss MEMCG_MAX events for enforced allocations

parents c3619cad 50814c7f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2678,6 +2678,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
	bool passed_oom = false;
	unsigned int reclaim_options = MEMCG_RECLAIM_MAY_SWAP;
	bool drained = false;
	bool raised_max_event = false;
	unsigned long pflags;

	if (mem_cgroup_is_root(memcg))
@@ -2728,6 +2729,7 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
		goto nomem;

	memcg_memory_event(mem_over_limit, MEMCG_MAX);
	raised_max_event = true;
#ifdef CONFIG_PSI_FINE_GRAINED
	pflags = PSI_MEMCG_RECLAIM;
#endif
@@ -2791,6 +2793,13 @@ static int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
	if (!(gfp_mask & __GFP_NOFAIL))
		return -ENOMEM;
force:
	/*
	 * If the allocation has to be enforced, don't forget to raise
	 * a MEMCG_MAX event.
	 */
	if (!raised_max_event)
		memcg_memory_event(mem_over_limit, MEMCG_MAX);

	/*
	 * The allocation either can't fail or will lead to more memory
	 * being freed very soon.  Allow memory usage go over the limit