linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Debugging deadlocks using SV semaphores via PROC FS
@ 2004-04-27  7:38 Steffen Rumler
  0 siblings, 0 replies; only message in thread
From: Steffen Rumler @ 2004-04-27  7:38 UTC (permalink / raw)
  To: linuxppc

[-- 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;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-04-27  7:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-27  7:38 Debugging deadlocks using SV semaphores via PROC FS Steffen Rumler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).