linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: linux-kernel@vger.kernel.org
Cc: ak@linux.intel.com, akpm@linux-foundation.org,
	bigeasy@linutronix.de, bp@suse.de, catalin.marinas@arm.com,
	davem@davemloft.net, hch@lst.de, kan.liang@intel.com,
	mark.rutland@arm.com, mingo@kernel.org, peterz@infradead.org,
	riel@surriel.com, will@kernel.org
Subject: [PATCH 9/9] samples/kretprobe: correctly check for kthreads
Date: Wed, 14 Aug 2019 11:41:31 +0100	[thread overview]
Message-ID: <20190814104131.20190-10-mark.rutland@arm.com> (raw)
In-Reply-To: <20190814104131.20190-1-mark.rutland@arm.com>

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: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 samples/kprobes/kretprobe_example.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/samples/kprobes/kretprobe_example.c b/samples/kprobes/kretprobe_example.c
index 186315ca88b3..d6e0bf196f0e 100644
--- a/samples/kprobes/kretprobe_example.c
+++ b/samples/kprobes/kretprobe_example.c
@@ -41,7 +41,7 @@ static int entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
 {
 	struct my_data *data;
 
-	if (!current->mm)
+	if (is_kthread(current))
 		return 1;	/* Skip kernel threads */
 
 	data = (struct my_data *)ri->data;
-- 
2.11.0


  parent reply	other threads:[~2019-08-14 10:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14 10:41 [PATCH 0/9] kthread detection cleanup Mark Rutland
2019-08-14 10:41 ` [PATCH 1/9] sched/core: add is_kthread() helper Mark Rutland
2019-08-14 11:26   ` Geert Uytterhoeven
2019-08-14 11:32     ` Mark Rutland
2019-08-19  8:52       ` Ingo Molnar
2019-08-21 11:21         ` Peter Zijlstra
2019-08-14 10:41 ` [PATCH 2/9] sched: treewide: use is_kthread() Mark Rutland
2019-08-14 11:27   ` Geert Uytterhoeven
2019-08-14 12:39   ` Sebastian Andrzej Siewior
2019-08-14 13:35     ` Mark Rutland
2019-08-14 13:37   ` Valentin Schneider
2019-08-14 10:41 ` [PATCH 3/9] kmemleak: correctly check for kthreads Mark Rutland
2019-08-14 16:39   ` Catalin Marinas
2019-08-14 10:41 ` [PATCH 4/9] arm/perf: " Mark Rutland
2019-08-14 10:41 ` [PATCH 5/9] arm64: correctly check for ktrheads Mark Rutland
2019-08-14 16:40   ` Catalin Marinas
2019-08-14 10:41 ` [PATCH 6/9] sparc/perf: correctly check for kthreads Mark Rutland
2019-08-14 16:26   ` David Miller
2019-08-14 10:41 ` [PATCH 7/9] x86/lbr: " Mark Rutland
2019-08-14 10:41 ` [PATCH 8/9] x86/fpu: " Mark Rutland
2019-08-14 13:07   ` Sebastian Andrzej Siewior
2019-08-14 13:39     ` Mark Rutland
2019-08-14 14:55       ` Sebastian Andrzej Siewior
2019-08-14 10:41 ` Mark Rutland [this message]
2019-08-14 13:43 ` [PATCH 0/9] kthread detection cleanup Valentin Schneider

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=20190814104131.20190-10-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=bp@suse.de \
    --cc=catalin.marinas@arm.com \
    --cc=davem@davemloft.net \
    --cc=hch@lst.de \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).