From: Steffen Rumler <Steffen.Rumler@siemens.com>
To: linuxppc <linuxppc-embedded@lists.linuxppc.org>
Subject: Debugging deadlocks using SV semaphores via PROC FS
Date: Tue, 27 Apr 2004 09:38:38 +0200 [thread overview]
Message-ID: <408E0DFE.9000302@siemens.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 785 bytes --]
Hi,
I have extended the PROC FS entry in ipc/sem.c for the 2.4.20 DEVEL
in order to debug deadlock problems; see attachment.
For each semaphore array, now also all array elements: (last-pid, sem.-value)
will be traced.
In this way, I can easy answer the question:
"Which process is holding a distinct semaphore in a permanent way ?"
An subsequent strace of the found process provides additional information.
Steffen
--
--------------------------------------------------------------
Steffen Rumler
ICN CP D NT SW 3
Siemens AG
Hofmannstr. 51 Email: Steffen.Rumler@siemens.com
D-81359 Munich Phone: +49 89 722-44061
Germany Fax : +49 89 722-36703
--------------------------------------------------------------
[-- Attachment #2: sem.c --]
[-- Type: text/plain, Size: 2130 bytes --]
static int sysvipc_sem_read_proc(char *buffer, char **start, off_t offset, int length, int *eof, void *data)
{
off_t pos = 0;
off_t begin = 0;
int i, len = 0;
int j;
struct sem *sem_base;
len += sprintf(buffer, " key semid perms nsems uid gid cuid cgid otime ctime\n");
down(&sem_ids.sem);
for(i = 0; i <= sem_ids.max_id; i++) {
struct sem_array *sma;
sma = sem_lock(i);
if(sma) {
len += sprintf(buffer + len, "\n%10d %10d %4o %10lu %5u %5u %5u %5u %10lu %10lu\n",
sma->sem_perm.key,
sem_buildid(i,sma->sem_perm.seq),
sma->sem_perm.mode,
sma->sem_nsems,
sma->sem_perm.uid,
sma->sem_perm.gid,
sma->sem_perm.cuid,
sma->sem_perm.cgid,
sma->sem_otime,
sma->sem_ctime);
pos += len;
if(pos < offset) {
len = 0;
begin = pos;
}
if(pos > offset + length){
sem_unlock(i);
goto done;
}
/* S.R.: print-out (pid, val) pairs for semaphore array
*/
sem_base = sma->sem_base;
for(j=0; j < sma->sem_nsems; j++){
len += sprintf(buffer + len,
" %ld (pid) %ld (val)\n",
(sem_base->sempid) & 0xffff,
sem_base->semval);
pos += len;
if(pos < offset) {
len = 0;
begin = pos;
}
if(pos > offset + length){
sem_unlock(i);
goto done;
}
sem_base++;
}
sem_unlock(i);
}
}
*eof = 1;
done:
up(&sem_ids.sem);
*start = buffer + (offset - begin);
len -= (offset - begin);
if(len > length)
len = length;
if(len < 0)
len = 0;
return len;
}
reply other threads:[~2004-04-27 7:38 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=408E0DFE.9000302@siemens.com \
--to=steffen.rumler@siemens.com \
--cc=linuxppc-embedded@lists.linuxppc.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 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.