Re: [PATCH 2/2] ipc/sem.c: move wake_up_process out of the spinlocksection

From: Andrew Morton
Date: Tue May 11 2010 - 17:22:08 EST


On Wed, 28 Apr 2010 21:06:27 +0200
Manfred Spraul <manfred@xxxxxxxxxxxxxxxx> wrote:

> The wake-up part of semtimedop() consists out of two steps:
> - the right tasks must be identified.
> - they must be woken up.
>
> Right now, both steps run while the array spinlock is held.
> This patch reorders the code and moves the actual wake_up_process()
> behind the point where the spinlock is dropped.
>
> The code also moves setting sem->sem_otime to one place: It does not
> make sense to set the last modify time multiple times.

ipc/sem.c: In function 'update_queue':
ipc/sem.c:545: warning: 'retval' may be used uninitialized in this function

which indeed was a bug.

--- a/ipc/sem.c~ipc-semc-move-wake_up_process-out-of-the-spinlock-section-fix-2
+++ a/ipc/sem.c
@@ -542,7 +542,7 @@ static int update_queue(struct sem_array
struct list_head *walk;
struct list_head *pending_list;
int offset;
- int retval;
+ int retval = 0;

/* if there are complex operations around, then knowing the semaphore
* that was modified doesn't help us. Assume that multiple semaphores
_

But I worry that the patch which you sent might not have been the one
which you tested.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/