All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/12 v2] ptrace: tracehooks: do not use task->ptrace directly
Date: Thu, 28 May 2009 13:35:40 +0200	[thread overview]
Message-ID: <20090528113540.GA18681@redhat.com> (raw)

s/->ptrace/task_ptrace()/ in tracehook.h as a preparation for the future
changes.

Also, microoptimize tracehook_prepare_clone() for the common non-ptraced
case.

 include/linux/tracehook.h |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

--- PTRACE/include/linux/tracehook.h~1_TRACEHOOK	2009-05-24 21:36:47.000000000 +0200
+++ PTRACE/include/linux/tracehook.h	2009-05-24 21:48:40.000000000 +0200
@@ -225,16 +225,18 @@ static inline void tracehook_report_exit
  */
 static inline int tracehook_prepare_clone(unsigned clone_flags)
 {
-	if (clone_flags & CLONE_UNTRACED)
+	unsigned int ptrace = task_ptrace(current);
+
+	if (likely(!ptrace) || (clone_flags & CLONE_UNTRACED))
 		return 0;
 
 	if (clone_flags & CLONE_VFORK) {
-		if (current->ptrace & PT_TRACE_VFORK)
+		if (ptrace & PT_TRACE_VFORK)
 			return PTRACE_EVENT_VFORK;
 	} else if ((clone_flags & CSIGNAL) != SIGCHLD) {
-		if (current->ptrace & PT_TRACE_CLONE)
+		if (ptrace & PT_TRACE_CLONE)
 			return PTRACE_EVENT_CLONE;
-	} else if (current->ptrace & PT_TRACE_FORK)
+	} else if (ptrace & PT_TRACE_FORK)
 		return PTRACE_EVENT_FORK;
 
 	return 0;
@@ -479,7 +481,7 @@ static inline int tracehook_get_signal(s
  */
 static inline int tracehook_notify_jctl(int notify, int why)
 {
-	return notify || (current->ptrace & PT_PTRACED);
+	return notify || task_ptrace(current);
 }
 
 #define DEATH_REAP			-1
@@ -503,7 +505,7 @@ static inline int tracehook_notify_death
 					 void **death_cookie, int group_dead)
 {
 	if (task_detached(task))
-		return task->ptrace ? SIGCHLD : DEATH_REAP;
+		return task_ptrace(task) ? SIGCHLD : DEATH_REAP;
 
 	/*
 	 * If something other than our normal parent is ptracing us, then
@@ -513,7 +515,7 @@ static inline int tracehook_notify_death
 	if (thread_group_empty(task) && !ptrace_reparented(task))
 		return task->exit_signal;
 
-	return task->ptrace ? SIGCHLD : DEATH_DELAYED_GROUP_LEADER;
+	return task_ptrace(task) ? SIGCHLD : DEATH_DELAYED_GROUP_LEADER;
 }
 
 /**


                 reply	other threads:[~2009-05-28 11:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090528113540.GA18681@redhat.com \
    --to=oleg@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    /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.