Re: [PATCH] perf: Fix oops when kthread execs user process

2019-06-03 Thread Michael Ellerman
Will Deacon writes: > On Thu, May 30, 2019 at 03:57:36PM +0530, Ravi Bangoria wrote: >> On 5/30/19 2:08 PM, Ravi Bangoria wrote: >> >> --- >> >> Subject: perf: Fix perf_sample_regs_user() >> >> From: Peter Zijlstra >> >> Date: Wed May 29 14:37:24 CEST 2019 >> >> >> >> perf_sample_regs_user()

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-06-03 Thread Peter Zijlstra
On Fri, May 31, 2019 at 04:37:03PM +0100, Will Deacon wrote: > On Thu, May 30, 2019 at 03:57:36PM +0530, Ravi Bangoria wrote: > > On 5/30/19 2:08 PM, Ravi Bangoria wrote: > > >> --- a/kernel/events/core.c > > >> +++ b/kernel/events/core.c > > >> @@ -5923,7 +5923,7 @@ static void

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-06-03 Thread Will Deacon
On Fri, May 31, 2019 at 04:37:15PM +0100, Will Deacon wrote: > Oh, nice! I think this happens because Power doesn't actually initialise > the regs after a kthread execs() until late in start_thread(). But the plot > thickens somewhat, since current_pt_regs() is different to > task_pt_regs(current)

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-31 Thread Will Deacon
On Thu, May 30, 2019 at 03:57:36PM +0530, Ravi Bangoria wrote: > > > On 5/30/19 2:08 PM, Ravi Bangoria wrote: > >> --- > >> Subject: perf: Fix perf_sample_regs_user() > >> From: Peter Zijlstra > >> Date: Wed May 29 14:37:24 CEST 2019 > >> > >> perf_sample_regs_user() uses 'current->mm' to test

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-30 Thread Mark Rutland
On Wed, May 29, 2019 at 07:03:13PM +0200, Peter Zijlstra wrote: > On Wed, May 29, 2019 at 05:38:54PM +0100, Mark Rutland wrote: > > Generally speaking though, if we ever task task_pt_regs() of an idle > > task we'll get junk, and user_mode() could be true. > > Agreed, but we're not doing that.

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-30 Thread Ravi Bangoria
On 5/30/19 2:08 PM, Ravi Bangoria wrote: >> --- >> Subject: perf: Fix perf_sample_regs_user() >> From: Peter Zijlstra >> 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().

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-30 Thread Ravi Bangoria
On 5/29/19 6:25 PM, Peter Zijlstra wrote: > 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?

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-30 Thread Will Deacon
On Wed, May 29, 2019 at 06:44:07PM +0200, Peter Zijlstra wrote: > On Wed, May 29, 2019 at 05:25:28PM +0100, Will Deacon wrote: > > > > > > On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > > > > > > On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote: > > > > > > > > > >

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Peter Zijlstra
On Wed, May 29, 2019 at 05:38:54PM +0100, Mark Rutland wrote: > Sorry for the noise. n/p, confusion happens :-) > Generally speaking though, if we ever task task_pt_regs() of an idle > task we'll get junk, and user_mode() could be true. Agreed, but we're not doing that.

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Peter Zijlstra
On Wed, May 29, 2019 at 05:25:28PM +0100, Will Deacon wrote: > > > > On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > > > > > On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote: > > > > > > > > > > if (user_mode(regs)) { > > > > > > > > > > Hmm, so it just occurred

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Mark Rutland
On Wed, May 29, 2019 at 05:24:36PM +0100, Mark Rutland wrote: > On Wed, May 29, 2019 at 06:19:55PM +0200, Peter Zijlstra wrote: > > On Wed, May 29, 2019 at 03:35:10PM +0100, Will Deacon wrote: > > > On Wed, May 29, 2019 at 03:25:15PM +0200, Peter Zijlstra wrote: > > > > On Wed, May 29, 2019 at

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Will Deacon
On Wed, May 29, 2019 at 06:19:55PM +0200, Peter Zijlstra wrote: > On Wed, May 29, 2019 at 03:35:10PM +0100, Will Deacon wrote: > > On Wed, May 29, 2019 at 03:25:15PM +0200, Peter Zijlstra wrote: > > > On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > > > > On Wed, May 29, 2019 at

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Mark Rutland
On Wed, May 29, 2019 at 06:19:55PM +0200, Peter Zijlstra wrote: > On Wed, May 29, 2019 at 03:35:10PM +0100, Will Deacon wrote: > > On Wed, May 29, 2019 at 03:25:15PM +0200, Peter Zijlstra wrote: > > > On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > > > > On Wed, May 29, 2019 at

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Peter Zijlstra
On Wed, May 29, 2019 at 03:35:10PM +0100, Will Deacon wrote: > On Wed, May 29, 2019 at 03:25:15PM +0200, Peter Zijlstra wrote: > > On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > > > On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote: > > > > > > if

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Will Deacon
On Wed, May 29, 2019 at 03:25:15PM +0200, Peter Zijlstra wrote: > On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > > On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote: > > > > if (user_mode(regs)) { > > > > Hmm, so it just occurred to me that Mark's observation is

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Peter Zijlstra
On Wed, May 29, 2019 at 02:05:21PM +0100, Will Deacon wrote: > On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote: > > if (user_mode(regs)) { > > Hmm, so it just occurred to me that Mark's observation is that the regs > can be junk in some cases. In which case, should we be

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Will Deacon
On Wed, May 29, 2019 at 02:55:57PM +0200, Peter Zijlstra wrote: > 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 >

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Peter Zijlstra
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:

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Will Deacon
On Wed, May 29, 2019 at 12:10:42PM +0200, Peter Zijlstra wrote: > On Wed, May 29, 2019 at 10:17:33AM +0100, Will Deacon wrote: > > On Tue, May 28, 2019 at 07:32:28PM +0200, Peter Zijlstra wrote: > > > > 'funny' thing that, perf_sample_regs_user() seems to assume that > > > anything with

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Mark Rutland
On Tue, May 28, 2019 at 07:32:28PM +0200, Peter Zijlstra wrote: > On Tue, May 28, 2019 at 04:32:24PM +0100, Will Deacon wrote: > > On Tue, May 28, 2019 at 04:01:03PM +0200, Peter Zijlstra wrote: > > > On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: > > > > When a kthread calls

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Peter Zijlstra
On Wed, May 29, 2019 at 10:17:33AM +0100, Will Deacon wrote: > On Tue, May 28, 2019 at 07:32:28PM +0200, Peter Zijlstra wrote: > > 'funny' thing that, perf_sample_regs_user() seems to assume that > > anything with current->mm is in fact a user task, and that assumption is > > just plain wrong,

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-29 Thread Will Deacon
On Tue, May 28, 2019 at 07:32:28PM +0200, Peter Zijlstra wrote: > On Tue, May 28, 2019 at 04:32:24PM +0100, Will Deacon wrote: > > On Tue, May 28, 2019 at 04:01:03PM +0200, Peter Zijlstra wrote: > > > On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: > > > > When a kthread calls

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-28 Thread Michael Ellerman
Will Deacon writes: > On Tue, May 28, 2019 at 04:01:03PM +0200, Peter Zijlstra wrote: >> On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: >> > When a kthread calls call_usermodehelper() the steps are: >> > 1. allocate current->mm >> > 2. load_elf_binary() >> > 3. populate

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-28 Thread Michael Ellerman
Peter Zijlstra writes: > On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: >> When a kthread calls call_usermodehelper() the steps are: >> 1. allocate current->mm >> 2. load_elf_binary() >> 3. populate current->thread.regs >> >> While doing this, interrupts are not disabled. If

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-28 Thread Peter Zijlstra
On Tue, May 28, 2019 at 04:32:24PM +0100, Will Deacon wrote: > On Tue, May 28, 2019 at 04:01:03PM +0200, Peter Zijlstra wrote: > > On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: > > > When a kthread calls call_usermodehelper() the steps are: > > > 1. allocate current->mm > > > 2.

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-28 Thread Mark Rutland
On Tue, May 28, 2019 at 04:32:24PM +0100, Will Deacon wrote: > On Tue, May 28, 2019 at 04:01:03PM +0200, Peter Zijlstra wrote: > > On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: > > > When a kthread calls call_usermodehelper() the steps are: > > > 1. allocate current->mm > > > 2.

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-28 Thread Will Deacon
On Tue, May 28, 2019 at 04:01:03PM +0200, Peter Zijlstra wrote: > On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: > > When a kthread calls call_usermodehelper() the steps are: > > 1. allocate current->mm > > 2. load_elf_binary() > > 3. populate current->thread.regs > > > > While

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-28 Thread Peter Zijlstra
On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: > When a kthread calls call_usermodehelper() the steps are: > 1. allocate current->mm > 2. load_elf_binary() > 3. populate current->thread.regs > > While doing this, interrupts are not disabled. If there is a perf > interrupt in

Re: [PATCH] perf: Fix oops when kthread execs user process

2019-05-28 Thread Russell King - ARM Linux admin
On Tue, May 28, 2019 at 08:31:29PM +0800, Young Xiao wrote: > When a kthread calls call_usermodehelper() the steps are: > 1. allocate current->mm > 2. load_elf_binary() > 3. populate current->thread.regs > > While doing this, interrupts are not disabled. If there is a perf > interrupt in