Re: [rfc 0/2] Introducing VmFlags field into smaps output

From: Cyrill Gorcunov
Date: Tue Oct 23 2012 - 17:46:34 EST


On Tue, Oct 23, 2012 at 02:30:45PM -0700, Andrew Morton wrote:
> >
> > The data is encoded in a somewhat awkward two letters mnemonic form, to
> > encourage userspace to be prepared for fields being added or removed in
> > the future.
> >
>
> Wow. This version generates 1k less kernel bloat than v2! Gee, and I
> only sent that email as a late-night joke ;)

Cool!

> fs/proc/task_mmu.o with neither patch:
> text data bss dec hex filename
> 14849 112 5312 20273 4f31 fs/proc/task_mmu.o
>
> fs/proc/task_mmu.o with the v2 patch:
> 16074 112 5776 21962 55ca fs/proc/task_mmu.o
>
> fs/proc/task_mmu.o with the v3 patch:
> 15446 112 5368 20926 51be fs/proc/task_mmu.o
>
> fs/proc/task_mmu.o with the v3 patch and the below fix:
> 15123 112 5352 20587 506b fs/proc/task_mmu.o
>
> So the delta has gone from 1700 bytes down to 300. Seems that it pays
> to be anal about these things ;)

LOL ;-)

> Don't forget the `static'! Without it, the compiler will need to

Yeah, for some reason missed it, thanks!

> construct the array as a temporary on the stack each time the function
> is called - it's just terrible. (There's no reason why the compiler
> can't insert the static for us as an optimisation, and I think later
> gcc's may have got smarter about this).
>
> Was there a reason why you added the ".l = " to the initialiser? My
> gcc is happy without it.

Mine either, just as habbit I would say, thanks.

> Also... what happens if there's an unrecognised bit set in `flags'?
> Memory corruption or code skew could cause this. We emit a couple of
> NULs into the procfs output, which I guess is an OK response to such a
> condition.

That's indeed will produce some nil character on the screen. I guess we
need some designited init here, say

[0 ... (BITS_PER_LONG-1)] = { {'-', '-'} },
...
[ilog2(VM_READ)] = { {'r', 'd'} },
...
and so on, i'll update on top

> From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Subject: procfs-add-vmflags-field-in-smaps-output-v3-fix
>
> make mnemonics[] static, remove unneeded init code, tidy whitespace
>
--
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/