From: "Martin J. Bligh" <mbligh@aracnet.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Anton Blanchard <anton@samba.org>, Andrew Morton <akpm@digeo.com>,
Kernel Mailing List <linux-kernel@vger.kernel.org>,
Zwane Mwaikambo <zwane@holomorphy.com>,
Manfred Spraul <manfred@colorfullife.com>
Subject: Re: Fw: 2.5.61 oops running SDET
Date: Sun, 16 Feb 2003 11:06:23 -0800 [thread overview]
Message-ID: <26480000.1045422382@[10.10.2.4]> (raw)
In-Reply-To: <Pine.LNX.4.44.0302161017500.2619-100000@home.transmeta.com>
>> 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?
>
> This patch looks like it should certainly fix the problem, but that is
> still some god-awful ugly overkill in locking.
>
> I'd rather make the rule be that you have to take the task lock before
> modifying things like the parent pointers (and all the other fundamntal
> pointers), since that's already the rule for most of it anyway.
>
> And then the tasklist lock would go away _entirely_ from /proc (except for
> task lookup in ->readdir/->lookup, of course, where it is fundamentally
> needed and proper - and will probably some day be replaced by RCU, I
> suspect).
Well, I did the stupid safe thing, and it hangs the box once we get up to
a load of 32 with SDET. Below is what I did, the only other issue I can
see in here is that task_mem takes mm->mmap_sem which is now nested inside
the task_lock inside tasklist_lock ... but I can't see anywhere that's a
problem from a quick search
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 09:59:24 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);
- 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);
+ read_unlock(&tasklist_lock);
return buffer - orig;
}
next prev parent reply other threads:[~2003-02-16 18:56 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
2003-02-16 18:21 ` Linus Torvalds
2003-02-16 19:06 ` Martin J. Bligh [this message]
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='26480000.1045422382@[10.10.2.4]' \
--to=mbligh@aracnet.com \
--cc=akpm@digeo.com \
--cc=anton@samba.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.com \
--cc=torvalds@transmeta.com \
--cc=zwane@holomorphy.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®