Thread (11 messages) 11 messages, 2 authors, 2021-06-30

Re: [PATCH 2/3] mm: Charge active memcg when no mm is set

From: Michal Koutný <mkoutny@suse.com>
Date: 2021-06-25 14:47:43
Also in: linux-block, linux-mm, lkml

On Thu, Jun 10, 2021 at 10:39:43AM -0700, Dan Schatzberg [off-list ref] wrote:
quoted hunk ↗ jump to hunk
@@ -926,8 +937,17 @@ struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm)
 	 * counting is disabled on the root level in the
 	 * cgroup core. See CSS_NO_REF.
 	 */
-	if (unlikely(!mm))
-		return root_mem_cgroup;
+	if (unlikely(!mm)) {
+		memcg = active_memcg();
+		if (unlikely(memcg)) {
+			/* remote memcg must hold a ref */
+			css_get(&memcg->css);
+			return memcg;
+		}
+		mm = current->mm;
+		if (unlikely(!mm))
+			return root_mem_cgroup;
+	}
With the change in __add_to_page_cache_locked() all page cache charges
will supply null mm, so the first !mm unlikely hint may not be warranted
anymore. Just an interesting point, generally, I'm adding

Reviewed-by: Michal Koutný <mkoutny@suse.com>

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help