linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Emelianov <xemul@sw.ru>
To: Andrew Morton <akpm@osdl.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devel@openvz.org
Subject: [PATCH 14/15] Make /proc/slabinfo use seq_list_xxx helpers
Date: Fri, 18 May 2007 14:11:36 +0400	[thread overview]
Message-ID: <464D7BD8.9020000@sw.ru> (raw)
In-Reply-To: <464D6E87.7060605@sw.ru>

This entry prints a header in .start callback. This is OK,
but the more elegant solution would be to move this into the
.show callback and use seq_list_start_head() in .start one.

I have left it as is in order to make the patch just switch
to new API and noting more.

Signed-off-by: Pavel Emelianov <xemul@openvz.org>

---

diff --git a/mm/slab.c b/mm/slab.c
index 6edfd34..faad0d7 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4161,26 +4161,17 @@ static void print_slabinfo_header(struct
 static void *s_start(struct seq_file *m, loff_t *pos)
 {
 	loff_t n = *pos;
-	struct list_head *p;
 
 	mutex_lock(&cache_chain_mutex);
 	if (!n)
 		print_slabinfo_header(m);
-	p = cache_chain.next;
-	while (n--) {
-		p = p->next;
-		if (p == &cache_chain)
-			return NULL;
-	}
-	return list_entry(p, struct kmem_cache, next);
+
+	return seq_list_start(&cache_chain, *pos);
 }
 
 static void *s_next(struct seq_file *m, void *p, loff_t *pos)
 {
-	struct kmem_cache *cachep = p;
-	++*pos;
-	return cachep->next.next == &cache_chain ?
-		NULL : list_entry(cachep->next.next, struct kmem_cache, next);
+	return seq_list_next(p, &cache_chain, pos);
 }
 
 static void s_stop(struct seq_file *m, void *p)
@@ -4190,7 +4181,7 @@ static void s_stop(struct seq_file *m, v
 
 static int s_show(struct seq_file *m, void *p)
 {
-	struct kmem_cache *cachep = p;
+	struct kmem_cache *cachep = list_entry(p, struct kmem_cache, next);
 	struct slab *slabp;
 	unsigned long active_objs;
 	unsigned long num_objs;
@@ -4359,17 +4350,8 @@ ssize_t slabinfo_write(struct file *file
 
 static void *leaks_start(struct seq_file *m, loff_t *pos)
 {
-	loff_t n = *pos;
-	struct list_head *p;
-
 	mutex_lock(&cache_chain_mutex);
-	p = cache_chain.next;
-	while (n--) {
-		p = p->next;
-		if (p == &cache_chain)
-			return NULL;
-	}
-	return list_entry(p, struct kmem_cache, next);
+	return seq_list_start(&cache_chain, *pos);
 }
 
 static inline int add_caller(unsigned long *n, unsigned long v)

  parent reply	other threads:[~2007-05-18 10:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-18  9:14 [PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2) Pavel Emelianov
2007-05-18  9:21 ` [PATCH 1/15] The helper functions itselves Pavel Emelianov
2007-05-18  9:25 ` [PATCH 2/15] Make AFS use seq_list_xxx helpers Pavel Emelianov
2007-05-18  9:28 ` [PATCH 3/15] Make ATM driver " Pavel Emelianov
2007-05-18  9:32 ` [PATCH 4/15] Make block layer /proc files " Pavel Emelianov
2007-05-18  9:34 ` [PATCH 5/15] Make crypto API " Pavel Emelianov
2007-05-18 10:13   ` Herbert Xu
2007-05-18  9:37 ` [PATCH 6/15] Make input layer " Pavel Emelianov
2007-05-18  9:41 ` [PATCH 7/15] Make ISDN CAPI " Pavel Emelianov
2007-05-18  9:43 ` [PATCH 8/15] Make /proc/misc " Pavel Emelianov
2007-05-18  9:46 ` [PATCH 9/15] Make /proc/modules " Pavel Emelianov
2007-05-18  9:53 ` [PATCH 10/15] Make some network-related proc files " Pavel Emelianov
2007-05-18 10:24   ` David Miller
2007-05-18  9:59 ` [PATCH 1/15] The helper functions itselves David Howells
2007-05-18 10:00 ` [PATCH 11/15] Make some netfilter-related proc files use seq_list_xxx helpers Pavel Emelianov
2007-05-18 10:04 ` [PATCH 12/15] Make NFS client " Pavel Emelianov
2007-05-18 17:42   ` Trond Myklebust
2007-05-18 10:07 ` [PATCH 13/15] Make /proc/tty/drivers " Pavel Emelianov
2007-05-18 10:11 ` Pavel Emelianov [this message]
2007-05-18 10:14 ` [PATCH 15/15] Make /proc/self/mounts(tats) " Pavel Emelianov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=464D7BD8.9020000@sw.ru \
    --to=xemul@sw.ru \
    --cc=akpm@osdl.org \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).