diff mbox series

[6/9] sparc/perf: correctly check for kthreads

Message ID 20190814104131.20190-7-mark.rutland@arm.com
State New
Headers show
Series kthread detection cleanup | expand

Commit Message

Mark Rutland Aug. 14, 2019, 10:41 a.m. UTC
The sparc perf_callchain_user() functions looks at current->mm,
apparently to determine whether the thread is a kthread without any
valid user context.

In general, a non-NULL current->mm doesn't imply that current is a
kthread, as kthreads can install an mm via use_mm(), and so it's
preferable to use is_kthread() to determine whether a thread is a
kthread.

For consistency, let's use is_kthread() here.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>

Cc: David S. Miller <davem@davemloft.net>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
---
 arch/sparc/kernel/perf_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.11.0

Comments

David Miller Aug. 14, 2019, 4:26 p.m. UTC | #1
From: Mark Rutland <mark.rutland@arm.com>

Date: Wed, 14 Aug 2019 11:41:28 +0100

> The sparc perf_callchain_user() functions looks at current->mm,

> apparently to determine whether the thread is a kthread without any

> valid user context.

> 

> In general, a non-NULL current->mm doesn't imply that current is a

> kthread, as kthreads can install an mm via use_mm(), and so it's

> preferable to use is_kthread() to determine whether a thread is a

> kthread.

> 

> For consistency, let's use is_kthread() here.

> 

> Signed-off-by: Mark Rutland <mark.rutland@arm.com>


Acked-by: David S. Miller <davem@davemloft.net>
diff mbox series

Patch

diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index a58ae9c42803..ef7b1a03bea9 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -1858,7 +1858,7 @@  perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs
 
 	perf_callchain_store(entry, regs->tpc);
 
-	if (!current->mm)
+	if (is_kthread(current))
 		return;
 
 	flushw_user();