From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Alexander van Heukelum <heukelum@mailshack.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
heukelum@fastmail.fm, Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
lguest@ozlabs.org, jeremy@xensource.com,
Steven Rostedt <srostedt@redhat.com>,
Mike Travis <travis@sgi.com>, Andi Kleen <andi@firstfloor.org>
Subject: Re: [PATCH RFC/RFB] x86_64, i386: interrupt dispatch changes
Date: Tue, 4 Nov 2008 18:07:29 +0300 [thread overview]
Message-ID: <20081104150729.GC21470@localhost> (raw)
In-Reply-To: <20081104122839.GA22864@mailshack.com>
[Alexander van Heukelum - Tue, Nov 04, 2008 at 01:28:39PM +0100]
| Hi all,
|
| An x86 processor handles an interrupt (from an external
| source, software generated or due to an exception),
| depending on the contents if the IDT. Normally the IDT
| contains mostly interrupt gates. Linux points each
| interrupt gate to a unique function. Some are specific
| to some task (handling traps, IPI's, ...), the others
| are stubs that push the interrupt number to the stack
| and jump to 'common_interrupt'.
|
| This patch removes the need for the stubs.
|
| An interrupt gate contains a FAR pointer to the interrupt
| handler, meaning that the code segment of the interrupt
| handler is also reloaded. Instead of pointing each (non-
| specific) interrupt gate to a unique handler, we set a
| unique code segment and use a common handler. When the
| handler finishes the code segment is restored to the
| 'normal'/previous one.
|
| In order to have a unique code segment for each interrupt
| vector, the GDT is extended to 512 entries (1 full page),
| and the last half of the page describes identical code
| segments (identical, except for the number in the cs
| register), which are refered to by the 256 interrupt
| gates.
|
| In this version, even the specialized handlers get run
| with their code segment switched. This is not necessary,
| but I like the fact that in a register dump one can now
| see from the code segment that the code is ran due to
| a (hard) interrupt. The exception I made is the int 0x80
| (syscall), which runs with the normal kernel code segment.
|
|
| Concluding: changing interrupt handling to this way
| removes quite a bit of source code. It also removes the
| need for the interrupt stubs and, on i386, pointers to
| them. This saves a few kilobytes of code. The page
| reserved for the GDT is now fully used. The cs register
| indicating directly that code is executed on behalf of
| a (hardware) interrupt is a nice debugging aid. This way
| of handling interrupts also leads to cleaner code: this
| patch already gets rid of some 'ugly' macro magic in
| entry_32.S and irqinit_64.c.
|
| More cleanup is certainly possible, but I have tried to
| keep the changes local and small. If switching code
| segments is too expensive for some paths, that can be
| fixed by not doing that ;).
|
| I'ld welcome some numbers on a few benchmarks on real
| hardware (I only tested on qemu: debian runs without
| noticable differences before/after this patch).
|
| Greetings,
| Alexander
|
| P.S. Just in case someone thinks this is a great idea and
| testing and benchmarking goes well...
|
...
Hi Alexander, great done!
not taking into account the cost of cs reading (which I
don't suspect to be that expensive apart from writting,
on the other hand I guess walking on GDT entries could
be not that cheap especially with new segments you propose,
I guess cpu internally check for segment to be the same
and do not reload it again even if it's described as FAR
pointer but I could be wrong so Andi CC'ed :)
A small nit in implementation:
entry_32.S:
+ push %eax
+ push %eax
+ mov %cs,%eax
+ shr $3,%eax
+ and $0xff,%eax
+ not %eax
+ mov %eax,4(%esp)
+ pop %eax
CFI_ADJUST_CFA_OFFSET missed?
- Cyrill -
next prev parent reply other threads:[~2008-11-04 15:07 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-04 12:28 [PATCH RFC/RFB] x86_64, i386: interrupt dispatch changes Alexander van Heukelum
2008-11-04 12:42 ` Ingo Molnar
2008-11-04 13:29 ` Alexander van Heukelum
2008-11-04 14:00 ` Ingo Molnar
2008-11-04 16:23 ` Alexander van Heukelum
2008-11-04 16:47 ` Cyrill Gorcunov
2008-11-04 16:58 ` Ingo Molnar
2008-11-04 17:13 ` Cyrill Gorcunov
2008-11-04 17:29 ` Alexander van Heukelum
2008-11-06 9:19 ` Ingo Molnar
2008-11-04 20:02 ` Jeremy Fitzhardinge
2008-11-04 20:15 ` H. Peter Anvin
2008-11-04 20:02 ` Jeremy Fitzhardinge
2008-11-04 15:07 ` Cyrill Gorcunov [this message]
2008-11-04 15:47 ` Alexander van Heukelum
2008-11-04 16:36 ` Ingo Molnar
2008-11-04 16:45 ` Alexander van Heukelum
2008-11-04 16:54 ` Ingo Molnar
2008-11-04 16:55 ` Ingo Molnar
2008-11-04 16:58 ` Alexander van Heukelum
2008-11-04 17:39 ` Alexander van Heukelum
2008-11-04 17:05 ` Andi Kleen
2008-11-04 18:06 ` Alexander van Heukelum
2008-11-04 18:14 ` H. Peter Anvin
2008-11-04 18:44 ` Alexander van Heukelum
2008-11-04 19:07 ` H. Peter Anvin
2008-11-04 19:33 ` H. Peter Anvin
2008-11-04 20:06 ` Jeremy Fitzhardinge
2008-11-04 20:30 ` Andi Kleen
2008-11-04 20:26 ` H. Peter Anvin
2008-11-04 20:46 ` Andi Kleen
2008-11-04 20:44 ` Ingo Molnar
2008-11-04 21:06 ` Andi Kleen
2008-11-05 0:42 ` Jeremy Fitzhardinge
2008-11-05 0:50 ` H. Peter Anvin
2008-11-06 9:15 ` Ingo Molnar
2008-11-06 9:25 ` H. Peter Anvin
2008-11-06 9:30 ` Ingo Molnar
2008-11-05 10:26 ` Ingo Molnar
2008-11-14 1:11 ` Nick Piggin
2008-11-14 1:20 ` H. Peter Anvin
2008-11-14 2:12 ` Nick Piggin
2008-11-04 21:29 ` Ingo Molnar
2008-11-04 21:35 ` H. Peter Anvin
2008-11-04 21:52 ` Ingo Molnar
2008-11-05 17:53 ` Cyrill Gorcunov
2008-11-05 18:04 ` H. Peter Anvin
2008-11-05 18:14 ` Cyrill Gorcunov
2008-11-05 18:20 ` H. Peter Anvin
2008-11-05 18:26 ` Cyrill Gorcunov
[not found] ` <1226243805.27361.1283784629@webmail.messagingengine.com>
2008-11-10 1:29 ` H. Peter Anvin
2008-11-26 21:35 ` [Lguest] " Avi Kivity
2008-11-26 21:50 ` Avi Kivity
2008-11-27 0:03 ` H. Peter Anvin
2008-11-27 10:13 ` Avi Kivity
2008-11-27 10:56 ` Andi Kleen
2008-11-27 10:59 ` Avi Kivity
2008-11-28 20:48 ` Alexander van Heukelum
2008-11-29 15:45 ` Alexander van Heukelum
2008-11-29 18:21 ` Avi Kivity
2008-11-29 18:22 ` Avi Kivity
2008-11-29 19:58 ` Ingo Molnar
2008-12-01 4:32 ` Rusty Russell
2008-12-01 8:00 ` Ingo Molnar
2008-12-01 9:24 ` Avi Kivity
2008-12-01 10:32 ` Cyrill Gorcunov
2008-12-01 10:41 ` Avi Kivity
2008-12-01 10:49 ` Ingo Molnar
2008-11-10 8:58 ` Ingo Molnar
2008-11-10 12:44 ` Alexander van Heukelum
2008-11-10 13:07 ` Ingo Molnar
2008-11-10 21:35 ` Alexander van Heukelum
2008-11-10 22:21 ` H. Peter Anvin
2008-11-11 5:00 ` H. Peter Anvin
2008-11-13 22:23 ` Matt Mackall
2008-11-14 1:18 ` H. Peter Anvin
2008-11-14 2:29 ` Matt Mackall
2008-11-14 3:22 ` H. Peter Anvin
2008-11-11 9:54 ` Ingo Molnar
2008-11-10 15:39 ` H. Peter Anvin
2008-11-10 21:44 ` Alexander van Heukelum
2008-11-10 23:34 ` H. Peter Anvin
2008-11-05 18:15 ` Cyrill Gorcunov
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=20081104150729.GC21470@localhost \
--to=gorcunov@gmail.com \
--cc=andi@firstfloor.org \
--cc=heukelum@fastmail.fm \
--cc=heukelum@mailshack.com \
--cc=hpa@zytor.com \
--cc=jeremy@xensource.com \
--cc=lguest@ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=srostedt@redhat.com \
--cc=tglx@linutronix.de \
--cc=travis@sgi.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