public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@openvz.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Pavel Emelyanov <xemul@parallels.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [PATCH -mm] procfs: add VmFlags field in smaps output v3
Date: Thu, 25 Oct 2012 00:41:13 +0400	[thread overview]
Message-ID: <20121024204113.GZ30983@moon> (raw)
In-Reply-To: <20121024133652.39ede022.akpm@linux-foundation.org>

On Wed, Oct 24, 2012 at 01:36:52PM -0700, Andrew Morton wrote:
> > ...
> >
> > +	for_each_set_bit(i, &vma->vm_flags, BITS_PER_LONG) {
> 
> for_each_set_bit() seems to be rather sucky.  Going back to 
> 
> --- a/fs/proc/task_mmu.c~a-fix
> +++ a/fs/proc/task_mmu.c
> @@ -568,10 +568,11 @@ static void show_smap_vma_flags(struct s
>  	size_t i;
>  
>  	seq_puts(m, "VmFlags: ");
> -	for_each_set_bit(i, &vma->vm_flags, BITS_PER_LONG) {
> -		seq_printf(m, "%c%c ",
> -			   mnemonics[i][0],
> -			   mnemonics[i][1]);
> +	for (i = 0; i < BITS_PER_LONG; i++) {
> +		if (vma->vm_flags & (1UL << i)) {
> +			seq_printf(m, "%c%c ",
> +				   mnemonics[i][0], mnemonics[i][1]);
> +		}
>  	}
>  	seq_putc(m, '\n');
>  }
> 
> saves 41 bytes.  That's rather a lot for such a small code sequence.

OK, bits-per-long is not a big value here, neither the function is time
critical one, so thanks!

      reply	other threads:[~2012-10-24 20:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24 12:27 [PATCH -mm] procfs: add VmFlags field in smaps output v3 Cyrill Gorcunov
2012-10-24 12:47 ` Stephen Rothwell
2012-10-24 12:56   ` Cyrill Gorcunov
2012-10-24 20:36 ` Andrew Morton
2012-10-24 20:41   ` Cyrill Gorcunov [this message]

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=20121024204113.GZ30983@moon \
    --to=gorcunov@openvz.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=xemul@parallels.com \
    /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