public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benjamin LaHaise <bcrl@redhat.com>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] 4KB stack + irq stack for x86
Date: Wed, 5 Jun 2002 17:07:09 -0400	[thread overview]
Message-ID: <20020605170709.F4697@redhat.com> (raw)
In-Reply-To: <20020605144357.A4697@redhat.com> <Pine.LNX.4.33.0206051150320.10556-100000@penguin.transmeta.com>

On Wed, Jun 05, 2002 at 11:53:10AM -0700, Linus Torvalds wrote:
> All of the flags should be "sticky one-bits", so just oring them should do 
> the right thing.
> 
> That way we don't have to add nasty BUG checks to the code, and since 
> we're already dirtying both cache-lines the extra overhead should 
> literally be just the cost of doing one locked "orl".

This patch on top of the others should do that.  I've placed a full 
diff from 2.5.20 to the current code at 
http://www.kvack.org/~blah/stack-v2.5.20-A2.diff .

		-ben
-- 
"You will be reincarnated as a toad; and you will be much happier."

:r ~/patches/v2.5.20/v2.5.20-smallstack-A0-A1.diff
diff -urN stackcheck-v2.5.20-A1/arch/i386/kernel/entry.S stack-2.5.20.diff/arch/i386/kernel/entry.S
--- stackcheck-v2.5.20-A1/arch/i386/kernel/entry.S	Wed Jun  5 15:59:12 2002
+++ stack-2.5.20.diff/arch/i386/kernel/entry.S	Wed Jun  5 15:55:09 2002
@@ -365,26 +365,34 @@
 	movl TI_IRQ_STACK(%ebx),%ecx
 	movl TI_TASK(%ebx),%edx
 	movl %esp,%eax
-	leal (THREAD_SIZE-4)(%ecx),%ebx
+	leal (THREAD_SIZE-4)(%ecx),%esi
 	testl %ecx,%ecx			# is there a valid irq_stack?
 
 	# switch to the irq stack
 #ifdef CONFIG_X86_HAVE_CMOV
-	cmovnz %ebx,%esp
-#warning using cmov
+	cmovnz %esi,%esp
 #else
-#warning cannot use cmov
 	jnz 1f
-	mov %ebx,%esp
+	mov %esi,%esp
 1:
 #endif
 
 	# update the task pointer in the irq stack
-	GET_THREAD_INFO(%ebx)
-	movl %edx,TI_TASK(%ebx)
+	GET_THREAD_INFO(%esi)
+	movl %edx,TI_TASK(%esi)
 
 	call do_IRQ
+
 	movl %eax,%esp			# potentially restore non-irq stack
+
+	# copy flags from the irq stack back into the task's thread_info
+	# %esi is saved over the do_IRQ call and contains the irq stack
+	# thread_info pointer
+	# %ebx contains the original thread_info pointer
+	movl TI_FLAGS(%esi),%eax
+	movl $0,TI_FLAGS(%esi)
+	LOCK orl %eax,TI_FLAGS(%ebx)
+
 	jmp ret_from_intr
 
 #define BUILD_INTERRUPT(name, nr)	\
diff -urN stackcheck-v2.5.20-A1/arch/i386/kernel/smpboot.c stack-2.5.20.diff/arch/i386/kernel/smpboot.c
--- stackcheck-v2.5.20-A1/arch/i386/kernel/smpboot.c	Wed Jun  5 15:59:08 2002
+++ stack-2.5.20.diff/arch/i386/kernel/smpboot.c	Wed Jun  5 15:12:36 2002
@@ -875,7 +875,13 @@
 
 	/* So we see what's up   */
 	printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
-	stack_start.esp = (void *) (THREAD_SIZE + (char *)idle->thread_info);
+
+	/* The -4 is to correct for the fact that the stack pointer
+	 * is used to find the location of the thread_info structure
+	 * by masking off several of the LSBs.  Without the -4, esp
+	 * is pointing to the page after the one the stack is on.
+	 */
+	stack_start.esp = (void *)(THREAD_SIZE - 4 + (char *)idle->thread_info);
 
 	/*
 	 * This grunge runs the startup process for
diff -urN stackcheck-v2.5.20-A1/include/asm-i386/thread_info.h stack-2.5.20.diff/include/asm-i386/thread_info.h
--- stackcheck-v2.5.20-A1/include/asm-i386/thread_info.h	Wed Jun  5 15:59:08 2002
+++ stack-2.5.20.diff/include/asm-i386/thread_info.h	Wed Jun  5 14:55:04 2002
@@ -57,6 +57,7 @@
  * macros/functions for gaining access to the thread information structure
  */
 #define THREAD_ORDER	0
+#define INIT_THREAD_SIZE	THREAD_SIZE
 
 #ifndef __ASSEMBLY__
 #define init_thread_info	(init_thread_union.thread_info)

  reply	other threads:[~2002-06-05 21:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-05  2:55 [RFC] 4KB stack + irq stack for x86 Benjamin LaHaise
2002-06-05 15:33 ` Linus Torvalds
2002-06-05 18:43   ` Benjamin LaHaise
2002-06-05 18:53     ` Linus Torvalds
2002-06-05 21:07       ` Benjamin LaHaise [this message]
2002-06-05 22:15 ` Steve Lord
2002-06-05 22:31   ` Benjamin LaHaise
2002-06-05 23:13     ` David S. Miller
2002-06-06  0:24       ` Larry McVoy
2002-06-06  1:15       ` Andi Kleen
2002-06-02 15:52         ` Pavel Machek
2002-06-09 18:50           ` Andi Kleen
2002-06-06  1:42         ` Benjamin LaHaise
2002-06-06  2:30           ` Stephen Lord
     [not found] <20020604225539.F9111@redhat.com.suse.lists.linux.kernel>
     [not found] ` <Pine.LNX.4.44.0206050820100.2941-100000@home.transmeta.com.suse.lists.linux.kernel>
     [not found]   ` <20020605144357.A4697@redhat.com.suse.lists.linux.kernel>
2002-06-05 20:40     ` Andi Kleen
2002-06-05 20:55       ` Linus Torvalds
  -- strict thread matches above, loose matches on Subject: below --
2002-06-06 13:32 Ulrich Weigand
     [not found] <mailman.1023370621.16639.linux-kernel2news@redhat.com>
2002-06-06 17:37 ` Pete Zaitcev
2002-06-07  1:06   ` David S. Miller
2002-06-06 19:24 Ulrich Weigand
     [not found] <OF70FD985F.A9C66B00-ONC1256BD0.0069C993@de.ibm.com.suse.lists.linux.kernel>
2002-06-06 19:49 ` Andi Kleen
2002-06-06 20:27   ` David Mosberger
2002-06-07 11:28   ` Maciej W. Rozycki
2002-06-06 20:55 Ulrich Weigand
2002-06-06 21:19 ` David Mosberger
2002-06-06 22:10   ` Martin J. Bligh
2002-06-07  0:59   ` William Lee Irwin III

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=20020605170709.F4697@redhat.com \
    --to=bcrl@redhat.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