aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@parallels.com>2014-12-10 18:42:16 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 20:41:04 -0500
commit1df3b26f201f7f08852c14596bc3ee6ba1826f11 (patch)
tree8eaf11024072d71c3701bc5d25e5d27f446f2ae1
parentb455def28d8a22aee4a13d065b3fd1d296833606 (diff)
slab: print slabinfo header in seq show
Currently we print the slabinfo header in the seq start method, which makes it unusable for showing leaks, so we have leaks_show, which does practically the same as s_show except it doesn't show the header. However, we can print the header in the seq show method - we only need to check if the current element is the first on the list. This will allow us to use the same set of seq iterators for both leaks and slabinfo reporting, which is nice. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> 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: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--mm/slab.c8
-rw-r--r--mm/slab.h1
-rw-r--r--mm/slab_common.c15
3 files changed, 8 insertions, 16 deletions
diff --git a/mm/slab.c b/mm/slab.c
index eae2d21cc14f..a2152a2573dd 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4043,12 +4043,6 @@ ssize_t slabinfo_write(struct file *file, const char __user *buffer,
4043 4043
4044#ifdef CONFIG_DEBUG_SLAB_LEAK 4044#ifdef CONFIG_DEBUG_SLAB_LEAK
4045 4045
4046static void *leaks_start(struct seq_file *m, loff_t *pos)
4047{
4048 mutex_lock(&slab_mutex);
4049 return seq_list_start(&slab_caches, *pos);
4050}
4051
4052static inline int add_caller(unsigned long *n, unsigned long v) 4046static inline int add_caller(unsigned long *n, unsigned long v)
4053{ 4047{
4054 unsigned long *p; 4048 unsigned long *p;
@@ -4170,7 +4164,7 @@ static int leaks_show(struct seq_file *m, void *p)
4170} 4164}
4171 4165
4172static const struct seq_operations slabstats_op = { 4166static const struct seq_operations slabstats_op = {
4173 .start = leaks_start, 4167 .start = slab_start,
4174 .next = slab_next, 4168 .next = slab_next,
4175 .stop = slab_stop, 4169 .stop = slab_stop,
4176 .show = leaks_show, 4170 .show = leaks_show,
diff --git a/mm/slab.h b/mm/slab.h
index ab019e63e3c2..53a55c70c409 100644
--- a/mm/slab.h
+++ b/mm/slab.h
@@ -357,6 +357,7 @@ static inline struct kmem_cache_node *get_node(struct kmem_cache *s, int node)
357 357
358#endif 358#endif
359 359
360void *slab_start(struct seq_file *m, loff_t *pos);
360void *slab_next(struct seq_file *m, void *p, loff_t *pos); 361void *slab_next(struct seq_file *m, void *p, loff_t *pos);
361void slab_stop(struct seq_file *m, void *p); 362void slab_stop(struct seq_file *m, void *p);
362 363
diff --git a/mm/slab_common.c b/mm/slab_common.c
index dcdab81bd240..06aeaf091f21 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -834,14 +834,9 @@ void print_slabinfo_header(struct seq_file *m)
834 seq_putc(m, '\n'); 834 seq_putc(m, '\n');
835} 835}
836 836
837static void *s_start(struct seq_file *m, loff_t *pos) 837void *slab_start(struct seq_file *m, loff_t *pos)
838{ 838{
839 loff_t n = *pos;
840
841 mutex_lock(&slab_mutex); 839 mutex_lock(&slab_mutex);
842 if (!n)
843 print_slabinfo_header(m);
844
845 return seq_list_start(&slab_caches, *pos); 840 return seq_list_start(&slab_caches, *pos);
846} 841}
847 842
@@ -903,10 +898,12 @@ int cache_show(struct kmem_cache *s, struct seq_file *m)
903 return 0; 898 return 0;
904} 899}
905 900
906static int s_show(struct seq_file *m, void *p) 901static int slab_show(struct seq_file *m, void *p)
907{ 902{
908 struct kmem_cache *s = list_entry(p, struct kmem_cache, list); 903 struct kmem_cache *s = list_entry(p, struct kmem_cache, list);
909 904
905 if (p == slab_caches.next)
906 print_slabinfo_header(m);
910 if (!is_root_cache(s)) 907 if (!is_root_cache(s))
911 return 0; 908 return 0;
912 return cache_show(s, m); 909 return cache_show(s, m);
@@ -926,10 +923,10 @@ static int s_show(struct seq_file *m, void *p)
926 * + further values on SMP and with statistics enabled 923 * + further values on SMP and with statistics enabled
927 */ 924 */
928static const struct seq_operations slabinfo_op = { 925static const struct seq_operations slabinfo_op = {
929 .start = s_start, 926 .start = slab_start,
930 .next = slab_next, 927 .next = slab_next,
931 .stop = slab_stop, 928 .stop = slab_stop,
932 .show = s_show, 929 .show = slab_show,
933}; 930};
934 931
935static int slabinfo_open(struct inode *inode, struct file *file) 932static int slabinfo_open(struct inode *inode, struct file *file)