All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] [PATCH 4/9] Create helper for /proc/slabinfo
Date: Fri, 11 Nov 2005 08:18:43 +0000	[thread overview]
Message-ID: <437453E3.3040703@bfs.de> (raw)
In-Reply-To: <4373DF5D.8050106@us.ibm.com>

hi Matthew,
just to have less #if in the code. it maybe usefull to make something 
like that in the beginning:

#if STATS
#define STATS_VERSION "slabinfo - version: 2.1 (statistics)"
#else
#define STATS_VERSION "slabinfo - version: 2.1"
#endif
note i have silently droped "\n" are they realy needed ?

re,
   walter

Matthew Dobson wrote:
> Most of the s_start() function body is just printing out a header for
> /proc/slabinfo.  Move it to its own function.
> 
> -Matt
> 
> 
> ------------------------------------------------------------------------
> 
> In s_start(), if we're at the beginning of printing out /proc/slabinfo, we
> print out a header with version info and descriptions of the fields.  This
> is indented and takes up a lot of space in an otherwise tiny fuction.
> 
> Create a helper, print_slabinfo_header(), that s_start() can call to
> print out it's header.  Remove several long lines, and make both functions
> more readable.
> 
> Signed-off-by: Matthew Dobson <colpatch@us.ibm.com>
> 
> Index: linux-2.6.14+slab_cleanup/mm/slab.c
> =================================> --- linux-2.6.14+slab_cleanup.orig/mm/slab.c	2005-11-10 11:43:40.223347016 -0800
> +++ linux-2.6.14+slab_cleanup/mm/slab.c	2005-11-10 11:43:42.198046816 -0800
> @@ -3378,32 +3378,37 @@ next:
>  
>  #ifdef CONFIG_PROC_FS
>  
> -static void *s_start(struct seq_file *m, loff_t *pos)
> +static inline void print_slabinfo_header(struct seq_file *m)
>  {
> -	loff_t n = *pos;
> -	struct list_head *p;
> -
> -	down(&cache_chain_sem);
> -	if (!n) {
> -		/*
> -		 * Output format version, so at least we can change it
> -		 * without _too_ many complaints.
> -		 */
> +	/*
> +	 * Output format version, so at least we can change it
> +	 * without _too_ many complaints.
> +	 */
>  #if STATS
> -		seq_puts(m, "slabinfo - version: 2.1 (statistics)\n");
> +	seq_puts(m, "slabinfo - version: 2.1 (statistics)\n");
>  #else
> -		seq_puts(m, "slabinfo - version: 2.1\n");
> +	seq_puts(m, "slabinfo - version: 2.1\n");
>  #endif
> -		seq_puts(m, "# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab>");
> -		seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
> -		seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
> +	seq_puts(m, "# name            <active_objs> <num_objs> <objsize> "
> +		 "<objperslab> <pagesperslab>");
> +	seq_puts(m, " : tunables <limit> <batchcount> <sharedfactor>");
> +	seq_puts(m, " : slabdata <active_slabs> <num_slabs> <sharedavail>");
>  #if STATS
> -		seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped>"
> -				" <error> <maxfreeable> <nodeallocs> <remotefrees>");
> -		seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
> +	seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
> +		 "<error> <maxfreeable> <nodeallocs> <remotefrees>");
> +	seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
>  #endif
> -		seq_putc(m, '\n');
> -	}
> +	seq_putc(m, '\n');
> +}
> +
> +static void *s_start(struct seq_file *m, loff_t *pos)
> +{
> +	loff_t n = *pos;
> +	struct list_head *p;
> +
> +	down(&cache_chain_sem);
> +	if (!n)
> +		print_slabinfo_header(m);
>  	p = cache_chain.next;
>  	while (n--) {
>  		p = p->next;
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Kernel-janitors mailing list
> Kernel-janitors@lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/kernel-janitors
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

  reply	other threads:[~2005-11-11  8:18 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-10 23:53 [KJ] [PATCH 0/9] Cleanup mm/slab.c v2 Matthew Dobson
2005-11-10 23:53 ` Matthew Dobson
2005-11-10 23:56 ` [KJ] [PATCH 1/9] CodingStyle-ify mm/slab.c Matthew Dobson
2005-11-10 23:56   ` Matthew Dobson
2005-11-10 23:58 ` [KJ] [PATCH 2/9] Use 'nid' Matthew Dobson
2005-11-10 23:58   ` Matthew Dobson
2005-11-13 20:15   ` [KJ] " Pavel Machek
2005-11-13 20:15     ` Pavel Machek
2005-11-10 23:59 ` [KJ] [PATCH 3/9] Fix alloc_percpu's args Matthew Dobson
2005-11-10 23:59   ` Matthew Dobson
2005-11-11  0:01 ` [KJ] [PATCH 4/9] Create helper for /proc/slabinfo Matthew Dobson
2005-11-11  0:01   ` Matthew Dobson
2005-11-11  8:18   ` walter harms [this message]
2005-11-11 18:19   ` [KJ] " Matthew Dobson
2005-11-11  0:03 ` [KJ] [PATCH 5/9] Create helper for kmem_cache_create() Matthew Dobson
2005-11-11  0:03   ` Matthew Dobson
2005-11-11  8:10   ` [KJ] " walter harms
2005-11-11 18:25   ` Matthew Dobson
2005-11-11  0:04 ` [KJ] [PATCH 6/9] Cleanup kmem_cache_create() Matthew Dobson
2005-11-11  0:04   ` Matthew Dobson
2005-11-11  8:10   ` [KJ] " Ingo Oeser
2005-11-11  8:10     ` Ingo Oeser
2005-11-11 18:28     ` [KJ] " Matthew Dobson
2005-11-11 18:28       ` Matthew Dobson
2005-11-11 23:46     ` [KJ] " Håkon Løvdal
2005-11-11  0:05 ` [KJ] [PATCH 7/9] Cleanup cache_reap() Matthew Dobson
2005-11-11  0:05   ` Matthew Dobson
2005-11-11  0:06 ` [KJ] [PATCH 8/9] Cleanup slabinfo_write() Matthew Dobson
2005-11-11  0:06   ` Matthew Dobson
2005-11-11  0:07 ` [KJ] [PATCH 9/9] Cleanup a loop in set_slab_attr() Matthew Dobson
2005-11-11  0:07   ` Matthew Dobson
2005-11-11  7:29 ` [KJ] Re: [PATCH 0/9] Cleanup mm/slab.c v2 Pekka J Enberg
2005-11-11  7:29   ` Pekka J Enberg

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=437453E3.3040703@bfs.de \
    --to=wharms@bfs.de \
    --cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.