All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: Xen/ia64 presentation
@ 2005-04-27 17:25 Magenheimer, Dan (HP Labs Fort Collins)
  2005-04-27 19:12 ` Hollis Blanchard
  0 siblings, 1 reply; 18+ messages in thread
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2005-04-27 17:25 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Xen-devel

Hi Hollis --

I hope its OK that I respond to you in xen-devel.  I know you
posted a similar question before the Xen summit and I apologize
that the message got buried and I never replied.

> In general, why are you so determined to track Linux code? Although 
> Xen/x86 started that way, it has since diverged, and I think 
> that makes 
> a lot of sense. There is likely to be a ton of Linux code supporting 
> features that don't make sense in a hypervisor, right? That has 
> certainly been my experience working on the PowerPC hypervisor over a 
> few years...

Here's a few reasons (apologies for the free associating :-)...

It is true that there is a "ton" of Linux code supporting features
that don't make sense in a hypervisor.  But there is a "couple hundred
pounds of gold/platinum" Linux code that DOES virtually identical things
to a hypervisor -- at least that is the case for ia64.  Unlike
Linux/x86, much of the core archdep code for Linux/ia64 is still
changing relatively rapidly (bug fixes and performance improvements).
When Xen was originally derived from Linux (2.4.7-ish), Linux/ia64
was very immature.  I really had no choice other than to leverage
a much later version.  And there have been many useful changes in
Linux/ia64 between 2.6.4 (where I started Xen/ia64) and 2.6.11 (which
is currently being used for Xen/ia64).

A friend likes to say that "good programmers are lazy... VERY good
programmers are VERY lazy".  While I can claim only to be lazy (and
the converse of this aphorism may not be true anyway :-), I hate to
waste my time writing code that has already been written by someone
else better than I could have written it anyway.  Assembly coding on
ia64 is very complicated and error prone; code like kernel entry/exit
on Linux/ia64 is some of the most intricate and cryptic code you may
ever see.  I have the highest level of respect for people like David
Mosberger who wrote this code but, frankly, I don't want to try to
maintain a parallel version of it.

IBM's pHype and vHype were written as closed source (and pHype still
is).
Xen and Xen/ia64 were written with open source and GPL in mind and
so there was no problem with leveraging Linux code directly.  I'd
venture to guess that 40%-60% of the code in Xen/x86 is directly
taken or indirectly derived (e.g. minor syntactic changes) from Linux.
Ian argues that, although this might be true, the other 40-60% is
the core value of Xen.  Which exactly supports my point: why should
the Xen team waste time on developing/changing the "non-core" part of
Xen when it can be directly leveraged from Linux?

It's true that Xen is slowly diverging from the original Linux code.
You see this as a good thing.  I disagree.  There are few good examples
of highly portable systems code, but Linux is one of them.  Many
things look "a little weird" in Linux because the code supports
multiple architectures.  A good example is allocating a task struct
(see below).  I'd argue that one of the key factors for Linux's current
and future success is its ubiquity due its portability; and Xen would
do well to follow in its footsteps rather than diverge in ways that
will very likely make it less portable.

Maintaining close ties to Linux makes it much easier to "go back to
the well".  I remember that Xen 1.0 removed a lot of the early
"start of day" code for other (e.g. Cyrix) processors; when the
user community grew and some users wanted to run on other processors,
the Xen team went back and grabbed the code from Linux.  When the
ACPI tables needed to be more fully parsed, the Xen team grabbed
the ACPI code from Linux.  Recently, when I needed to add "user access"
capability to Xen/ia64, I grabbed the exception table code from
Linux/ia64 (and Linux common code); it basically just worked, in part
because Keir had grabbed the x86 equivalent code earlier.

And I expect this trend to continue and not slow down.  For example,
when I start SMP support, all the important places are marked in
Linux code by CONFIG_SMP.  When I want to implement hot plug memory/CPUs
or NUMA or jiffieless timer support, I'll know where to look.  Let's
face it: Linux has and will always have a larger community than Xen.
It just makes sense to me to leverage as much as we can from that
community as easily as we can.

Some may argue that this is all a good reason to put Xen and Linux
in the same source tree.  I'm not sure I would go that far.  But,
please, let's not kill the golden goose for what amounts to a little
convenience and aesthetics.

Whew... sorry to be so long-winded!

> You said SMP support is still on the TODO list, and sure enough 
> CONFIG_SMP is undefined in the unstable tree. But when I did that for 
> PowerPC, I found build breakage in common code. x86 doesn't 
> even build 
> without CONFIG_SMP. Does that work for you?

Yes it does work, although I remember I had to add an ugly hack or
two in asm-ia64/config.h to allow it to compile without CONFIG_SMP.
Personally I think Xen should compile and work properly with
CONFIG_SMP not specified, but once I found a workaround, I gave
up the battle.

> What do you mean by this statement regarding Xen/x86: "struct 
> exec_domain is a state vector (not a memory area)"?

Sorry this was cryptic... I did a poor job of condensing a
complicated topic to a single bullet.

On Linux/x86 and Xen/x86, a task_struct (called an exec_domain
in Xen but the concept is very similar) is just a C struct which
is used to save state.  On Linux/ia64 (and I think some other
architectures) and Xen/ia64, a task_struct is really a page of
memory.  It contains two stacks and state is sprinkled liberally
throughout.  Why?  Because ia64 has so many registers that lots
of optimizations are done to only save/restore registers "lazily"
so registers may be saved at seemingly random places in one
of the stacks.  (This is why kernel entry/exit code is so intricate.)

BTW this is a good example of the "portability" issue with
divergence of Xen from Linux.  Long ago, Keir looked at the code
for alloc_task_struct and decided: "Why bother making a function
call to something which just kmalloc's a struct?" and so he moved
it inline.  The reason became clear with Xen/ia64 and I got him
to change it "back".  But recently, when cleaning up the code,
he nearly removed the abstraction again.

> Unrelated to the presentation, I've noticed a large amount of 
> commented-out code and definitions in Xen/ia64 code, and 
> other oddities 
> like "typedef struct exec_domain VCPU". Are these artifacts of 
> borrowing code from other sources? Are you planning on doing some 
> cleanup in the future?

Yeah, there are some artifacts and some cleanup would be good.
The typedef predates exec_domain (used to be a typedef of
struct domain) and I used it because I knew that exec_domain
was coming.  Personally, I prefer VCPU (virtual CPU) to exec_domain.

Dan

> -----Original Message-----
> From: Hollis Blanchard [mailto:hollisb@us.ibm.com] 
> Sent: Wednesday, April 27, 2005 6:59 AM
> To: Magenheimer, Dan (HP Labs Fort Collins)
> Subject: Xen/ia64 presentation
> 
> Hi Dan, now that the Xen Summit PDFs are online, I just read through 
> your presentation on Xen/ia64. A few questions...
> 
> You said SMP support is still on the TODO list, and sure enough 
> CONFIG_SMP is undefined in the unstable tree. But when I did that for 
> PowerPC, I found build breakage in common code. x86 doesn't 
> even build 
> without CONFIG_SMP. Does that work for you?
> 
> What do you mean by this statement regarding Xen/x86: "struct 
> exec_domain is a state vector (not a memory area)"?
> 
> Unrelated to the presentation, I've noticed a large amount of 
> commented-out code and definitions in Xen/ia64 code, and 
> other oddities 
> like "typedef struct exec_domain VCPU". Are these artifacts of 
> borrowing code from other sources? Are you planning on doing some 
> cleanup in the future?
> 
> In general, why are you so determined to track Linux code? Although 
> Xen/x86 started that way, it has since diverged, and I think 
> that makes 
> a lot of sense. There is likely to be a ton of Linux code supporting 
> features that don't make sense in a hypervisor, right? That has 
> certainly been my experience working on the PowerPC hypervisor over a 
> few years...
> 
> -- 
> Hollis Blanchard
> IBM Linux Technology Center
> 
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: Re: Xen/ia64 presentation
@ 2005-04-27 21:47 Magenheimer, Dan (HP Labs Fort Collins)
  2005-04-27 22:34 ` Hollis Blanchard
  0 siblings, 1 reply; 18+ messages in thread
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2005-04-27 21:47 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: Xen-devel

As you may have noticed, Xen/ia64 completely ignores
all of the execution context structs because (as
described in the base for this thread), ia64 can't
represent its state that way.

In fact if you grep for these (as well as xen_regs)
in common files, there are very few uses of them.
And I'd argue that the uses that ARE still in common
(e.g. keyhandler.c, serial/console drivers, dom0_ops)
are places that haven't yet been properly divided between
archdep and common (because Xen/ia64 hacks around them
rather than use them).  Either that or the datatype
is entirely opaque to the routine and is just being
passed along to another (archdep) routine.

In other words, I'm suggesting that perhaps all of
these constructs are archdep and (eventually) shouldn't
appear in common code.

Dan

> -----Original Message-----
> From: Hollis Blanchard [mailto:hollisb@us.ibm.com] 
> Sent: Wednesday, April 27, 2005 2:09 PM
> To: Keir Fraser
> Cc: Xen-devel; Magenheimer, Dan (HP Labs Fort Collins)
> Subject: Re: [Xen-devel] Re: Xen/ia64 presentation
> 
> Keir Fraser wrote:
> > 
> > On 27 Apr 2005, at 20:31, Hollis Blanchard wrote:
> >>
> >> On this subject, I'd also like to ask about 
> full_execution_context_t.
> >> execution_context_t is used in a fair number of places in 
> the Xen core;
> >> however full_execution_context_t seems to only be used in the dom0
> >> interface.
> >>
> >> The in-Xen analog to full_execution_context_t is 
> arch_exec_domain, with
> >> many fields duplicated between the two. Could we 
> consolidate these, or
> >> at least give full_execution_context_t a name that better 
> describes its
> >> purpose?
> > 
> > Yes, that's another one that's gross. Maybe rename
> > full_execution_context_t to execution_context_t, and rename existing
> > execution_context_t to something else (cpu_reg_t, or 
> something like that)?
> 
> execution_context_t is also struct xen_regs, so if we like 
> typedefs then
> xen_regs_t would be consistent. Right now, lots of code uses xen_regs
> and lots uses execution_context_t... should that be made consistent?
> 
> xen_regs/execution_context_t seems to mean "state which xen code could
> alter", so something to distinguish it from "all CPU state" would be
> nice. Maybe something like this:
> 
> struct xen_state:  (now xen_regs) state which xen C/asm code 
> could alter
> struct vcpu_state: (now exec_domain) all virtual CPU state
> struct arch_vcpu_state
> 
> ("vcpu_regs" might not be good, since we could need to save other
> context like software-controlled TLBs, and so "xen_state" would match
> "vcpu_state".)
> 
> I guess you want to keep a separate virtual CPU struct for the dom0
> interface to preserve the ABI? Calling that 
> "execution_context_t" could
> work; I don't know what else to call it.
> 
> -- 
> Hollis Blanchard
> IBM Linux Technology Center
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: RE: Xen/ia64 presentation
@ 2005-04-28 14:53 Dong, Eddie
  0 siblings, 0 replies; 18+ messages in thread
From: Dong, Eddie @ 2005-04-28 14:53 UTC (permalink / raw)
  To: Magenheimer, Dan (HP Labs Fort Collins), Hollis Blanchard; +Cc: Xen-devel

Magenheimer, Dan (HP Labs Fort Collins) wrote:
> Maintaining close ties to Linux makes it much easier to "go back to
> the well".  I remember that Xen 1.0 removed a lot of the early
> "start of day" code for other (e.g. Cyrix) processors; when the
> user community grew and some users wanted to run on other processors,
> the Xen team went back and grabbed the code from Linux.  When the
> ACPI tables needed to be more fully parsed, the Xen team grabbed
> the ACPI code from Linux.  Recently, when I needed to add "user
> access" capability to Xen/ia64, I grabbed the exception table code
> from Linux/ia64 (and Linux common code); it basically just worked, in
> part because Keir had grabbed the x86 equivalent code earlier.
> 
Hi, Dan:
	"user access"  capability probably is not a right example. I
think you are talking about the mechanism to support Hypercall parameter
passing that you call it as poorman's exception handler mechanism. As we
discussed before, this mechanism will trigger guest tlb fault when the
TC map carrying guest hypercall information went away. This cause
following critical problem:
	1: When this hypercall is invoked in guest vpsr.ic=0, it will
trigger nested tlb miss which the guest can never handle.
	2: If the hypercall is invoked in guest tlb miss handler,
injecting guest tlb miss may cause endless (recursive) guest tlb miss->
hypercall -> guest tlb miss...

	The possible solution to this issue is to use either guest TR
map or guest special map (always reside in guest TLB) for the area
carrying hypercall information so that the map for this area will never
go away and thus the special "user access" mechanism that linux uses is
not necessary again. (In linux sitiuation, the user application never
run in vspr.ic=0 nor tlb miss handler)
Thanks,eddie

^ permalink raw reply	[flat|nested] 18+ messages in thread
* RE: Re: Xen/ia64 presentation
@ 2005-04-28 19:05 Magenheimer, Dan (HP Labs Fort Collins)
  0 siblings, 0 replies; 18+ messages in thread
From: Magenheimer, Dan (HP Labs Fort Collins) @ 2005-04-28 19:05 UTC (permalink / raw)
  To: Keir Fraser, Hollis Blanchard; +Cc: Xen-devel

> The '_state' seems a bit superfluous. How about just 'struct vcpu'?

Or perhaps just vcpu_t, and let the arch provide the typedef?
 
> explicitly to the handler then it is very hard to reliably 
> recalculate 
> it if it is needed, and it is useful for debugging purposes 
> at the very 
> least.
> 
> A 'cpu_user_regs' seems like something every arch can provide, right?

On ia64, the state is pretty scattered about but all of it can
be found (at least non-performantly) from a pt_regs or a vcpu
so either one works for me as long as I can typedef/define it
(e.g. cpu_user_regs -> pt_regs).

Dan

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2005-04-28 20:11 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-27 17:25 Xen/ia64 presentation Magenheimer, Dan (HP Labs Fort Collins)
2005-04-27 19:12 ` Hollis Blanchard
2005-04-27 19:24   ` Keir Fraser
2005-04-27 19:31     ` Hollis Blanchard
2005-04-27 19:34       ` Keir Fraser
2005-04-27 20:08         ` Hollis Blanchard
2005-04-28  8:32           ` Keir Fraser
2005-04-28  8:54             ` Keir Fraser
2005-04-28 18:10             ` Hollis Blanchard
2005-04-28 18:38               ` Keir Fraser
2005-04-28 18:58                 ` Hollis Blanchard
2005-04-28 19:47                   ` Keir Fraser
2005-04-28 20:11                     ` Hollis Blanchard
2005-04-27 19:31   ` Keir Fraser
  -- strict thread matches above, loose matches on Subject: below --
2005-04-27 21:47 Magenheimer, Dan (HP Labs Fort Collins)
2005-04-27 22:34 ` Hollis Blanchard
2005-04-28 14:53 Dong, Eddie
2005-04-28 19:05 Magenheimer, Dan (HP Labs Fort Collins)

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.