Vladimir Davydov 05257a1a3d memcg: add rwsem to synchronize against memcg_caches arrays relocation
We need a stable value of memcg_nr_cache_ids in kmem_cache_create()
(memcg_alloc_cache_params() wants it for root caches), where we only
hold the slab_mutex and no memcg-related locks.  As a result, we have to
update memcg_nr_cache_ids under the slab_mutex, which we can only take
on the slab's side (see memcg_update_array_size).  This looks awkward
and will become even worse when per-memcg list_lru is introduced, which
also wants stable access to memcg_nr_cache_ids.

To get rid of this dependency between the memcg_nr_cache_ids and the
slab_mutex, this patch introduces a special rwsem.  The rwsem is held
for writing during memcg_caches arrays relocation and memcg_nr_cache_ids
updates.  Therefore one can take it for reading to get a stable access
to memcg_caches arrays and/or memcg_nr_cache_ids.

Currently the semaphore is taken for reading only from
kmem_cache_create, right before taking the slab_mutex, so right now
there's no much point in using rwsem instead of mutex.  However, once
list_lru is made per-memcg it will allow list_lru initializations to
proceed concurrently.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Greg Thelen <gthelen@google.com>
Cc: Glauber Costa <glommer@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-02-12 18:54:09 -08:00
..
2014-09-22 16:48:47 +09:00
2014-12-14 14:57:16 -08:00
2014-12-02 16:20:59 -08:00
2014-11-24 17:24:08 -05:00
2014-12-15 18:19:03 -08:00
2015-02-11 10:56:48 -08:00
2014-11-25 20:11:12 -08:00
2015-02-11 10:28:45 -08:00
2015-01-29 10:49:28 +02:00
2014-12-14 14:57:16 -08:00
2014-12-14 16:10:09 -08:00
2014-12-18 19:08:10 -08:00
2014-12-14 16:10:09 -08:00
2014-12-19 22:55:06 +01:00
2014-12-14 16:10:09 -08:00
2014-07-08 13:36:52 -07:00
2015-01-21 19:21:30 +01:00
2014-11-10 09:27:30 -07:00
2015-02-11 18:03:54 -08:00
2014-11-04 17:34:15 -08:00
2014-12-31 13:06:50 -05:00
2014-10-09 11:35:48 +03:00
2014-10-08 16:01:41 -04:00
2014-08-07 14:40:08 -04:00
2014-04-18 14:20:48 +02:00
2014-08-06 18:01:24 -07:00
2014-05-20 10:30:40 +09:00
2014-06-06 16:08:13 -07:00
2015-01-27 11:09:13 +01:00
2014-09-29 15:37:01 -04:00
2014-06-02 14:56:01 -07:00
2014-12-16 14:53:01 -08:00
2015-01-15 10:34:54 +01:00
2015-01-15 10:34:54 +01:00
2014-07-22 21:55:45 +01:00
2015-01-24 10:11:12 +01:00
2014-12-18 09:39:51 +01:00
2015-01-04 23:11:43 -05:00
2014-05-27 17:38:11 -07:00
2015-02-12 18:54:09 -08:00
2014-10-09 22:25:58 -04:00
2015-02-11 17:06:02 -08:00
2014-10-24 00:14:36 +02:00
2014-11-04 13:18:52 -07:00
2014-11-04 13:29:38 +00:00
2014-12-11 13:06:58 -08:00
2014-06-10 14:35:22 -07:00
2014-12-14 14:57:16 -08:00
2014-07-09 14:58:37 +01:00
2015-02-11 18:15:38 -08:00
2015-01-06 11:01:13 -08:00
2014-08-08 15:57:26 -07:00
2014-08-08 15:57:31 -07:00
2015-01-22 15:10:56 +01:00
2015-01-03 14:32:57 -05:00
2014-06-12 00:21:11 -04:00
2014-06-04 16:53:57 -07:00
2014-08-08 15:57:24 -07:00
2014-06-04 16:53:56 -07:00
2014-11-06 14:57:27 -08:00
2014-09-23 21:40:48 -07:00
2014-11-28 16:08:16 +01:00
2014-09-16 15:02:55 -06:00
2014-12-09 12:05:24 +02:00
2014-06-04 16:53:57 -07:00
2014-12-15 23:49:28 +02:00