From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: Kees Cook <keescook@chromium.org>, Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"mingo@elte.hu" <mingo@elte.hu>,
"ak@linux.intel.com" <ak@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@redhat.com>,
Hugh Dickins <hughd@google.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC] perf: mmap2 not covering VM_CLONE regions
Date: Thu, 3 Oct 2013 11:03:47 +0200 [thread overview]
Message-ID: <20131003090347.GB3081@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <CABPqkBRbqnwRpigACZwnV4rSK2wZekZqXi-vfB2+YbSWgfTUKA@mail.gmail.com>
On Thu, Oct 03, 2013 at 10:55:28AM +0200, Stephane Eranian wrote:
> I don't know the MM code but I assume that that vm_mm struct is
> allocated dynamically
> and maybe you already grabbing a lock while doing this. Could we
> leverage that lock
> to increment a global generation number?
Sure; something like so.. I just don't like global state nor adding to
mm_struct for just this.
---
include/linux/mm_types.h | 1 +
kernel/fork.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index d9851eeb6e1d..3877b1e72a5b 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -436,6 +436,7 @@ struct mm_struct {
int first_nid;
#endif
struct uprobes_state uprobes_state;
+ u64 mm_id;
};
/* first nid will either be a valid NID or one of these values */
diff --git a/kernel/fork.c b/kernel/fork.c
index 086fe73ad6bd..b315f6227629 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -523,6 +523,8 @@ static void mm_init_aio(struct mm_struct *mm)
#endif
}
+static u64 global_mm_id;
+
static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)
{
atomic_set(&mm->mm_users, 1);
@@ -537,6 +539,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p)
spin_lock_init(&mm->page_table_lock);
mm_init_aio(mm);
mm_init_owner(mm, p);
+ mm->mm_id = 0;
if (likely(!mm_alloc_pgd(mm))) {
mm->def_flags = 0;
@@ -1422,6 +1425,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
*/
write_lock_irq(&tasklist_lock);
+ if (p->mm && !p->mm->mm_id)
+ p->mm->mm_id = ++global_mm_id;
+
/* CLONE_PARENT re-uses the old parent */
if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) {
p->real_parent = current->real_parent;
next prev parent reply other threads:[~2013-10-03 9:04 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-30 15:44 Stephane Eranian
2013-09-30 16:15 ` Peter Zijlstra
2013-09-30 16:48 ` Stephane Eranian
2013-09-30 16:54 ` Peter Zijlstra
2013-10-01 11:22 ` Stephane Eranian
2013-10-02 11:23 ` Peter Zijlstra
2013-10-02 11:58 ` Peter Zijlstra
2013-10-02 12:39 ` Ingo Molnar
2013-10-02 12:46 ` Peter Zijlstra
2013-10-02 12:59 ` Stephane Eranian
2013-10-02 13:01 ` Peter Zijlstra
2013-10-02 13:13 ` Stephane Eranian
2013-10-02 13:37 ` Peter Zijlstra
2013-10-02 17:14 ` Kees Cook
2013-10-02 17:20 ` Stephane Eranian
2013-10-02 17:29 ` Kees Cook
2013-10-02 17:49 ` Stephane Eranian
2013-10-02 18:10 ` Kees Cook
2013-10-02 19:00 ` Peter Zijlstra
2013-10-02 19:38 ` Kees Cook
2013-10-02 20:31 ` Peter Zijlstra
2013-10-03 8:55 ` Stephane Eranian
2013-10-03 9:03 ` Peter Zijlstra [this message]
2013-10-03 9:13 ` Stephane Eranian
2013-10-03 15:34 ` Kees Cook
2013-10-07 21:04 ` Stephane Eranian
2013-10-08 6:54 ` Peter Zijlstra
2013-10-08 7:15 ` Stephane Eranian
2013-10-08 9:36 ` Peter Zijlstra
2013-10-08 9:42 ` Stephane Eranian
2013-10-08 9:54 ` Peter Zijlstra
2013-10-03 18:32 ` Andi Kleen
2013-10-07 11:16 ` Stephane Eranian
2013-10-07 11:32 ` Peter Zijlstra
2013-10-02 15:22 ` Ingo Molnar
2013-10-08 14:23 ` David Ahern
2013-10-08 19:41 ` Ingo Molnar
2013-10-08 19:54 ` Stephane Eranian
2013-10-08 19:57 ` David Ahern
2013-10-09 9:54 ` Ingo Molnar
2013-10-09 9:59 ` Ingo Molnar
2013-10-09 10:39 ` Peter Zijlstra
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=20131003090347.GB3081@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@redhat.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=hughd@google.com \
--cc=jolsa@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.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
Powered by JetHome