All of lore.kernel.org
 help / color / mirror / Atom feed
From: Scott Maxwell <maxwell@ScottMaxwell.org>
To: linux-kernel@vger.kernel.org
Cc: manfreds@colorfullife.com
Subject: [PATCH] SysV IPC loop speedups, kernel 2.4.3
Date: Tue, 17 Apr 2001 23:00:59 -0700	[thread overview]
Message-ID: <3ADD2D9B.75927E9C@ScottMaxwell.org> (raw)

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

This patch contains a couple of micro-optimizations for the loops in
ipc/msg.c's load_msg() and store_msg().  It works fine for me under
2.4.3.

-- 
-------------------------+--------------------------------------------
R H L U  Scott Maxwell:  | ``Life results from the non-random survival
E A I X     maxwell@     |   of randomly varying replicators.''
D T N 6 ScottMaxwell.org |     -- Richard Dawkins

[-- Attachment #2: ipc-msg-loop.patch --]
[-- Type: text/plain, Size: 1844 bytes --]

diff -urN linux-2.4.3/ipc/msg.c linux/ipc/msg.c
--- linux-2.4.3/ipc/msg.c	Mon Feb 19 10:18:18 2001
+++ linux/ipc/msg.c	Tue Apr 17 22:34:36 2001
@@ -177,28 +177,30 @@
 		goto out_err;
 	}
 
-	len -= alen;
-	src = ((char*)src)+alen;
-	pseg = &msg->next;
-	while(len > 0) {
-		struct msg_msgseg* seg;
-		alen = len;
-		if(alen > DATALEN_SEG)
-			alen = DATALEN_SEG;
-		seg = (struct msg_msgseg *) kmalloc (sizeof(*seg) + alen, GFP_KERNEL);
-		if(seg==NULL) {
-			err=-ENOMEM;
-			goto out_err;
-		}
-		*pseg = seg;
-		seg->next = NULL;
-		if(copy_from_user (seg+1, src, alen)) {
-			err = -EFAULT;
-			goto out_err;
+	if (len > DATALEN_MSG) {
+		pseg = &msg->next;
+		while(len > alen) {
+			struct msg_msgseg* seg;
+
+			len -= alen;
+			src = ((char*)src)+alen;
+
+			alen = len;
+			if(alen > DATALEN_SEG)
+				alen = DATALEN_SEG;
+			seg = (struct msg_msgseg *) kmalloc (sizeof(*seg) + alen, GFP_KERNEL);
+			if(seg==NULL) {
+				err=-ENOMEM;
+				goto out_err;
+			}
+			*pseg = seg;
+			seg->next = NULL;
+			if(copy_from_user (seg+1, src, alen)) {
+				err = -EFAULT;
+				goto out_err;
+			}
+			pseg = &seg->next;
 		}
-		pseg = &seg->next;
-		len -= alen;
-		src = ((char*)src)+alen;
 	}
 	return msg;
 
@@ -218,18 +220,20 @@
 	if(copy_to_user (dest, msg+1, alen))
 		return -1;
 
-	len -= alen;
-	dest = ((char*)dest)+alen;
-	seg = msg->next;
-	while(len > 0) {
-		alen = len;
-		if(alen > DATALEN_SEG)
-			alen = DATALEN_SEG;
-		if(copy_to_user (dest, seg+1, alen))
-			return -1;
-		len -= alen;
-		dest = ((char*)dest)+alen;
-		seg=seg->next;
+	if (len > DATALEN_MSG) {
+		seg = msg->next;
+		while(len > alen) {
+			len -= alen;
+			dest = ((char*)dest)+alen;
+
+			alen = len;
+			if(alen > DATALEN_SEG)
+				alen = DATALEN_SEG;
+			if(copy_to_user (dest, seg+1, alen))
+				return -1;
+
+			seg=seg->next;
+		}
 	}
 	return 0;
 }

                 reply	other threads:[~2001-04-18  9:21 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=3ADD2D9B.75927E9C@ScottMaxwell.org \
    --to=maxwell@scottmaxwell.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfreds@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.