linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, memcg: assign shrinker_map before kvfree
@ 2019-09-20 12:29 Cyrill Gorcunov
  2019-09-20 13:21 ` Kirill A. Shutemov
  2019-09-20 14:11 ` Kirill Tkhai
  0 siblings, 2 replies; 6+ messages in thread
From: Cyrill Gorcunov @ 2019-09-20 12:29 UTC (permalink / raw)
  To: LKML
  Cc: Linux MM, Johannes Weiner, Michal Hocko, Vladimir Davydov, Kirill Tkhai

Currently there is a small gap between fetching pointer, calling
kvfree and assign its value to nil. In current callgraph it is
not a problem (since memcg_free_shrinker_maps is running from
memcg_alloc_shrinker_maps and mem_cgroup_css_free only) still
this looks suspicious and we can easily eliminate the gap at all.

Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 mm/memcontrol.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-tip.git/mm/memcontrol.c
===================================================================
--- linux-tip.git.orig/mm/memcontrol.c
+++ linux-tip.git/mm/memcontrol.c
@@ -364,9 +364,9 @@ static void memcg_free_shrinker_maps(str
 	for_each_node(nid) {
 		pn = mem_cgroup_nodeinfo(memcg, nid);
 		map = rcu_dereference_protected(pn->shrinker_map, true);
+		rcu_assign_pointer(pn->shrinker_map, NULL);
 		if (map)
 			kvfree(map);
-		rcu_assign_pointer(pn->shrinker_map, NULL);
 	}
 }
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-20 14:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20 12:29 [PATCH] mm, memcg: assign shrinker_map before kvfree Cyrill Gorcunov
2019-09-20 13:21 ` Kirill A. Shutemov
2019-09-20 13:40   ` Cyrill Gorcunov
2019-09-20 14:20   ` Kirill Tkhai
2019-09-20 14:11 ` Kirill Tkhai
2019-09-20 14:31   ` Cyrill Gorcunov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).