Skip to contentSkip to conversation

memcg: refill_stock for kmem uncharging too

PATCH In review Shakeel Butt 2 participants 3 messages Apr 23, 2019 – Apr 28, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 memcg: refill_stock for kmem uncharging too

The commit 475d0487a2ad ("mm: memcontrol: use per-cpu stocks for socket memory uncharging") added refill_stock() for skmem uncharging path to optimize workloads having high network traffic. Do the same for the kmem uncharging as well. Though we can bypass the refill for the offlined memcgs but it may impact the performance of network traffic for the sockets used by other cgroups.

Cc Roman Gushchin <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Vladimir Davydov <[email protected]>
Cc Andrew Morton <[email protected]>

---

Changelog since v1:
- No need to bypass offline memcgs in the refill.

 mm/memcontrol.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
mm/memcontrol.c +1 -5
index 2535e54e7989..2713b45ec3f0 100644
@@ -2768,17 +2768,13 @@ void __memcg_kmem_uncharge(struct page *page, int order)
 	if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
 		page_counter_uncharge(&memcg->kmem, nr_pages);
 
-	page_counter_uncharge(&memcg->memory, nr_pages);
-	if (do_memsw_account())
-		page_counter_uncharge(&memcg->memsw, nr_pages);
-
 	page->mem_cgroup = NULL;
 
 	/* slab pages do not have PageKmemcg flag set */
 	if (PageKmemcg(page))
 		__ClearPageKmemcg(page);
 
-	css_put_many(&memcg->css, nr_pages);
+	refill_stock(memcg, nr_pages);
 }
 #endif /* CONFIG_MEMCG_KMEM */
 
Signature · 1 line
2.21.0.593.g511ec345e18-goog
maintainer
#1 lore raw
Quoted 6 lines · Shakeel Butt

The commit 475d0487a2ad ("mm: memcontrol: use per-cpu stocks for socket memory uncharging") added refill_stock() for skmem uncharging path to optimize workloads having high network traffic. Do the same for the kmem uncharging as well. Though we can bypass the refill for the offlined memcgs but it may impact the performance of network traffic for the sockets used by other cgroups.

While the change makes sense, I would really like to see what kind of effect on performance does it really have. Do you have any specific workload that benefits from it?

Thanks!

Quoted 40 lines
Cc Roman Gushchin <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Vladimir Davydov <[email protected]>
Cc Andrew Morton <[email protected]>

---

Changelog since v1:
- No need to bypass offline memcgs in the refill.

 mm/memcontrol.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
mm/memcontrol.c +1 -5
index 2535e54e7989..2713b45ec3f0 100644
@@ -2768,17 +2768,13 @@ void __memcg_kmem_uncharge(struct page *page, int order)
 	if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
 		page_counter_uncharge(&memcg->kmem, nr_pages);
 
-	page_counter_uncharge(&memcg->memory, nr_pages);
-	if (do_memsw_account())
-		page_counter_uncharge(&memcg->memsw, nr_pages);
-
 	page->mem_cgroup = NULL;
 
 	/* slab pages do not have PageKmemcg flag set */
 	if (PageKmemcg(page))
 		__ClearPageKmemcg(page);
 
-	css_put_many(&memcg->css, nr_pages);
+	refill_stock(memcg, nr_pages);
 }
 #endif /* CONFIG_MEMCG_KMEM */
 
Signature · 1 line
2.21.0.593.g511ec345e18-goog
Signature · 2 lines
Michal Hocko
SUSE Labs
#2 lore raw
Quoted 9 lines · Michal Hocko
Quoted 6 lines · Shakeel Butt

The commit 475d0487a2ad ("mm: memcontrol: use per-cpu stocks for socket memory uncharging") added refill_stock() for skmem uncharging path to optimize workloads having high network traffic. Do the same for the kmem uncharging as well. Though we can bypass the refill for the offlined memcgs but it may impact the performance of network traffic for the sockets used by other cgroups.

Quoted 4 lines

While the change makes sense, I would really like to see what kind of effect on performance does it really have. Do you have any specific workload that benefits from it?

Thanks for the review. I will run some benchmarks and report back later.

Shakeel