[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20121024204113.GZ30983@moon>
Date: Thu, 25 Oct 2012 00:41:13 +0400
From: Cyrill Gorcunov <gorcunov@...nvz.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Pavel Emelyanov <xemul@...allels.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Stephen Rothwell <sfr@...b.auug.org.au>
Subject: Re: [PATCH -mm] procfs: add VmFlags field in smaps output v3
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!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists