From: <cutaway@bellsouth.net>
To: <linux-kernel@vger.kernel.org>
Subject: [RFC] exit_thread() speedups in x86 process.c
Date: Mon, 13 Jun 2005 21:16:42 -0400 [thread overview]
Message-ID: <000b01c5707e$c189c930$2800000a@pc365dualp2> (raw)
In the current exit_thread() implementation, it appears including the I/O
port map tear down code within the exit_thread() generates enough autovar
data that the compiler needs to spill 4 registers to the stack resulting in
(4) PUSH on entry and (4) POP on exit.
When I tried extracting the map teardown into a seperate function, the
situation changed dramatically to where NO REGISTERS were being
pushed/popped in the normal path entry/exit.
Below is the original generated code, code my proposal generated, and an
#ifdef'd change that produced this elimination of the PUSH/POP's.
Unless I'm on drugs, this looks like a solid winner in a fairly important
code path :)
--------- Original exit_thread() -------
615 .globl exit_thread
616 .type exit_thread,@function
617 exit_thread:
618 02cc 55 pushl %ebp
619 02cd 57 pushl %edi
620 02ce 56 pushl %esi
621 02cf 53 pushl %ebx
622 02d0 B800E0FF movl $-8192,%eax
blah, blah...
629 02e5 85C0 testl %eax,%eax
630 02e7 7507 jne .L1675
631 .L1657:
632 02e9 5B popl %ebx
633 02ea 5E popl %esi
634 02eb 5F popl %edi
635 02ec 5D popl %ebp
636 02ed C3 ret
637 02ee 89F6 .p2align 2
638 .L1675:
639 02f0 50 pushl %eax
640 02f1 E8FCFFFF call kfree
...Lots of stuff here to tear down port maps...
--------- Proposed exit_thread() -------
655 .globl exit_thread
656 .type exit_thread,@function
657 exit_thread:
///////////////////////////////////////
// Note how all PUSH/POP's are
// gone from the mainline code now
///////////////////////////////////////
658 0340 B800E0FF movl $-8192,%eax
658 FF
659
660 0345 21E0 andl %esp,%eax
661
662 0347 8B00 movl (%eax),%eax
663 0349 05C00100 addl $448,%eax
663 00
664 034e 8B907C02 movl 636(%eax),%edx
664 0000
665 0354 85D2 testl %edx,%edx
666 0356 7504 jne .L1676
667 0358 C3 ret
668 0359 8D7600 .p2align 2
669 .L1676:
670 035c 50 pushl %eax
671 035d E86AFFFF call NukePortMap
671 FF
672 0362 58 popl %eax
673 0363 C3 ret
---- This is the change that eliminates the PUSH/POP's ---
#ifdef __TONYI__
static void NukePortMap(struct thread_struct *t)
{
int cpu = get_cpu();
struct tss_struct *tss = &per_cpu(init_tss, cpu);
kfree(t->io_bitmap_ptr);
t->io_bitmap_ptr = NULL;
/*
* Careful, clear this in the TSS too:
*/
memset(tss->io_bitmap, 0xff, tss->io_bitmap_max);
t->io_bitmap_max = 0;
tss->io_bitmap_owner = NULL;
tss->io_bitmap_max = 0;
tss->io_bitmap_base = INVALID_IO_BITMAP_OFFSET;
put_cpu();
}
#endif
/*
* Free current thread data structures etc..
*/
void exit_thread(void)
{
struct task_struct *tsk = current;
struct thread_struct *t = &tsk->thread;
/* The process may have allocated an io port bitmap... nuke it. */
if (unlikely(NULL != t->io_bitmap_ptr)) {
#ifdef __TONYI__
NukePortMap(t);
#else
int cpu = get_cpu();
struct tss_struct *tss = &per_cpu(init_tss, cpu);
kfree(t->io_bitmap_ptr);
t->io_bitmap_ptr = NULL;
/*
* Careful, clear this in the TSS too:
*/
memset(tss->io_bitmap, 0xff, tss->io_bitmap_max);
t->io_bitmap_max = 0;
tss->io_bitmap_owner = NULL;
tss->io_bitmap_max = 0;
tss->io_bitmap_base = INVALID_IO_BITMAP_OFFSET;
put_cpu();
#endif
}
}
next reply other threads:[~2005-06-14 0:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-14 1:16 cutaway [this message]
2005-06-14 3:08 ` Coywolf Qi Hunt
2005-06-14 4:26 ` cutaway
2005-06-14 7:43 ` Denis Vlasenko
2005-06-22 5:48 Chuck Ebbert
2005-06-22 8:41 ` cutaway
2005-07-02 2:57 Chuck Ebbert
2005-07-02 11:56 ` Denis Vlasenko
2005-07-03 19:59 ` cutaway
[not found] <200507012258_MC3-1-A340-3A81@compuserve.com.suse.lists.linux.kernel>
[not found] ` <200507021456.40667.vda@ilport.com.ua.suse.lists.linux.kernel>
2005-07-03 16:05 ` Andi Kleen
2005-07-05 18:30 William Cohen
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='000b01c5707e$c189c930$2800000a@pc365dualp2' \
--to=cutaway@bellsouth.net \
--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
all inboxes | Powered by JetHome®