From: Rusty Russell <rusty@rustcorp.com.au>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, frankeh@watson.ibm.com
Subject: [PATCH] Futex update IV: use a waitqueue.
Date: Thu, 06 Jun 2002 17:15:37 +1000 [thread overview]
Message-ID: <E17FrUg-0005GX-00@wagner.rustcorp.com.au> (raw)
Name: Use a waitqueue, rather than a task ptr
Author: Rusty Russell
Status: Tested in 2.5.20
Depends: Futex/copy-from-user.patch.gz
D: This turns the simple task pointer into a waitqueue, which is
D: needed for the poll() patch.
diff -urN -I \$.*\$ --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.20.18954/kernel/futex.c linux-2.5.20.18954.updated/kernel/futex.c
--- linux-2.5.20.18954/kernel/futex.c Thu Jun 6 17:12:20 2002
+++ linux-2.5.20.18954.updated/kernel/futex.c Thu Jun 6 17:13:05 2002
@@ -49,7 +49,7 @@
the relevent ones (hashed queues may be shared) */
struct futex_q {
struct list_head list;
- struct task_struct *task;
+ wait_queue_head_t waiters;
/* Page struct and offset within it. */
struct page *page;
unsigned int offset;
@@ -69,6 +69,11 @@
return &futex_queues[hash_long(h, FUTEX_HASHBITS)];
}
+static inline void tell_waiter(struct futex_q *q)
+{
+ wake_up_all(&q->waiters);
+}
+
static int futex_wake(struct list_head *head,
struct page *page,
unsigned int offset,
@@ -83,7 +88,7 @@
if (this->page == page && this->offset == offset) {
list_del_init(i);
- wake_up_process(this->task);
+ tell_waiter(this);
num_woken++;
if (num_woken >= num) break;
}
@@ -94,11 +99,12 @@
/* Add at end to avoid starvation */
static inline void queue_me(struct list_head *head,
+ wait_queue_t *wait,
struct futex_q *q,
struct page *page,
unsigned int offset)
{
- q->task = current;
+ add_wait_queue(&q->waiters, wait);
q->page = page;
q->offset = offset;
@@ -150,10 +156,11 @@
{
int curval;
struct futex_q q;
+ DECLARE_WAITQUEUE(wait, current);
int ret = 0;
set_current_state(TASK_INTERRUPTIBLE);
- queue_me(head, &q, page, offset);
+ queue_me(head, &wait, &q, page, offset);
/* Page is pinned, but may no longer be in this address space. */
if (get_user(curval, uaddr) != 0) {
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
reply other threads:[~2002-06-06 7:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=E17FrUg-0005GX-00@wagner.rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=frankeh@watson.ibm.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 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®