From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: "Andrew Morton" <akpm@digeo.com>
Cc: "Manfred Spraul" <manfred@colorfullife.com>,
<linux-kernel@vger.kernel.org>
Subject: RE: ipc semaphore optimization
Date: Fri, 27 Jun 2003 15:48:22 -0700 [thread overview]
Message-ID: <41F331DBE1178346A6F30D7CF124B24B2A4871@fmsmsx409.fm.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 328 bytes --]
Hi Andrew,
> ipc/sem.c changed significantly between 2.5.72 and 2.5.73. Could
> you please update this, retest, resend?
>
> Please Cc Manfred on the update too, thanks.
Updated patch relative to 2.5.73, tested and verified. Manfred's change
is in the sem_undo area while this patch is in the wake-up path.
- Ken
[-- Attachment #2: sem2573.patch --]
[-- Type: application/octet-stream, Size: 4286 bytes --]
diff -Nur linux-2.5.73/ipc/sem.c linux-2.5.73.sem/ipc/sem.c
--- linux-2.5.73/ipc/sem.c Sun Jun 22 11:32:41 2003
+++ linux-2.5.73.sem/ipc/sem.c Fri Jun 27 15:23:26 2003
@@ -49,6 +49,10 @@
* increase. If there are decrement operations in the operations
* array we do the same as before.
*
+ * With the incarnation of O(1) scheduler, it becomes unnecessary to perform
+ * check/retry algorithm for waking up blocked processes as the new scheduler
+ * is better at handling thread switch than the old one.
+ *
* /proc/sysvipc/sem support (c) 1999 Dragos Acostachioaie <dragos@iname.com>
*
* SMP-threaded, sysctl's added
@@ -258,8 +262,7 @@
*/
static int try_atomic_semop (struct sem_array * sma, struct sembuf * sops,
- int nsops, struct sem_undo *un, int pid,
- int do_undo)
+ int nsops, struct sem_undo *un, int pid)
{
int result, sem_op;
struct sembuf *sop;
@@ -289,10 +292,6 @@
curr->semval = result;
}
- if (do_undo) {
- result = 0;
- goto undo;
- }
sop--;
while (sop >= sops) {
sma->sem_base[sop->sem_num].sempid = pid;
@@ -334,23 +333,14 @@
for (q = sma->sem_pending; q; q = q->next) {
- if (q->status == 1)
- continue; /* this one was woken up before */
-
error = try_atomic_semop(sma, q->sops, q->nsops,
- q->undo, q->pid, q->alter);
+ q->undo, q->pid);
/* Does q->sleeper still need to sleep? */
if (error <= 0) {
- /* Found one, wake it up */
- wake_up_process(q->sleeper);
- if (error == 0 && q->alter) {
- /* if q-> alter let it self try */
- q->status = 1;
- return;
- }
q->status = error;
remove_from_queue(sma,q);
+ wake_up_process(q->sleeper);
}
}
}
@@ -1062,7 +1052,7 @@
if (error)
goto out_unlock_free;
- error = try_atomic_semop (sma, sops, nsops, un, current->pid, 0);
+ error = try_atomic_semop (sma, sops, nsops, un, current->pid);
if (error <= 0)
goto update;
@@ -1075,55 +1065,46 @@
queue.nsops = nsops;
queue.undo = un;
queue.pid = current->pid;
- queue.alter = decrease;
queue.id = semid;
if (alter)
append_to_queue(sma ,&queue);
else
prepend_to_queue(sma ,&queue);
- for (;;) {
- queue.status = -EINTR;
- queue.sleeper = current;
- current->state = TASK_INTERRUPTIBLE;
- sem_unlock(sma);
+ queue.status = -EINTR;
+ queue.sleeper = current;
+ current->state = TASK_INTERRUPTIBLE;
+ sem_unlock(sma);
- if (timeout)
- jiffies_left = schedule_timeout(jiffies_left);
- else
- schedule();
+ if (timeout)
+ jiffies_left = schedule_timeout(jiffies_left);
+ else
+ schedule();
- sma = sem_lock(semid);
- if(sma==NULL) {
- if(queue.prev != NULL)
- BUG();
- error = -EIDRM;
- goto out_free;
- }
- /*
- * If queue.status == 1 we where woken up and
- * have to retry else we simply return.
- * If an interrupt occurred we have to clean up the
- * queue
- *
- */
- if (queue.status == 1)
- {
- error = try_atomic_semop (sma, sops, nsops, un,
- current->pid,0);
- if (error <= 0)
- break;
- } else {
- error = queue.status;
- if (error == -EINTR && timeout && jiffies_left == 0)
- error = -EAGAIN;
- if (queue.prev) /* got Interrupt */
- break;
- /* Everything done by update_queue */
- goto out_unlock_free;
- }
+ sma = sem_lock(semid);
+ if(sma==NULL) {
+ if(queue.prev != NULL)
+ BUG();
+ error = -EIDRM;
+ goto out_free;
+ }
+
+ /*
+ * If queue.status != -EINTR we are woken up by another process
+ */
+ error = queue.status;
+ if (queue.status != -EINTR) {
+ goto out_unlock_free;
}
+
+ /*
+ * If an interrupt occurred we have to clean up the queue
+ */
+ if (timeout && jiffies_left == 0)
+ error = -EAGAIN;
remove_from_queue(sma,&queue);
+ goto out_unlock_free;
+
update:
if (alter)
update_queue (sma);
diff -Nur linux-2.5.73/include/linux/sem.h linux-2.5.73.sem/include/linux/sem.h
--- linux-2.5.73/include/linux/sem.h Sun Jun 22 11:32:42 2003
+++ linux-2.5.73.sem/include/linux/sem.h Fri Jun 27 14:55:44 2003
@@ -109,7 +109,6 @@
int id; /* internal sem id */
struct sembuf * sops; /* array of pending operations */
int nsops; /* number of operations */
- int alter; /* operation will alter semaphore */
};
/* Each task has a list of undo requests. They are executed automatically
next reply other threads:[~2003-06-27 22:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-27 22:48 Chen, Kenneth W [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-07-01 16:36 Chen, Kenneth W
2003-06-27 20:22 Chen, Kenneth W
2003-06-27 19:43 Manfred Spraul
2003-06-27 18:03 Margit Schubert-While
2003-06-27 17:13 Chen, Kenneth W
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=41F331DBE1178346A6F30D7CF124B24B2A4871@fmsmsx409.fm.intel.com \
--to=kenneth.w.chen@intel.com \
--cc=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred@colorfullife.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®