public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Cyrill Gorcunov <gorcunov@openvz.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: Wed, 24 Oct 2012 13:36:52 -0700	[thread overview]
Message-ID: <20121024133652.39ede022.akpm@linux-foundation.org> (raw)
In-Reply-To: <20121024122730.GO30983@moon>

On Wed, 24 Oct 2012 16:27:30 +0400
Cyrill Gorcunov <gorcunov@openvz.org> wrote:

> During c/r sessions we've found that there is no way at the moment to
> fetch some VMA associated flags, such as mlock() and madvise().
> 
> This leads us to a problem -- we don't know if we should call for mlock()
> and/or madvise() after restore on the vma area we're bringing back to
> life.
> 
> This patch intorduces a new field into "smaps" output called VmFlags,
> where all set flags associated with the particular VMA is shown as two
> letter mnemonics.
> 
> [ Strictly speaking for c/r we only need mlock/madvise bits but it has been
>   said that providing just a few flags looks somehow inconsistent.  So all
>   flags are here now. ]
> 
> This feature is made available on CONFIG_CHECKPOINT_RESTORE=n kernels, as
> other applications may start to use these fields.
> 
> 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.
> 
> ...
>
> +	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.

  parent reply	other threads:[~2012-10-24 20:36 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 [this message]
2012-10-24 20:41   ` 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=20121024133652.39ede022.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=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