All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@openvz.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devel@openvz.org, Oleg Nesterov <oleg@tv-sign.ru>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 4/12] Don't operate with pid_t in rtmutex tester
Date: Tue, 29 Jan 2008 16:49:27 +0300	[thread overview]
Message-ID: <479F2EE7.8040902@openvz.org> (raw)
In-Reply-To: <479F2C5C.1050303@openvz.org>

The proper behavior to store task's pid and get this task 
later is to get the struct pid pointer and get the task
with the pid_task() call.

Make it for rt_mutex_waiter->deadlock_task_pid field.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---
 kernel/rtmutex-debug.c  |   12 +++++++++---
 kernel/rtmutex_common.h |    2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/kernel/rtmutex-debug.c b/kernel/rtmutex-debug.c
index 56d73cb..40ec85c 100644
--- a/kernel/rtmutex-debug.c
+++ b/kernel/rtmutex-debug.c
@@ -130,7 +130,7 @@ void debug_rt_mutex_deadlock(int detect, struct rt_mutex_waiter *act_waiter,
 
 	task = rt_mutex_owner(act_waiter->lock);
 	if (task && task != current) {
-		act_waiter->deadlock_task_pid = task->pid;
+		act_waiter->deadlock_task_pid = get_pid(task_pid(task));
 		act_waiter->deadlock_lock = lock;
 	}
 }
@@ -142,9 +142,12 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
 	if (!waiter->deadlock_lock || !rt_trace_on)
 		return;
 
-	task = find_task_by_pid(waiter->deadlock_task_pid);
-	if (!task)
+	rcu_read_lock();
+	task = pid_task(waiter->deadlock_task_pid, PIDTYPE_PID);
+	if (!task) {
+		rcu_read_unlock();
 		return;
+	}
 
 	TRACE_OFF_NOLOCK();
 
@@ -173,6 +176,7 @@ void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter)
 		current->comm, task_pid_nr(current));
 	dump_stack();
 	debug_show_all_locks();
+	rcu_read_unlock();
 
 	printk("[ turning off deadlock detection."
 	       "Please report this trace. ]\n\n");
@@ -203,10 +207,12 @@ void debug_rt_mutex_init_waiter(struct rt_mutex_waiter *waiter)
 	memset(waiter, 0x11, sizeof(*waiter));
 	plist_node_init(&waiter->list_entry, MAX_PRIO);
 	plist_node_init(&waiter->pi_list_entry, MAX_PRIO);
+	waiter->deadlock_task_pid = NULL;
 }
 
 void debug_rt_mutex_free_waiter(struct rt_mutex_waiter *waiter)
 {
+	put_pid(waiter->deadlock_task_pid);
 	TRACE_WARN_ON(!plist_node_empty(&waiter->list_entry));
 	TRACE_WARN_ON(!plist_node_empty(&waiter->pi_list_entry));
 	TRACE_WARN_ON(waiter->task);
diff --git a/kernel/rtmutex_common.h b/kernel/rtmutex_common.h
index 2d3b835..e124bf5 100644
--- a/kernel/rtmutex_common.h
+++ b/kernel/rtmutex_common.h
@@ -51,7 +51,7 @@ struct rt_mutex_waiter {
 	struct rt_mutex		*lock;
 #ifdef CONFIG_DEBUG_RT_MUTEXES
 	unsigned long		ip;
-	pid_t			deadlock_task_pid;
+	struct pid		*deadlock_task_pid;
 	struct rt_mutex		*deadlock_lock;
 #endif
 };
-- 
1.5.3.4


  parent reply	other threads:[~2008-01-29 13:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-29 13:38 [PATCH 0/12] Schedule find_task_by_pid() for removal Pavel Emelyanov
2008-01-29 13:41 ` [PATCH 1/12] Use find_task_by_vpid in posix timers Pavel Emelyanov
2008-01-29 13:43 ` [PATCH 2/12] Use find_task_by_vpid in autid code Pavel Emelyanov
2008-01-29 13:46 ` [PATCH 3/12] Use find_task_by_vpid in taskstats Pavel Emelyanov
2008-01-29 13:49 ` Pavel Emelyanov [this message]
2008-01-29 13:52 ` [PATCH 5/12] Handle pid namespaces in cgroups code Pavel Emelyanov
2008-01-29 18:08   ` Paul Menage
2008-01-29 13:55 ` [PATCH 6/12] gfs2: make gfs2_glock.gl_owner_pid be a struct pid * Pavel Emelyanov
2008-01-29 14:19   ` Steven Whitehouse
2008-01-29 14:33     ` Pavel Emelyanov
2008-01-29 13:57 ` [PATCH 7/12] gfs2: make gfs2_holder.gh_owner_pid " Pavel Emelyanov
2008-01-29 13:59 ` [PATCH 8/12] frv: use find_task_by_vpid in cxn_pin_by_pid Pavel Emelyanov
2008-01-29 14:02 ` [PATCH 9/12] ia64: make pfm_get_task work with virtual pids Pavel Emelyanov
2008-01-29 14:04 ` [PATCH 10/12] ia64: fix ptrace inside a namespace Pavel Emelyanov
2008-01-29 14:06 ` [PATCH 11/12] mips: use find_task_by_vpid in system calls Pavel Emelyanov
2008-01-29 14:09 ` [PATCH 12/12] Deprecate the find_task_by_pid Pavel Emelyanov
2008-02-01 22:27   ` Andrew Morton

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=479F2EE7.8040902@openvz.org \
    --to=xemul@openvz.org \
    --cc=akpm@linux-foundation.org \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@tv-sign.ru \
    --cc=tglx@linutronix.de \
    /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.