public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luca Barbieri <ldb@ldb.ods.org>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Linux-Kernel ML <linux-kernel@vger.kernel.org>
Subject: [PATCH] Small futex improvement
Date: 18 Nov 2002 17:00:43 +0100	[thread overview]
Message-ID: <1037635243.1774.149.camel@ldb> (raw)

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

This patch makes the futex code check utime only when waiting.
This makes it possible to do futex wakes without clearing the register
containing the utime parameter.
The code also becomes cleaner.

--- linux-2.5.47_ldb/kernel/futex.c~	2002-11-01 13:31:28.000000000 +0100
+++ linux-2.5.47_ldb/kernel/futex.c	2002-11-17 21:50:41.000000000 +0100
@@ -314,6 +314,23 @@ out:
 	return ret;
 }
 
+static inline int futex_wait_utime(unsigned long uaddr,
+		      int offset,
+		      int val,
+		      struct timespec* utime)
+{
+	unsigned long time = MAX_SCHEDULE_TIMEOUT;
+
+	if (utime) {
+		struct timespec t;
+		if (copy_from_user(&t, utime, sizeof(t)) != 0)
+			return -EFAULT;
+		time = timespec_to_jiffies(&t) + 1;
+	}
+
+	return futex_wait(uaddr, offset, val, time);
+}
+
 static int futex_close(struct inode *inode, struct file *filp)
 {
 	struct futex_q *q = filp->private_data;
@@ -421,17 +438,9 @@ out:
 
 asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec *utime)
 {
-	unsigned long time = MAX_SCHEDULE_TIMEOUT;
 	unsigned long pos_in_page;
 	int ret;
 
-	if (utime) {
-		struct timespec t;
-		if (copy_from_user(&t, utime, sizeof(t)) != 0)
-			return -EFAULT;
-		time = timespec_to_jiffies(&t) + 1;
-	}
-
 	pos_in_page = uaddr % PAGE_SIZE;
 
 	/* Must be "naturally" aligned */
@@ -440,7 +449,7 @@ asmlinkage int sys_futex(unsigned long u
 
 	switch (op) {
 	case FUTEX_WAIT:
-		ret = futex_wait(uaddr, pos_in_page, val, time);
+		ret = futex_wait_utime(uaddr, pos_in_page, val, utime);
 		break;
 	case FUTEX_WAKE:
 		ret = futex_wake(uaddr, pos_in_page, val);



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

                 reply	other threads:[~2002-11-18 15:53 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=1037635243.1774.149.camel@ldb \
    --to=ldb@ldb.ods.org \
    --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