From: Manfred Spraul <manfred@colorfullife.com>
To: Chris Mason <chris.mason@oracle.com>
Cc: zach.brown@oracle.com, jens.axboe@oracle.com,
linux-kernel@vger.kernel.org, Nick Piggin <npiggin@suse.de>
Subject: Re: [PATCH 1/2] ipc semaphores: reduce ipc_lock contention in semtimedop
Date: Tue, 13 Apr 2010 19:15:30 +0200 [thread overview]
Message-ID: <4BC4A6B2.1090906@colorfullife.com> (raw)
In-Reply-To: <1271098163-3663-2-git-send-email-chris.mason@oracle.com>
Hi Chris,
On 04/12/2010 08:49 PM, Chris Mason wrote:
> /*
> + * when a semaphore is modified, we want to retry the series of operations
> + * for anyone that was blocking on that semaphore. This breaks down into
> + * a few different common operations:
> + *
> + * 1) One modification releases one or more waiters for zero.
> + * 2) Many waiters are trying to get a single lock, only one will get it.
> + * 3) Many modifications to the count will succeed.
> + *
>
Have you thought about odd corner cases:
Nick noticed the last time that it is possible to wait for arbitrary values:
in one semop:
- decrease semaphore 5 by 10
- wait until semaphore 5 is 0
- increase semaphore 5 by 10.
> SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
> unsigned, nsops, const struct timespec __user *, timeout)
> {
> @@ -1129,6 +1306,8 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
> struct sem_queue queue;
> unsigned long jiffies_left = 0;
> struct ipc_namespace *ns;
> + struct sem *blocker = NULL;
> + LIST_HEAD(pending);
>
> ns = current->nsproxy->ipc_ns;
>
> @@ -1168,6 +1347,14 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
> alter = 1;
> }
>
> + /*
> + * try_atomic_semop takes all the locks of all the semaphores in
> + * the sops array. We have to make sure we don't deadlock if userland
> + * happens to send them out of order, so we sort them by semnum.
> + */
> + if (nsops> 1)
> + sort(sops, nsops, sizeof(*sops), sembuf_compare, NULL);
> +
>
Does sorting preserve the behavior?
next prev parent reply other threads:[~2010-04-13 17:15 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-12 18:49 [PATCH RFC] Optimize semtimedop Chris Mason
2010-04-12 18:49 ` [PATCH 1/2] ipc semaphores: reduce ipc_lock contention in semtimedop Chris Mason
2010-04-13 17:15 ` Manfred Spraul [this message]
2010-04-13 17:39 ` Chris Mason
2010-04-13 18:09 ` Nick Piggin
2010-04-13 18:19 ` Chris Mason
2010-04-13 18:57 ` Nick Piggin
2010-04-13 19:01 ` Chris Mason
2010-04-13 19:25 ` Nick Piggin
2010-04-13 19:38 ` Chris Mason
2010-04-13 20:05 ` Nick Piggin
2010-05-16 16:57 ` Manfred Spraul
2010-05-16 22:40 ` Chris Mason
2010-05-17 7:20 ` Nick Piggin
2010-04-14 16:16 ` Manfred Spraul
2010-04-14 17:33 ` Chris Mason
2010-04-14 19:11 ` Manfred Spraul
2010-04-14 19:50 ` Chris Mason
2010-04-15 16:33 ` Manfred Spraul
2010-04-15 16:34 ` Chris Mason
2010-04-13 18:24 ` Zach Brown
2010-04-16 11:26 ` Manfred Spraul
2010-04-16 11:45 ` Chris Mason
2010-04-12 18:49 ` [PATCH 2/2] ipc semaphores: order wakeups based on waiter CPU Chris Mason
2010-04-17 10:24 ` Manfred Spraul
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=4BC4A6B2.1090906@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=chris.mason@oracle.com \
--cc=jens.axboe@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=npiggin@suse.de \
--cc=zach.brown@oracle.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
Powered by JetHome