From e9988670a96282901b203bb41b0977067c92ed9d Mon Sep 17 00:00:00 2001 From: Carsten Emde <C.Emde@osadl.org> 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 <C.Emde@osadl.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- mm/slab_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) @ mm/slab_common.c:546 @ 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); @ mm/slab_common.c:559 @ 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 @ mm/slab_common.c:571 @ 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) @ mm/slab_common.c:586 @ 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