All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Will Deacon <will.deacon@arm.com>
Cc: Young Xiao <92siuyang@gmail.com>,
	linux@armlinux.org.uk, mark.rutland@arm.com, mingo@redhat.com,
	bp@alien8.de, hpa@zytor.com, x86@kernel.org,
	kan.liang@linux.intel.com, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, ravi.bangoria@linux.vnet.ibm.com,
	mpe@ellerman.id.au, acme@redhat.com, eranian@google.com,
	fweisbec@gmail.com, jolsa@redhat.com
Subject: Re: [PATCH] perf: Fix oops when kthread execs user process
Date: Wed, 29 May 2019 14:55:57 +0200	[thread overview]
Message-ID: <20190529125557.GU2623@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190529102022.GC4485@fuggles.cambridge.arm.com>

On Wed, May 29, 2019 at 11:20:22AM +0100, Will Deacon wrote:
> Anyway, you can add my ack to your patch, but I bet we can remove that mm
> check :D

I've ended up with the below. Ravi, can you test if that does indeed
obsolete your PPC patch?

---
Subject: perf: Fix perf_sample_regs_user()
From: Peter Zijlstra <peterz@infradead.org>
Date: Wed May 29 14:37:24 CEST 2019

perf_sample_regs_user() uses 'current->mm' to test for the presence of
userspace, but this is insufficient, consider use_mm().

A better test is: '!(current->flags & PF_KTHREAD)', exec() clears
PF_KTHREAD after it sets the new ->mm but before it drops to userspace
for the first time.

Possibly obsoletes: bf05fc25f268 ("powerpc/perf: Fix oops when kthread execs user process")

Reported-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Reported-by: Young Xiao <92siuyang@gmail.com>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Fixes: 4018994f3d87 ("perf: Add ability to attach user level registers dump to sample")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/events/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5923,7 +5923,7 @@ static void perf_sample_regs_user(struct
 	if (user_mode(regs)) {
 		regs_user->abi = perf_reg_abi(current);
 		regs_user->regs = regs;
-	} else if (current->mm) {
+	} else if (!(current->flags & PF_KTHREAD)) {
 		perf_get_regs_user(regs_user, regs, regs_user_copy);
 	} else {
 		regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE;

WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <peterz@infradead.org>
To: Will Deacon <will.deacon@arm.com>
Cc: mark.rutland@arm.com, Young Xiao <92siuyang@gmail.com>,
	mpe@ellerman.id.au, jolsa@redhat.com, x86@kernel.org,
	linux@armlinux.org.uk, eranian@google.com,
	linux-kernel@vger.kernel.org, acme@redhat.com, mingo@redhat.com,
	bp@alien8.de, hpa@zytor.com, ravi.bangoria@linux.vnet.ibm.com,
	fweisbec@gmail.com, linux-arm-kernel@lists.infradead.org,
	kan.liang@linux.intel.com
Subject: Re: [PATCH] perf: Fix oops when kthread execs user process
Date: Wed, 29 May 2019 14:55:57 +0200	[thread overview]
Message-ID: <20190529125557.GU2623@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190529102022.GC4485@fuggles.cambridge.arm.com>

On Wed, May 29, 2019 at 11:20:22AM +0100, Will Deacon wrote:
> Anyway, you can add my ack to your patch, but I bet we can remove that mm
> check :D

I've ended up with the below. Ravi, can you test if that does indeed
obsolete your PPC patch?

---
Subject: perf: Fix perf_sample_regs_user()
From: Peter Zijlstra <peterz@infradead.org>
Date: Wed May 29 14:37:24 CEST 2019

perf_sample_regs_user() uses 'current->mm' to test for the presence of
userspace, but this is insufficient, consider use_mm().

A better test is: '!(current->flags & PF_KTHREAD)', exec() clears
PF_KTHREAD after it sets the new ->mm but before it drops to userspace
for the first time.

Possibly obsoletes: bf05fc25f268 ("powerpc/perf: Fix oops when kthread execs user process")

Reported-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Reported-by: Young Xiao <92siuyang@gmail.com>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Fixes: 4018994f3d87 ("perf: Add ability to attach user level registers dump to sample")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/events/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5923,7 +5923,7 @@ static void perf_sample_regs_user(struct
 	if (user_mode(regs)) {
 		regs_user->abi = perf_reg_abi(current);
 		regs_user->regs = regs;
-	} else if (current->mm) {
+	} else if (!(current->flags & PF_KTHREAD)) {
 		perf_get_regs_user(regs_user, regs, regs_user_copy);
 	} else {
 		regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE;

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-05-29 12:56 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 12:31 [PATCH] perf: Fix oops when kthread execs user process Young Xiao
2019-05-28 12:31 ` Young Xiao
2019-05-28 12:41 ` Russell King - ARM Linux admin
2019-05-28 12:41   ` Russell King - ARM Linux admin
2019-05-28 14:01 ` Peter Zijlstra
2019-05-28 14:01   ` Peter Zijlstra
2019-05-28 15:32   ` Will Deacon
2019-05-28 15:32     ` Will Deacon
2019-05-28 16:12     ` Mark Rutland
2019-05-28 16:12       ` Mark Rutland
2019-05-28 17:32     ` Peter Zijlstra
2019-05-28 17:32       ` Peter Zijlstra
2019-05-29  9:17       ` Will Deacon
2019-05-29  9:17         ` Will Deacon
2019-05-29 10:10         ` Peter Zijlstra
2019-05-29 10:10           ` Peter Zijlstra
2019-05-29 10:20           ` Will Deacon
2019-05-29 10:20             ` Will Deacon
2019-05-29 12:55             ` Peter Zijlstra [this message]
2019-05-29 12:55               ` Peter Zijlstra
2019-05-29 13:05               ` Will Deacon
2019-05-29 13:05                 ` Will Deacon
2019-05-29 13:25                 ` Peter Zijlstra
2019-05-29 13:25                   ` Peter Zijlstra
2019-05-29 14:35                   ` Will Deacon
2019-05-29 14:35                     ` Will Deacon
2019-05-29 16:19                     ` Peter Zijlstra
2019-05-29 16:19                       ` Peter Zijlstra
2019-05-29 16:24                       ` Mark Rutland
2019-05-29 16:24                         ` Mark Rutland
2019-05-29 16:38                         ` Mark Rutland
2019-05-29 16:38                           ` Mark Rutland
2019-05-29 17:03                           ` Peter Zijlstra
2019-05-29 17:03                             ` Peter Zijlstra
2019-05-30 10:35                             ` Mark Rutland
2019-05-30 10:35                               ` Mark Rutland
2019-05-29 16:25                       ` Will Deacon
2019-05-29 16:25                         ` Will Deacon
2019-05-29 16:44                         ` Peter Zijlstra
2019-05-29 16:44                           ` Peter Zijlstra
2019-05-30  7:28                           ` Will Deacon
2019-05-30  7:28                             ` Will Deacon
2019-05-30  8:38               ` Ravi Bangoria
2019-05-30  8:38                 ` Ravi Bangoria
2019-05-30 10:27                 ` Ravi Bangoria
2019-05-30 10:27                   ` Ravi Bangoria
2019-05-31 15:37                   ` Will Deacon
2019-05-31 15:37                     ` Will Deacon
2019-06-03 11:23                     ` Will Deacon
2019-06-03 11:23                       ` Will Deacon
2019-06-03 11:48                     ` Peter Zijlstra
2019-06-03 11:48                       ` Peter Zijlstra
2019-06-03 13:30                     ` Michael Ellerman
2019-06-03 13:30                       ` Michael Ellerman
2019-05-29 10:11       ` Mark Rutland
2019-05-29 10:11         ` Mark Rutland
2019-05-29  4:21     ` Michael Ellerman
2019-05-29  4:21       ` Michael Ellerman
2019-05-29  1:44   ` Michael Ellerman
2019-05-29  1:44     ` Michael Ellerman

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=20190529125557.GU2623@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=92siuyang@gmail.com \
    --cc=acme@redhat.com \
    --cc=bp@alien8.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@redhat.com \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=ravi.bangoria@linux.vnet.ibm.com \
    --cc=will.deacon@arm.com \
    --cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.