linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@parallels.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Linux MM <linux-mm@kvack.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH 0/5] mm: Ability to monitor task memory changes (v3)
Date: Thu, 11 Apr 2013 15:28:31 +0400	[thread overview]
Message-ID: <51669E5F.4000801@parallels.com> (raw)

Hello,

This is the implementation of the soft-dirty bit concept that should help
keep track of changes in user memory, which in turn is very-very required by
the checkpoint-restore project (http://criu.org). Let me briefly remind what
the issue is.

<< EOF
To create a dump of an application(s) we save all the information about it
to files, and the biggest part of such dump is the contents of tasks' memory.
However, there are usage scenarios where it's not required to get _all_ the
task memory while creating a dump. For example, when doing periodical dumps,
it's only required to take full memory dump only at the first step and then
take incremental changes of memory. Another example is live migration. We 
copy all the memory to the destination node without stopping all tasks, then
stop them, check for what pages has changed, dump it and the rest of the state,
then copy it to the destination node. This decreases freeze time significantly.

That said, some help from kernel to watch how processes modify the contents
of their memory is required.
EOF

The proposal is to track changes with the help of new soft-dirty bit this way:

1. First do "echo 4 > /proc/$pid/clear_refs".
   At that point kernel clears the soft dirty _and_ the writable bits from all 
   ptes of process $pid. From now on every write to any page will result in #pf 
   and the subsequent call to pte_mkdirty/pmd_mkdirty, which in turn will set
   the soft dirty flag.

2. Then read the /proc/$pid/pagemap2 and check the soft-dirty bit reported there
   (the 55'th one). If set, the respective pte was written to since last call
   to clear refs.

The soft-dirty bit is the _PAGE_BIT_HIDDEN one. Although it's used by kmemcheck,
the latter one marks kernel pages with it, while the former bit is put on user 
pages so they do not conflict to each other.

The set is against the v3.9-rc5.
It includes preparations to /proc/pid's clear_refs file, adds the pagemap2 one
and the soft-dirty concept itself with Andrew's comments on the previous patch 
(hopefully) fixed.


History of the set:

* Previous version of this patch, commented out by Andrew:
  http://lwn.net/Articles/546184/

* Pre-previous ftrace-based approach:
  http://permalink.gmane.org/gmane.linux.kernel.mm/91428

  This one was not nice, because ftrace could drop events so we might
  miss significant information about page updates.

  Another issue with it -- it was impossible to use one to watch arbitrary
  task -- task had to mark memory areas with madvise itself to make events
  occur.

  Also, program, that monitored the update events could interfere with 
  anyone else trying to mess with ftrace.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>

             reply	other threads:[~2013-04-11 11:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 11:28 Pavel Emelyanov [this message]
2013-04-11 11:28 ` [PATCH 1/5] clear_refs: Sanitize accepted commands declaration Pavel Emelyanov
2013-04-11 21:17   ` Andrew Morton
2013-04-11 11:29 ` [PATCH 2/5] clear_refs: Introduce private struct for mm_walk Pavel Emelyanov
2013-04-11 11:29 ` [PATCH 3/5] pagemap: Introduce pagemap_entry_t without pmshift bits Pavel Emelyanov
2013-04-11 11:29 ` [PATCH 4/5] pagemap: Introduce the /proc/PID/pagemap2 file Pavel Emelyanov
2013-04-11 21:19   ` Andrew Morton
2013-04-12 13:10     ` Pavel Emelyanov
2013-05-02 17:08   ` Matt Helsley
2013-05-04  9:47     ` Pavel Emelyanov
2013-04-11 11:30 ` [PATCH 5/5] mm: Soft-dirty bits for user memory changes tracking Pavel Emelyanov
2013-04-11 21:24   ` Andrew Morton
2013-04-12 13:14     ` Pavel Emelyanov
2013-04-15 21:46       ` Andrew Morton
2013-04-15 23:57         ` Stephen Rothwell
2013-04-16 19:58         ` Pavel Emelyanov
2013-04-12 15:53   ` [PATCH 6/5] selftest: Add simple test for soft-dirty bit Pavel Emelyanov
2013-04-16 19:51 ` [PATCH 7/5] mem-soft-dirty: Reshuffle CONFIG_ options to be more Arch-friendly Pavel Emelyanov
2013-04-16 23:24   ` Stephen Rothwell

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=51669E5F.4000801@parallels.com \
    --to=xemul@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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).