public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Corey Minyard <minyard@acm.org>
To: linux-kernel@vger.kernel.org
Subject: [patch] Threads performance - allow signal handler to not call handler
Date: Wed, 27 Mar 2002 15:46:01 -0600	[thread overview]
Message-ID: <3CA23D99.6030900@acm.org> (raw)

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

This patch modfies i386 to add a flag to sa_flags in sigaction that will 
cause the signal handler to not be called (but all other side effects to 
occur).  This may seem unusual, but signals are often used between 
threads to wake each other up, the signal handler is just a dummy and is 
pure overhead.  With this patch, if the flag is set, the signal handler 
won't get called (thus saving the overhead of going in and out of 
userland for the handler), but it will still wake up sigsuspend() and 
select().  The beauty of this is the flag will be ignored on kernels 
without it, so it will still work, with just lower performance.

-Corey

[-- Attachment #2: linux-nocallhndlr.patch --]
[-- Type: text/plain, Size: 1533 bytes --]

--- ./arch/i386/kernel/signal.c.nocallhndlr	Wed Mar 27 10:56:29 2002
+++ ./arch/i386/kernel/signal.c	Wed Mar 27 11:04:45 2002
@@ -558,21 +558,24 @@
 		}
 	}
 
-	/* Set up the stack frame */
-	if (ka->sa.sa_flags & SA_SIGINFO)
-		setup_rt_frame(sig, ka, info, oldset, regs);
-	else
-		setup_frame(sig, ka, oldset, regs);
-
 	if (ka->sa.sa_flags & SA_ONESHOT)
 		ka->sa.sa_handler = SIG_DFL;
 
-	if (!(ka->sa.sa_flags & SA_NODEFER)) {
-		spin_lock_irq(&current->sigmask_lock);
-		sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
-		sigaddset(&current->blocked,sig);
-		recalc_sigpending(current);
-		spin_unlock_irq(&current->sigmask_lock);
+	/* Set up the stack frame */
+	if (! (ka->sa.sa_flags & SA_NOCALLHNDLR)) {
+		if (ka->sa.sa_flags & SA_SIGINFO)
+			setup_rt_frame(sig, ka, info, oldset, regs);
+		else
+			setup_frame(sig, ka, oldset, regs);
+
+		if (!(ka->sa.sa_flags & SA_NODEFER)) {
+			spin_lock_irq(&current->sigmask_lock);
+			sigorsets(&current->blocked,&current->blocked,
+				  &ka->sa.sa_mask);
+			sigaddset(&current->blocked,sig);
+			recalc_sigpending(current);
+			spin_unlock_irq(&current->sigmask_lock);
+		}
 	}
 }
 
--- ./include/asm-i386/signal.h.nocallhndlr	Wed Mar 27 10:56:12 2002
+++ ./include/asm-i386/signal.h	Wed Mar 27 11:17:38 2002
@@ -91,6 +91,7 @@
 #define SA_RESTART	0x10000000
 #define SA_NODEFER	0x40000000
 #define SA_RESETHAND	0x80000000
+#define SA_NOCALLHNDLR	0x00800000 /* Don't really call the handler. */
 
 #define SA_NOMASK	SA_NODEFER
 #define SA_ONESHOT	SA_RESETHAND

             reply	other threads:[~2002-03-27 21:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-27 21:46 Corey Minyard [this message]
2002-03-27 22:02 ` [patch] Threads performance - allow signal handler to not call handler Jeff Dike

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=3CA23D99.6030900@acm.org \
    --to=minyard@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    /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