From e9988670a96282901b203bb41b0977067c92ed9d Mon Sep 17 00:00:00 2001 From: Carsten Emde Date: Sat, 29 Jun 2013 15:28:27 +0100 Subject: [PATCH 4/6] Reading /proc/slabinfo may cause large latencies Reading /proc/slabinfo may cause large latencies of up to several milliseconds. This is due to a mutex lock that spans over the entire readout period and, thus, may prevent a higher-priority process from allocating memory during this amount of time. This patch shortens the mutex lock to the data accumulation of a single item. It still guarantees coherence of a single output line but not across items which probably is a minor disadvantage compared to the otherwise fatal effect on the system's real-time capabilities. Signed-off-by: Carsten Emde Signed-off-by: Sebastian Andrzej Siewior --- mm/slab_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index e2e98af..6a5a8ed 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -543,7 +543,6 @@ static void *s_start(struct seq_file *m, loff_t *pos) { loff_t n = *pos; - mutex_lock(&slab_mutex); if (!n) print_slabinfo_header(m); @@ -557,7 +556,6 @@ void *slab_next(struct seq_file *m, void *p, loff_t *pos) void slab_stop(struct seq_file *m, void *p) { - mutex_unlock(&slab_mutex); } static void @@ -570,6 +568,7 @@ memcg_accumulate_slabinfo(struct kmem_cache *s, struct slabinfo *info) if (!is_root_cache(s)) return; + mutex_lock(&slab_mutex); for_each_memcg_cache_index(i) { c = cache_from_memcg(s, i); if (!c) @@ -584,6 +583,7 @@ memcg_accumulate_slabinfo(struct kmem_cache *s, struct slabinfo *info) info->active_objs += sinfo.active_objs; info->num_objs += sinfo.num_objs; } + mutex_unlock(&slab_mutex); } int cache_show(struct kmem_cache *s, struct seq_file *m) -- 1.9.0