From: Andrew Morton <akpm@linux-foundation.org>
To: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Pavel Emelyanov <xemul@parallels.com>,
LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [rfc 0/2] Introducing VmFlags field into smaps output
Date: Mon, 22 Oct 2012 14:51:58 -0700 [thread overview]
Message-ID: <20121022145158.53bddfc1.akpm@linux-foundation.org> (raw)
In-Reply-To: <20121022213449.GH31440@moon>
On Tue, 23 Oct 2012 01:34:49 +0400
Cyrill Gorcunov <gorcunov@openvz.org> wrote:
>
> ...
>
> +VmFlags: rd ex mr mw me de
ho hum OK, let's do that.
> +static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
> +{
> + /*
> + * Don't forget to update Documentation/ on changes.
> + */
> +
> +#define __seq_show_vmflag(_f, _s) \
> + do { \
> + if (vma->vm_flags & (_f)) \
> + seq_puts(m, _s); \
> + } while (0)
> +
> + seq_puts(m, "VmFlags: ");
> +
> + __seq_show_vmflag(VM_READ, "rd ");
> + __seq_show_vmflag(VM_WRITE, "wr ");
> + __seq_show_vmflag(VM_EXEC, "ex ");
> + __seq_show_vmflag(VM_SHARED, "sh ");
> + __seq_show_vmflag(VM_MAYREAD, "mr ");
> + __seq_show_vmflag(VM_MAYWRITE, "mw ");
> + __seq_show_vmflag(VM_MAYEXEC, "me ");
> + __seq_show_vmflag(VM_MAYSHARE, "ms ");
> + __seq_show_vmflag(VM_GROWSDOWN, "gd ");
> + __seq_show_vmflag(VM_PFNMAP, "pf ");
> + __seq_show_vmflag(VM_DENYWRITE, "dw ");
> + __seq_show_vmflag(VM_LOCKED, "lo ");
> + __seq_show_vmflag(VM_IO, "io ");
> + __seq_show_vmflag(VM_SEQ_READ, "sr ");
> + __seq_show_vmflag(VM_RAND_READ, "rr ");
> + __seq_show_vmflag(VM_DONTCOPY, "dc ");
> + __seq_show_vmflag(VM_DONTEXPAND,"de ");
> + __seq_show_vmflag(VM_ACCOUNT, "ac ");
> + __seq_show_vmflag(VM_NORESERVE, "nr ");
> + __seq_show_vmflag(VM_HUGETLB, "ht ");
> + __seq_show_vmflag(VM_NONLINEAR, "nl ");
> + __seq_show_vmflag(VM_ARCH_1, "ar ");
> + __seq_show_vmflag(VM_DONTDUMP, "dd ");
> + __seq_show_vmflag(VM_MIXEDMAP, "mm ");
> + __seq_show_vmflag(VM_HUGEPAGE, "hg ");
> + __seq_show_vmflag(VM_NOHUGEPAGE,"nh ");
> + __seq_show_vmflag(VM_MERGEABLE, "mg ");
> +
> + seq_putc(m, '\n');
> +
> +#undef __seq_show_vmflag
> +}
This code would be much denser if we did the old
static const char foo[] = "rdwrexshmrmw...";
unsigned i;
for (i = 0; i < BITS_PER_LONG; i++) {
if (flags & (1 << i))
seq_printf("%c%c ", foo[i * 2], foo[i * 2 + 1]);
}
trick. But then we'd have to remember to fix foo[] each time we
alter the flags, so maybe let's not do that.
next prev parent reply other threads:[~2012-10-22 21:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-22 19:14 [rfc 0/2] Introducing VmFlags field into smaps output Cyrill Gorcunov
2012-10-22 19:14 ` [rfc 1/2] [RFC] procfs: Add VmFlags field in " Cyrill Gorcunov
2012-10-22 19:14 ` [rfc 2/2] [RFC] procfs: Documantation -- Add VmFlags field description Cyrill Gorcunov
2012-10-22 19:29 ` [rfc 0/2] Introducing VmFlags field into smaps output Andrew Morton
2012-10-22 19:39 ` Cyrill Gorcunov
2012-10-22 20:50 ` Pavel Emelyanov
2012-10-22 20:56 ` Cyrill Gorcunov
2012-10-22 21:34 ` Cyrill Gorcunov
2012-10-22 21:51 ` Andrew Morton [this message]
2012-10-23 6:13 ` Cyrill Gorcunov
2012-10-23 6:30 ` Andrew Morton
2012-10-23 6:34 ` Cyrill Gorcunov
2012-10-23 7:15 ` Cyrill Gorcunov
2012-10-23 21:30 ` Andrew Morton
2012-10-23 21:46 ` Cyrill Gorcunov
2012-10-23 21:59 ` Cyrill Gorcunov
2012-10-23 22:32 ` Peter Zijlstra
2012-10-23 23:56 ` Stephen Rothwell
2012-10-24 6:30 ` Cyrill Gorcunov
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=20121022145158.53bddfc1.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=a.p.zijlstra@chello.nl \
--cc=gorcunov@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).