mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Martin J. Bligh" <mbligh@aracnet.com>
To: Anton Blanchard <anton@samba.org>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	Andrew Morton <akpm@digeo.com>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Fw: 2.5.61 oops running SDET
Date: Sun, 16 Feb 2003 08:39:40 -0800	[thread overview]
Message-ID: <21410000.1045413579@[10.10.2.4]> (raw)
In-Reply-To: <20030216130558.GL9833@krispykreme>

>> OK, I did the following, which is what I think you wanted, plus Zwane's
>> observation that task_state acquires the task_struct lock (we're the only 
>> caller, so I just removed it), but I still get the same panic and this time
>> the box hung. No doubt I've just done something stupid in the patch ...
>> (task_state takes the tasklist_lock ... is that safe to do inside task_lock?)
> 
> It looks like you now try and take the tasklist_lock inside a task_lock()
> region, but task_lock says no-can-do:
> 
> /* Protects ->fs, ->files, ->mm, and synchronises with wait4().  Nests
>  * inside tasklist_lock */
> static inline void task_lock(struct task_struct *p)
> {
> ...

Right, that's what I expected, and that may well explain the hang, but I 
don't see how that explains the oops still happening. What exactly is 
tasklist_lock protecting here anyway?

        read_lock(&tasklist_lock);
        buffer += sprintf(buffer,
                "State:\t%s\n"
                "Tgid:\t%d\n"
                "Pid:\t%d\n"
                "PPid:\t%d\n"
                "TracerPid:\t%d\n"
                "Uid:\t%d\t%d\t%d\t%d\n"
                "Gid:\t%d\t%d\t%d\t%d\n",
                get_task_state(p), p->tgid,
                p->pid, p->pid ? p->real_parent->pid : 0,
                p->pid && p->ptrace ? p->parent->pid : 0,
                p->uid, p->euid, p->suid, p->fsuid,
                p->gid, p->egid, p->sgid, p->fsgid);
        read_unlock(&tasklist_lock);

Is it these two accesses:

p->real_parent->pid ?
p->parent->pid ?

Don't see what I can do for this apart from to invert the ordering and take
tasklist_lock around the whole function, and nest task_lock inside that, or
I suppose I could take the task_lock for each of the parents? I seem to 
recall Linus reminding people recently that it was only the lock 
acquisition order that was important, not release ... does something like 
the following look OK?


diff -urpN -X /home/fletch/.diff.exclude virgin/fs/proc/array.c sdet2/fs/proc/array.c
--- virgin/fs/proc/array.c	Sat Feb 15 16:11:45 2003
+++ sdet2/fs/proc/array.c	Sun Feb 16 08:37:45 2003
@@ -147,11 +147,11 @@ static inline const char * get_task_stat
 	return *p;
 }
 
+/* Call me with the tasklist_lock and task_lock for p held already */
 static inline char * task_state(struct task_struct *p, char *buffer)
 {
 	int g;
 
-	read_lock(&tasklist_lock);
 	buffer += sprintf(buffer,
 		"State:\t%s\n"
 		"Tgid:\t%d\n"
@@ -165,13 +165,10 @@ static inline char * task_state(struct t
 		p->pid && p->ptrace ? p->parent->pid : 0,
 		p->uid, p->euid, p->suid, p->fsuid,
 		p->gid, p->egid, p->sgid, p->fsgid);
-	read_unlock(&tasklist_lock);	
-	task_lock(p);
 	buffer += sprintf(buffer,
 		"FDSize:\t%d\n"
 		"Groups:\t",
 		p->files ? p->files->max_fds : 0);
-	task_unlock(p);
 
 	for (g = 0; g < p->ngroups; g++)
 		buffer += sprintf(buffer, "%d ", p->groups[g]);
@@ -243,20 +240,22 @@ extern char *task_mem(struct mm_struct *
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
 	char * orig = buffer;
-	struct mm_struct *mm = get_task_mm(task);
 
+	read_lock(&tasklist_lock);
+	task_lock(task);
 	buffer = task_name(task, buffer);
 	buffer = task_state(task, buffer);
+	read_unlock(&tasklist_lock);
  
-	if (mm) {
-		buffer = task_mem(mm, buffer);
-		mmput(mm);
-	}
-	buffer = task_sig(task, buffer);
+	if (task->mm)
+		buffer = task_mem(task->mm, buffer);
+	if (task->sighand)
+		buffer = task_sig(task, buffer);
 	buffer = task_cap(task, buffer);
 #if defined(CONFIG_ARCH_S390)
 	buffer = task_show_regs(task, buffer);
 #endif
+	task_unlock(task);
 	return buffer - orig;
 }
 





  reply	other threads:[~2003-02-16 16:30 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030215172407.1fdd41fd.akpm@digeo.com>
2003-02-16  1:35 ` Linus Torvalds
2003-02-16  2:09   ` Martin J. Bligh
2003-02-16  2:27     ` Linus Torvalds
2003-02-16  4:00       ` Martin J. Bligh
2003-02-16 13:05         ` Anton Blanchard
2003-02-16 16:39           ` Martin J. Bligh [this message]
2003-02-16 18:21             ` Linus Torvalds
2003-02-16 19:06               ` Martin J. Bligh
2003-02-16 19:17                 ` Linus Torvalds
2003-02-16 21:15                   ` Martin J. Bligh
2003-02-16 21:21                     ` Manfred Spraul
2003-02-16 22:34                       ` Linus Torvalds
2003-02-16 23:08                         ` Martin J. Bligh
2003-02-16 23:32                           ` Linus Torvalds
2003-02-16 19:18                 ` Manfred Spraul
2003-02-16 19:19                 ` more signal locking bugs? Martin J. Bligh
2003-02-16 19:24                   ` Linus Torvalds
2003-02-16 19:37                     ` Manfred Spraul
2003-02-16 19:42                       ` Linus Torvalds
2003-02-16 20:01                         ` Linus Torvalds
2003-02-16 20:07                         ` Manfred Spraul
2003-02-16 20:10                           ` Linus Torvalds
2003-02-16 20:23                             ` Manfred Spraul
2003-02-17  0:23                           ` Linus Torvalds
2003-02-17  2:05                             ` Martin J. Bligh
2003-02-17  2:39                               ` Martin J. Bligh
2003-02-17  3:53                                 ` Linus Torvalds
2003-02-17  5:07                                   ` Martin J. Bligh
2003-02-17  6:17                                   ` Martin J. Bligh
2003-02-17 17:09                                   ` Magnus Naeslund(f)
2003-02-17  3:54                                 ` [PATCH] fix secondary oops in sighand locking Martin J. Bligh
2003-02-17  6:36                             ` more signal locking bugs? Manfred Spraul
2003-02-17 19:06                               ` Linus Torvalds
2003-02-16 18:07         ` Fw: 2.5.61 oops running SDET Linus Torvalds
2003-02-16 18:26           ` Martin J. Bligh
2003-02-16 18:36             ` Martin J. Bligh
2003-02-16  2:48     ` Zwane Mwaikambo
2003-02-16 17:41 Manfred Spraul
2003-02-16 18:15 ` Linus Torvalds
2003-02-16 18:45   ` Manfred Spraul
2003-02-16 18:56     ` Linus Torvalds

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='21410000.1045413579@[10.10.2.4]' \
    --to=mbligh@aracnet.com \
    --cc=akpm@digeo.com \
    --cc=anton@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®