Re: [PATCH -mm] procfs: add VmFlags field in smaps output v3

From: Cyrill Gorcunov
Date: Wed Oct 24 2012 - 16:41:08 EST


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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/