[lkml]   [2019]   [Aug]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 7/9] x86/lbr: correctly check for kthreads
The x86 lbr branch_type() functions looks at current->mm, apparently to
determine whether the thread is a kthread without any valid user

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

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

Signed-off-by: Mark Rutland <>
Cc: Andi Kleen <>
Cc: Ingo Molnar <>
Cc: Kan Liang <>
Cc: Peter Zijlstra <>
arch/x86/events/intel/lbr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c
index 6f814a27416b..ed2b7e57a249 100644
--- a/arch/x86/events/intel/lbr.c
+++ b/arch/x86/events/intel/lbr.c
@@ -857,7 +857,7 @@ static int branch_type(unsigned long from, unsigned long to, int abort)
* can happen if measuring at the user level only
* and we interrupt in a kernel thread, e.g., idle.
- if (!current->mm)
+ if (is_kthread(current))
return X86_BR_NONE;

/* may fail if text not present */
 \ /
  Last update: 2019-08-14 12:43    [W:0.071 / U:25.140 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site