All of lore.kernel.org
 help / color / mirror / Atom feed
From: mingming cao <cmm@us.ibm.com>
To: Hugh Dickins <hugh@veritas.com>,
	torvalds@transmeta.com, linux-kernel@vger.kernel.org,
	cmm@us.ibm.com, akpm@zip.com.au
Subject: Re: [PATCH] Breaking down the global IPC locks - 2.5.31
Date: Tue, 20 Aug 2002 10:50:55 -0700	[thread overview]
Message-ID: <3D62817F.B2AA96AD@us.ibm.com> (raw)
In-Reply-To: 3D618D98.A9163EB1@us.ibm.com

[-- Attachment #1: Type: text/plain, Size: 293 bytes --]

mingming cao wrote:
> 
> This patch breaks the three global IPC locks into one lock per IPC ID.
> By doing so it could reduce possible lock contention in workloads which
> make heavy use of IPC semaphores, message queues and Shared
> memories...etc.

Here is the patch again. Fixed a typo. *_^

[-- Attachment #2: ipclock.patch --]
[-- Type: text/plain, Size: 2785 bytes --]

diff -urN -X ../dontdiff ../base/linux-2.5.31/include/linux/ipc.h 2.5.31-ipc/include/linux/ipc.h
--- ../base/linux-2.5.31/include/linux/ipc.h	Sat Aug 10 18:41:16 2002
+++ 2.5.31-ipc/include/linux/ipc.h	Tue Aug 13 10:23:59 2002
@@ -56,6 +56,7 @@
 /* used by in-kernel data structures */
 struct kern_ipc_perm
 {
+	spinlock_t	lock;
 	key_t		key;
 	uid_t		uid;
 	gid_t		gid;
diff -urN -X ../dontdiff ../base/linux-2.5.31/ipc/util.c 2.5.31-ipc/ipc/util.c
--- ../base/linux-2.5.31/ipc/util.c	Sat Aug 10 18:41:27 2002
+++ 2.5.31-ipc/ipc/util.c	Wed Aug 14 15:59:19 2002
@@ -74,7 +74,7 @@
 		printk(KERN_ERR "ipc_init_ids() failed, ipc service disabled.\n");
 		ids->size = 0;
 	}
-	ids->ary = SPIN_LOCK_UNLOCKED;
+	ids->ary =RW_LOCK_UNLOCKED;
 	for(i=0;i<ids->size;i++)
 		ids->entries[i].p = NULL;
 }
@@ -120,13 +120,13 @@
 	for(i=ids->size;i<newsize;i++) {
 		new[i].p = NULL;
 	}
-	spin_lock(&ids->ary);
+	write_lock(&ids->ary);
 
 	old = ids->entries;
 	ids->entries = new;
 	i = ids->size;
 	ids->size = newsize;
-	spin_unlock(&ids->ary);
+	write_unlock(&ids->ary);
 	ipc_free(old, sizeof(struct ipc_id)*i);
 	return ids->size;
 }
@@ -165,7 +165,9 @@
 	if(ids->seq > ids->seq_max)
 		ids->seq = 0;
 
-	spin_lock(&ids->ary);
+	new->lock = SPIN_LOCK_UNLOCKED;
+	read_lock(&ids->ary);
+	spin_lock(&new->lock);
 	ids->entries[id].p = new;
 	return id;
 }
diff -urN -X ../dontdiff ../base/linux-2.5.31/ipc/util.h 2.5.31-ipc/ipc/util.h
--- ../base/linux-2.5.31/ipc/util.h	Sat Aug 10 18:41:40 2002
+++ 2.5.31-ipc/ipc/util.h	Wed Aug 14 17:05:22 2002
@@ -19,7 +19,7 @@
 	unsigned short seq;
 	unsigned short seq_max;
 	struct semaphore sem;	
-	spinlock_t ary;
+	rwlock_t ary;
 	struct ipc_id* entries;
 };
 
@@ -47,7 +47,7 @@
 
 extern inline void ipc_lockall(struct ipc_ids* ids)
 {
-	spin_lock(&ids->ary);
+	write_lock(&ids->ary);
 }
 
 extern inline struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id)
@@ -63,7 +63,7 @@
 
 extern inline void ipc_unlockall(struct ipc_ids* ids)
 {
-	spin_unlock(&ids->ary);
+	write_unlock(&ids->ary);
 }
 extern inline struct kern_ipc_perm* ipc_lock(struct ipc_ids* ids, int id)
 {
@@ -72,16 +72,29 @@
 	if(lid >= ids->size)
 		return NULL;
 
-	spin_lock(&ids->ary);
+	read_lock(&ids->ary);
 	out = ids->entries[lid].p;
-	if(out==NULL)
-		spin_unlock(&ids->ary);
+	if(out==NULL) {
+		read_unlock(&ids->ary);
+		return NULL;
+	}
+	spin_lock(&out->lock);
 	return out;
 }
 
 extern inline void ipc_unlock(struct ipc_ids* ids, int id)
 {
-	spin_unlock(&ids->ary);
+	int lid = id % SEQ_MULTIPLIER;
+	struct kern_ipc_perm* out;
+
+        if(lid >= ids->size)
+		return;
+	out = ids->entries[lid].p;
+	if (out == NULL)
+		return;
+
+	spin_unlock(&out->lock);
+	read_unlock(&ids->ary);
 }
 
 extern inline int ipc_buildid(struct ipc_ids* ids, int id, int seq)

  reply	other threads:[~2002-08-20 17:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-05 19:48 [PATCH] Breaking down the global IPC locks mingming cao
2002-08-06 15:53 ` Hugh Dickins
2002-08-06 20:50   ` mingming cao
2002-08-20  0:30   ` [PATCH] Breaking down the global IPC locks - 2.5.31 mingming cao
2002-08-20 17:50     ` mingming cao [this message]
2002-08-21 16:51       ` Hugh Dickins
2002-08-23  0:36         ` mingming cao

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=3D62817F.B2AA96AD@us.ibm.com \
    --to=cmm@us.ibm.com \
    --cc=akpm@zip.com.au \
    --cc=hugh@veritas.com \
    --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 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.