[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xen-users
Subject:    Re: [Xen-users] whether xen scheduler supports preemption
From:       <zhangwqh () 126 ! com>
Date:       2013-06-30 15:00:48
Message-ID: 63677370.c228.13f9599c076.Coremail.zhangwqh () 126 ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]

[Attachment #4 (text/plain)]


Thank you very much for your guidance!

At 2013-06-27 18:30:05,"Dario Faggioli" <dario.faggioli@citrix.com> wrote:
> So, first of all... Can you use plain text instead of HTML for e-mails?
> 
> On mer, 2013-06-26 at 21:16 +0800, ÕÅΰ wrote:
> > Thank you very much for your detail explanation! See below.
> > 
> You're welcome. Although, at this point, I'm curious about why you're
> interested in this... What is it that you want to achieve?
At first, I have a wrong understanding for xen scheduler preemption. I thought it did \
not support preemption. Last week, my advisor  corrects my thought. So I want to know \
if a system supports preemption, the code which key part need to do the modification. \
At first, I add something in xen scheduler(only simple). My modification will bring \
some virtual machines starvation. Now I want to decrease the starvation. I need to \
add some other things. I meet a serious problem, in the schedule() or \
csched_schedule() function, if access the variable csched_dom structure, the system \
will automatically reboot. Eg, if add  the printk("The domain weight is %d", \
sdom->weight); in the csched_schedule() or schedule(), the system will automatically \
reboot and can not enter the system. Do you know why? It is very strange. In these \
two functions, I can successfully access the variable of csched_vcpu structure and \
csched_private.
> 
> > > ... Yes, that is at least most of it. In fact, when a vcpu wakes up, it
> > > is added to a specific runq, and the 'tickling' mechanism is there right
> > > to ensure that the said vcpu starts to run as soon as possible, either
> > > if there are idle pcpus, or the running vcpus have lower priority, the
> > > latter case being the definition of preemption.
> > When a vcpu wakes up, it is added to a specific runq. Whether the specific runq \
> > is the runnable queue? 
> Well, the vcpu wakes-up, so yes, it is the runnable queue of a specific
> pCPU. Which 'specific pCPU' depends, and I suggest you looking more
> deeply in the scheduler code. From the top of my head, I'd say it is the
> runqueue of the pCPU where the vCPU was when it went to sleep.
> 
> > either if there are idle pcpus, or the running vcpus have lower priority?
> > 
> In credit1, it works like this:
> - you (the vCPU) wake-up and I (Xen scheduler) queue you on the runq
> of the pCPU when you where before going to sleep;
> - if that pCPU is busy, I poke other pCPUs to see if you can run there
> (that's the meaning of 'tickling');
> - if the above is not possible, I check if preemption is required. If
> yes, I preempt the vCPU running on the runq, if not, you have to wait
> for your turn (or for some other pCPU becoming idle and picking you
> up) in the runq.
> 
> Does that make sense?
> 
Yes, now it make sense. Thank you very much for trying to let me understand what you \
said. 

> > I do not understand your meaning. You mean that if there are idle pcpus, the \
> > waked up vcpu will be scheduled on the idle pcpus to run.  
> For sure, the scheduler will try as hard as he can to achieve this, yes.
> 
> > If not, it will preempted the current running vcpus if the waked up vcpu has the \
> > higher priority compared to the the current vcpu. Whether my understanding is \
> > right? 
> I believe it is. Actually, I believe this is either the definition or,
> in any case, the only sensible thing that a reasonable enough
> preemptible scheduler should do. :-)
> 
> For the deep technicalities of how this is implemented in credit1,
> please refer to my hopefully accurate explanation above, or, even
> better, to sched_credit.c.
> 
> > > If you, for instance, avoid raising the SCHEDULE_SOFTIRQ for busy
> > > pcpus
> > > (I would still tickle the idle ones, or you'll get funny results! :-O),
> > > you definitely are making the (credit) scheduler less preemptible.
> > I can not understand here. still tickle the idle ones, or you'll get funny \
> > results! What's the meaning? 
> The meaning is that, given the explanation above, inhibiting preemption
> by, for instance, not tickling the busy pCPUs might actually work. On
> the other hand, if you have idle pCPUs, having them running the woken-up
> task is not a preemption, right? Well, if you do not tickle those pCPUs
> you won't get there, and you not only will get rid of peemption on busy
> pCPUs, you will also have idle pCPUs that remains idle, even if there
> are vCPUs waiting to be executed.
> 
> This means you're killing not only preemption, but also work
> conserving-ness, and that might not be among your original goals (or was
> it?).
> 
> > > Of course, wake-ups is not the only cause of SCHEDULE_SOFTIRQ being
> > > raised. E.g., it fires periodically at the scheduling time slice
> > > boundaries. If you want to avoid vcpus being interrupted by others with
> > > higher priority for this case too, you probably have more paths to tweak
> > > than just the csched_vcpu_wake() function.
> > > 
> > Yes, I can not remember the number of raising SCHEDULE_SOFTIRQ interrupt. Long \
> > time ago, I check the places of raising SCHEDULE_SOFTIRQ interrupt. It is about \
> > seven places. 
> Fine. Then, to be sure, I'd check all of them and see what they end up
> doing. I know they're all calling csched_schedule(), what I mean is I'd
> check the conditions and the parameters, to verify which ones of these 7
> possible situations could lead to preemption.
> 
> What you can be quite sure of, is ha there's not going to be a
> preemption without a call to csched_schedule() being involved, so you
> may even try to instrument the code at that level.. It really all
> depends on your final purpose.
> 
> > > And here I'm failing at understanding what you mean again... When a
> > > SCHEDULE_SOFTIRQ is raised for a given pcpu, that pcpu will deal with
> > > it, well, ASAP (look at how softirqs & tasklets work in the hypervisor
> > > source code). What do you mean by "give up the physical cpu"?
> > I mean after raising the SCHEDULE_SOFTIRQ interrupt, the handler function \
> > schedule() will execute in time or need to wait the current vcpu scheduled out. \
> > Which part decides the priority among them?  
> Mmm... I spot some confusion here. Why the scheduling out of a vcpu
> should be involved in all this? I mean, raising a SCHEDULE_SOFTIRQ and,
> most important, handling it, happens in Xen code. That means there is a
> pCPU executing hypervisor code, independently of which one is the vCPU
> that is or was running on that same pCPU. Well, this same hypervisor
> code will get to execute, at some point, csched_schedule(), make the
> scheduling decision and, if that is the case, dschedule the running vCPU
> and schedule another one (and here you are a preemption).
> 
> Actually, we really can't wait for a vCPU to be descheduled to execute
> the Xen scheduler, since it's the Xen scheduler itself that deschedules
> vCPUs! :-O
> 
> Perhaps, with "scheduled out" you mean something like block, i.e., you
> want to know if Xen is able to interrupt the vCPUs or if it always run
> them to completion or blocking. In which case, the former, we interrupt
> the vCPUs, just like an (preemptible) OS scheduler interrupts OS's
> tasks. Whether or not that will result in a preemption, it depends both
> on the scheduler and on the circumstances.
> 
> Sounds better now?
> 
> > Can you give me some guidance, where is the code for  softirqs & tasklets.
> > 
> Well, grep and find are usually good friends, when the question is where
> is the code! :-P
> 
> Both
> 
> $ grep tasklet xen.git/xen/*
> 
> and
> 
> $ grep softirq xen.git/xen/*
> 
> Produce a lot of output here. Also, I'd try something like that... You
> know, programmers usually have quite few fantasy
> 
> $ find ./xen.git/xen/ -iname tasklet*
> ./xen/include/xen/tasklet.h
> ./xen/common/tasklet.c
> 
> $ find ./xen.git/xen/ -iname softirq*
> ./xen/include/asm-x86/softirq.h
> ./xen/include/xen/softirq.h
> ./xen/include/asm-arm/softirq.h
> ./xen/common/softirq.c
> 
> > Another question:
> > In the schedule() function of schedule.c file, at first, it will set the flag \
> > tasklet_work_scheduled according to whether has the tasklet_work. What is the \
> > tasklet work? 
> After having inspected at least some of the sources above, look for the
> do_tasklet() function, and revise what it does. If it's the concept of
> tasklet and softirq that you're unfamiliar with, well, very quickly it's
> just one way of deferring work in an OS (or, in out case, an hypervisor,
> but still).
> 
> Linux makes uses of these kind of things pretty heavily (although the
> names, the implementation, and the number of different variants of them
> changes with kernel versions). I trust/hope you can find enough
> documentation about that on line. :-)
> 
> > In the csched_schedule() of  sched_credit.c file, it will give the idle vcpu \
> > boost priority if the tasklet_work_scheduled is set.  I have some difficult for \
> > understanding this part. Maybe my confusion is not knowing the tasklet work. Can \
> > you give some explanation why designing like this? 
> Again, tasklet is deferred work. That means there is this pretty
> function you want to call, but you can call it right now. Typical
> example is because you have interrupt disabled and the pretty function
> in question wants interrupt enabled, or it is you that you don't want to
> keep interrupts disabled for too long, or any other reason.
> 
> Ok, what you do is to make a note about calling that function later, and
> that's exactly what tasklet does. The reason why we execute them in idle
> domain's context is, well, because we have to execute them
> somewhere!  :-)
> 
> Seriously, our scheduler schedules vCPUs, not 'functions', so you either
> call a function from where you are (and we already said you can't) or,
> when you're done, the scheduler will pick a vCPU and get on with it, and
> your function will never be called. What we hence do is making sure it
> is one of the idle domain's vCPUs that is scheduled, as well as making
> sure that such vCPU will call your function as part of 'its workload'.
> 
> Check out the idle_loop() function, it's in xen/arch/x86/domain.c.
Thank you very much once again for your detail description!

> 
> Regards,
> Dario
> 
> 


[Attachment #5 (text/html)]

<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><br><span \
style="color: rgb(255, 0, 0);">Thank you very much for your \
guidance!</span><br><pre>At&nbsp;2013-06-27&nbsp;18:30:05,"Dario&nbsp;Faggioli"&nbsp;&lt;dario.faggioli@citrix.com&gt;&nbsp;wrote:
 &gt;So,&nbsp;first&nbsp;of&nbsp;all...&nbsp;Can&nbsp;you&nbsp;use&nbsp;plain&nbsp;text&nbsp;instead&nbsp;of&nbsp;HTML&nbsp;for&nbsp;e-mails?
 &gt;
&gt;On&nbsp;mer,&nbsp;2013-06-26&nbsp;at&nbsp;21:16&nbsp;+0800,&nbsp;ÕÅΰ&nbsp;wrote:
&gt;&gt;&nbsp;Thank&nbsp;you&nbsp;very&nbsp;much&nbsp;for&nbsp;your&nbsp;detail&nbsp;explanation!&nbsp;See&nbsp;below.
 &gt;&gt;
&gt;You're&nbsp;welcome.&nbsp;Although,&nbsp;at&nbsp;this&nbsp;point,&nbsp;I'm&nbsp;curious&nbsp;about&nbsp;why&nbsp;you're
 &gt;interested&nbsp;in&nbsp;this...&nbsp;What&nbsp;is&nbsp;it&nbsp;that&nbsp;you&nbsp;want&nbsp;to&nbsp;achieve?</pre><pre \
style="color: rgb(255, 0, 0);">At first, I have a wrong understanding for xen \
scheduler preemption. I thought it did not support preemption. Last week, my advisor  \
corrects my thought. So I want to know if a system supports preemption, the code \
which key part need to do the modification. At first, I add something in xen \
scheduler(only simple). My modification will bring some virtual machines starvation. \
Now I want to decrease the starvation. I need to add some other things. I meet a \
serious problem, in the schedule() or csched_schedule() function, if access the \
variable csched_dom structure, the system will automatically reboot. Eg, if add  the \
printk("The domain weight is %d", sdom-&gt;weight); in the csched_schedule() or \
schedule(), the system will automatically reboot and can not enter the system. Do you \
know why? It is very strange. In these two functions, I can successfully access the \
variable of csched_vcpu structure and csched_private.</pre><pre>&gt; \
&gt;&gt;&nbsp;&gt;...&nbsp;Yes,&nbsp;that&nbsp;is&nbsp;at&nbsp;least&nbsp;most&nbsp;of \
&nbsp;it.&nbsp;In&nbsp;fact,&nbsp;when&nbsp;a&nbsp;vcpu&nbsp;wakes&nbsp;up,&nbsp;it \
&gt;&gt;&nbsp;&gt;is&nbsp;added&nbsp;to&nbsp;a&nbsp;specific&nbsp;runq,&nbsp;and&nbsp;the&nbsp;'tickling'&nbsp;mechanism&nbsp;is&nbsp;there&nbsp;right
 &gt;&gt;&nbsp;&gt;to&nbsp;ensure&nbsp;that&nbsp;the&nbsp;said&nbsp;vcpu&nbsp;starts&nbsp;to&nbsp;run&nbsp;as&nbsp;soon&nbsp;as&nbsp;possible,&nbsp;either
 &gt;&gt;&nbsp;&gt;if&nbsp;there&nbsp;are&nbsp;idle&nbsp;pcpus,&nbsp;or&nbsp;the&nbsp;running&nbsp;vcpus&nbsp;have&nbsp;lower&nbsp;priority,&nbsp;the
 &gt;&gt;&nbsp;&gt;latter&nbsp;case&nbsp;being&nbsp;the&nbsp;definition&nbsp;of&nbsp;preemption.
 &gt;&gt;&nbsp;When&nbsp;a&nbsp;vcpu&nbsp;wakes&nbsp;up,&nbsp;it&nbsp;is&nbsp;added&nb \
sp;to&nbsp;a&nbsp;specific&nbsp;runq.&nbsp;Whether&nbsp;the&nbsp;specific&nbsp;runq&nbsp;is&nbsp;the&nbsp;runnable&nbsp;queue?
 &gt;&gt;
&gt;Well,&nbsp;the&nbsp;vcpu&nbsp;wakes-up,&nbsp;so&nbsp;yes,&nbsp;it&nbsp;is&nbsp;the&nbsp;runnable&nbsp;queue&nbsp;of&nbsp;a&nbsp;specific
 &gt;pCPU.&nbsp;Which&nbsp;'specific&nbsp;pCPU'&nbsp;depends,&nbsp;and&nbsp;I&nbsp;suggest&nbsp;you&nbsp;looking&nbsp;more
 &gt;deeply&nbsp;in&nbsp;the&nbsp;scheduler&nbsp;code.&nbsp;From&nbsp;the&nbsp;top&nbsp;of&nbsp;my&nbsp;head,&nbsp;I'd&nbsp;say&nbsp;it&nbsp;is&nbsp;the
 &gt;runqueue&nbsp;of&nbsp;the&nbsp;pCPU&nbsp;where&nbsp;the&nbsp;vCPU&nbsp;was&nbsp;when&nbsp;it&nbsp;went&nbsp;to&nbsp;sleep.
 &gt;
&gt;&gt;&nbsp;either&nbsp;if&nbsp;there&nbsp;are&nbsp;idle&nbsp;pcpus,&nbsp;or&nbsp;the&nbsp;running&nbsp;vcpus&nbsp;have&nbsp;lower&nbsp;priority?
 &gt;&gt;
&gt;In&nbsp;credit1,&nbsp;it&nbsp;works&nbsp;like&nbsp;this:
&gt;&nbsp;-&nbsp;you&nbsp;(the&nbsp;vCPU)&nbsp;wake-up&nbsp;and&nbsp;I&nbsp;(Xen&nbsp;scheduler)&nbsp;queue&nbsp;you&nbsp;on&nbsp;the&nbsp;runq
 &gt;&nbsp;&nbsp;&nbsp;of&nbsp;the&nbsp;pCPU&nbsp;when&nbsp;you&nbsp;where&nbsp;before&nbsp;going&nbsp;to&nbsp;sleep;
 &gt;&nbsp;-&nbsp;if&nbsp;that&nbsp;pCPU&nbsp;is&nbsp;busy,&nbsp;I&nbsp;poke&nbsp;other&nbsp;pCPUs&nbsp;to&nbsp;see&nbsp;if&nbsp;you&nbsp;can&nbsp;run&nbsp;there
 &gt;&nbsp;&nbsp;&nbsp;(that's&nbsp;the&nbsp;meaning&nbsp;of&nbsp;'tickling');
&gt;&nbsp;-&nbsp;if&nbsp;the&nbsp;above&nbsp;is&nbsp;not&nbsp;possible,&nbsp;I&nbsp;check&nbsp;if&nbsp;preemption&nbsp;is&nbsp;required.&nbsp;If
 &gt;&nbsp;&nbsp;&nbsp;yes,&nbsp;I&nbsp;preempt&nbsp;the&nbsp;vCPU&nbsp;running&nbsp;on&nbsp;the&nbsp;runq,&nbsp;if&nbsp;not,&nbsp;you&nbsp;have&nbsp;to&nbsp;wait
 &gt;&nbsp;&nbsp;&nbsp;for&nbsp;your&nbsp;turn&nbsp;(or&nbsp;for&nbsp;some&nbsp;other&nbsp;pCPU&nbsp;becoming&nbsp;idle&nbsp;and&nbsp;picking&nbsp;you
 &gt;&nbsp;&nbsp;&nbsp;up)&nbsp;in&nbsp;the&nbsp;runq.
&gt;
&gt;Does&nbsp;that&nbsp;make&nbsp;sense?
&gt;</pre><pre style="color: rgb(255, 0, 0);">Yes, now it make sense. Thank you very \
much for trying to let me understand what you said. </pre><pre> \
&gt;&gt;&nbsp;I&nbsp;do&nbsp;not&nbsp;understand&nbsp;your&nbsp;meaning.&nbsp;You&nbsp \
;mean&nbsp;that&nbsp;if&nbsp;there&nbsp;are&nbsp;idle&nbsp;pcpus,&nbsp;the&nbsp;waked& \
nbsp;up&nbsp;vcpu&nbsp;will&nbsp;be&nbsp;scheduled&nbsp;on&nbsp;the&nbsp;idle&nbsp;pcpus&nbsp;to&nbsp;run.&nbsp;
 &gt;&gt;
&gt;For&nbsp;sure,&nbsp;the&nbsp;scheduler&nbsp;will&nbsp;try&nbsp;as&nbsp;hard&nbsp;as&nbsp;he&nbsp;can&nbsp;to&nbsp;achieve&nbsp;this,&nbsp;yes.
 &gt;
&gt;&gt;&nbsp;If&nbsp;not,&nbsp;it&nbsp;will&nbsp;preempted&nbsp;the&nbsp;current&nbsp \
;running&nbsp;vcpus&nbsp;if&nbsp;the&nbsp;waked&nbsp;up&nbsp;vcpu&nbsp;has&nbsp;the&nb \
sp;higher&nbsp;priority&nbsp;compared&nbsp;to&nbsp;the&nbsp;the&nbsp;current&nbsp;vcpu.&nbsp;Whether&nbsp;my&nbsp;understanding&nbsp;is&nbsp;right?
 &gt;&gt;
&gt;I&nbsp;believe&nbsp;it&nbsp;is.&nbsp;Actually,&nbsp;I&nbsp;believe&nbsp;this&nbsp;is&nbsp;either&nbsp;the&nbsp;definition&nbsp;or,
 &gt;in&nbsp;any&nbsp;case,&nbsp;the&nbsp;only&nbsp;sensible&nbsp;thing&nbsp;that&nbsp;a&nbsp;reasonable&nbsp;enough
 &gt;preemptible&nbsp;scheduler&nbsp;should&nbsp;do.&nbsp;:-)
&gt;
&gt;For&nbsp;the&nbsp;deep&nbsp;technicalities&nbsp;of&nbsp;how&nbsp;this&nbsp;is&nbsp;implemented&nbsp;in&nbsp;credit1,
 &gt;please&nbsp;refer&nbsp;to&nbsp;my&nbsp;hopefully&nbsp;accurate&nbsp;explanation&nbsp;above,&nbsp;or,&nbsp;even
 &gt;better,&nbsp;to&nbsp;sched_credit.c.
&gt;
&gt;&gt;&nbsp;&gt;&nbsp;If&nbsp;you,&nbsp;for&nbsp;instance,&nbsp;avoid&nbsp;raising&nbsp;the&nbsp;SCHEDULE_SOFTIRQ&nbsp;for&nbsp;busy
 &gt;&gt;&nbsp;&gt;&nbsp;pcpus
&gt;&gt;&nbsp;&gt;&nbsp;(I&nbsp;would&nbsp;still&nbsp;tickle&nbsp;the&nbsp;idle&nbsp;ones,&nbsp;or&nbsp;you'll&nbsp;get&nbsp;funny&nbsp;results!&nbsp;:-O),
 &gt;&gt;&nbsp;&gt;&nbsp;you&nbsp;definitely&nbsp;are&nbsp;making&nbsp;the&nbsp;(credit)&nbsp;scheduler&nbsp;less&nbsp;preemptible.
 &gt;&gt;&nbsp;I&nbsp;can&nbsp;not&nbsp;understand&nbsp;here.&nbsp;still&nbsp;tickle&n \
bsp;the&nbsp;idle&nbsp;ones,&nbsp;or&nbsp;you'll&nbsp;get&nbsp;funny&nbsp;results!&nbsp;What's&nbsp;the&nbsp;meaning?
 &gt;&gt;
&gt;The&nbsp;meaning&nbsp;is&nbsp;that,&nbsp;given&nbsp;the&nbsp;explanation&nbsp;above,&nbsp;inhibiting&nbsp;preemption
 &gt;by,&nbsp;for&nbsp;instance,&nbsp;not&nbsp;tickling&nbsp;the&nbsp;busy&nbsp;pCPUs&nbsp;might&nbsp;actually&nbsp;work.&nbsp;On
 &gt;the&nbsp;other&nbsp;hand,&nbsp;if&nbsp;you&nbsp;have&nbsp;idle&nbsp;pCPUs,&nbsp;having&nbsp;them&nbsp;running&nbsp;the&nbsp;woken-up
 &gt;task&nbsp;is&nbsp;not&nbsp;a&nbsp;preemption,&nbsp;right?&nbsp;Well,&nbsp;if&nbsp;you&nbsp;do&nbsp;not&nbsp;tickle&nbsp;those&nbsp;pCPUs
 &gt;you&nbsp;won't&nbsp;get&nbsp;there,&nbsp;and&nbsp;you&nbsp;not&nbsp;only&nbsp;will&nbsp;get&nbsp;rid&nbsp;of&nbsp;peemption&nbsp;on&nbsp;busy
 &gt;pCPUs,&nbsp;you&nbsp;will&nbsp;also&nbsp;have&nbsp;idle&nbsp;pCPUs&nbsp;that&nbsp;remains&nbsp;idle,&nbsp;even&nbsp;if&nbsp;there
 &gt;are&nbsp;vCPUs&nbsp;waiting&nbsp;to&nbsp;be&nbsp;executed.
&gt;
&gt;This&nbsp;means&nbsp;you're&nbsp;killing&nbsp;not&nbsp;only&nbsp;preemption,&nbsp;but&nbsp;also&nbsp;work
 &gt;conserving-ness,&nbsp;and&nbsp;that&nbsp;might&nbsp;not&nbsp;be&nbsp;among&nbsp;your&nbsp;original&nbsp;goals&nbsp;(or&nbsp;was
 &gt;it?).
&gt;
&gt;&gt;&nbsp;&gt;Of&nbsp;course,&nbsp;wake-ups&nbsp;is&nbsp;not&nbsp;the&nbsp;only&nbsp;cause&nbsp;of&nbsp;SCHEDULE_SOFTIRQ&nbsp;being
 &gt;&gt;&nbsp;&gt;raised.&nbsp;E.g.,&nbsp;it&nbsp;fires&nbsp;periodically&nbsp;at&nbsp;the&nbsp;scheduling&nbsp;time&nbsp;slice
 &gt;&gt;&nbsp;&gt;boundaries.&nbsp;If&nbsp;you&nbsp;want&nbsp;to&nbsp;avoid&nbsp;vcpus&nbsp;being&nbsp;interrupted&nbsp;by&nbsp;others&nbsp;with
 &gt;&gt;&nbsp;&gt;higher&nbsp;priority&nbsp;for&nbsp;this&nbsp;case&nbsp;too,&nbsp;you&nbsp;probably&nbsp;have&nbsp;more&nbsp;paths&nbsp;to&nbsp;tweak
 &gt;&gt;&nbsp;&gt;than&nbsp;just&nbsp;the&nbsp;csched_vcpu_wake()&nbsp;function.
&gt;&gt;&nbsp;&gt;
&gt;&gt;&nbsp;Yes,&nbsp;I&nbsp;can&nbsp;not&nbsp;remember&nbsp;the&nbsp;number&nbsp;of \
&nbsp;raising&nbsp;SCHEDULE_SOFTIRQ&nbsp;interrupt.&nbsp;Long&nbsp;time&nbsp;ago,&nbsp \
;I&nbsp;check&nbsp;the&nbsp;places&nbsp;of&nbsp;raising&nbsp;SCHEDULE_SOFTIRQ&nbsp;interrupt.&nbsp;It&nbsp;is&nbsp;about&nbsp;seven&nbsp;places.
 &gt;&gt;&nbsp;
&gt;Fine.&nbsp;Then,&nbsp;to&nbsp;be&nbsp;sure,&nbsp;I'd&nbsp;check&nbsp;all&nbsp;of&nbsp;them&nbsp;and&nbsp;see&nbsp;what&nbsp;they&nbsp;end&nbsp;up
 &gt;doing.&nbsp;I&nbsp;know&nbsp;they're&nbsp;all&nbsp;calling&nbsp;csched_schedule(),&nbsp;what&nbsp;I&nbsp;mean&nbsp;is&nbsp;I'd
 &gt;check&nbsp;the&nbsp;conditions&nbsp;and&nbsp;the&nbsp;parameters,&nbsp;to&nbsp;verify&nbsp;which&nbsp;ones&nbsp;of&nbsp;these&nbsp;7
 &gt;possible&nbsp;situations&nbsp;could&nbsp;lead&nbsp;to&nbsp;preemption.
&gt;
&gt;What&nbsp;you&nbsp;can&nbsp;be&nbsp;quite&nbsp;sure&nbsp;of,&nbsp;is&nbsp;ha&nbsp;there's&nbsp;not&nbsp;going&nbsp;to&nbsp;be&nbsp;a
 &gt;preemption&nbsp;without&nbsp;a&nbsp;call&nbsp;to&nbsp;csched_schedule()&nbsp;being&nbsp;involved,&nbsp;so&nbsp;you
 &gt;may&nbsp;even&nbsp;try&nbsp;to&nbsp;instrument&nbsp;the&nbsp;code&nbsp;at&nbsp;that&nbsp;level..&nbsp;It&nbsp;really&nbsp;all
 &gt;depends&nbsp;on&nbsp;your&nbsp;final&nbsp;purpose.
&gt;
&gt;&gt;&nbsp;&gt;And&nbsp;here&nbsp;I'm&nbsp;failing&nbsp;at&nbsp;understanding&nbsp;what&nbsp;you&nbsp;mean&nbsp;again...&nbsp;When&nbsp;a
 &gt;&gt;&nbsp;&gt;SCHEDULE_SOFTIRQ&nbsp;is&nbsp;raised&nbsp;for&nbsp;a&nbsp;given&nbsp;pcpu,&nbsp;that&nbsp;pcpu&nbsp;will&nbsp;deal&nbsp;with
 &gt;&gt;&nbsp;&gt;it,&nbsp;well,&nbsp;ASAP&nbsp;(look&nbsp;at&nbsp;how&nbsp;softirqs&nbsp;&amp;&nbsp;tasklets&nbsp;work&nbsp;in&nbsp;the&nbsp;hypervisor
 &gt;&gt;&nbsp;&gt;source&nbsp;code).&nbsp;What&nbsp;do&nbsp;you&nbsp;mean&nbsp;by&nbsp;"give&nbsp;up&nbsp;the&nbsp;physical&nbsp;cpu"?
 &gt;&gt;&nbsp;I&nbsp;mean&nbsp;after&nbsp;raising&nbsp;the&nbsp;SCHEDULE_SOFTIRQ&nbsp \
;interrupt,&nbsp;the&nbsp;handler&nbsp;function&nbsp;schedule()&nbsp;will&nbsp;execute \
&nbsp;in&nbsp;time&nbsp;or&nbsp;need&nbsp;to&nbsp;wait&nbsp;the&nbsp;current&nbsp;vcpu \
&nbsp;scheduled&nbsp;out.&nbsp;Which&nbsp;part&nbsp;decides&nbsp;the&nbsp;priority&nbsp;among&nbsp;them?&nbsp;
 &gt;&gt;
&gt;Mmm...&nbsp;I&nbsp;spot&nbsp;some&nbsp;confusion&nbsp;here.&nbsp;Why&nbsp;the&nbsp;scheduling&nbsp;out&nbsp;of&nbsp;a&nbsp;vcpu
 &gt;should&nbsp;be&nbsp;involved&nbsp;in&nbsp;all&nbsp;this?&nbsp;I&nbsp;mean,&nbsp;raising&nbsp;a&nbsp;SCHEDULE_SOFTIRQ&nbsp;and,
 &gt;most&nbsp;important,&nbsp;handling&nbsp;it,&nbsp;happens&nbsp;in&nbsp;Xen&nbsp;code.&nbsp;That&nbsp;means&nbsp;there&nbsp;is&nbsp;a
 &gt;pCPU&nbsp;executing&nbsp;hypervisor&nbsp;code,&nbsp;independently&nbsp;of&nbsp;which&nbsp;one&nbsp;is&nbsp;the&nbsp;vCPU
 &gt;that&nbsp;is&nbsp;or&nbsp;was&nbsp;running&nbsp;on&nbsp;that&nbsp;same&nbsp;pCPU.&nbsp;Well,&nbsp;this&nbsp;same&nbsp;hypervisor
 &gt;code&nbsp;will&nbsp;get&nbsp;to&nbsp;execute,&nbsp;at&nbsp;some&nbsp;point,&nbsp;csched_schedule(),&nbsp;make&nbsp;the
 &gt;scheduling&nbsp;decision&nbsp;and,&nbsp;if&nbsp;that&nbsp;is&nbsp;the&nbsp;case,&nbsp;dschedule&nbsp;the&nbsp;running&nbsp;vCPU
 &gt;and&nbsp;schedule&nbsp;another&nbsp;one&nbsp;(and&nbsp;here&nbsp;you&nbsp;are&nbsp;a&nbsp;preemption).
 &gt;
&gt;Actually,&nbsp;we&nbsp;really&nbsp;can't&nbsp;wait&nbsp;for&nbsp;a&nbsp;vCPU&nbsp;to&nbsp;be&nbsp;descheduled&nbsp;to&nbsp;execute
 &gt;the&nbsp;Xen&nbsp;scheduler,&nbsp;since&nbsp;it's&nbsp;the&nbsp;Xen&nbsp;scheduler&nbsp;itself&nbsp;that&nbsp;deschedules
 &gt;vCPUs!&nbsp;:-O
&gt;
&gt;Perhaps,&nbsp;with&nbsp;"scheduled&nbsp;out"&nbsp;you&nbsp;mean&nbsp;something&nbsp;like&nbsp;block,&nbsp;i.e.,&nbsp;you
 &gt;want&nbsp;to&nbsp;know&nbsp;if&nbsp;Xen&nbsp;is&nbsp;able&nbsp;to&nbsp;interrupt&nbsp;the&nbsp;vCPUs&nbsp;or&nbsp;if&nbsp;it&nbsp;always&nbsp;run
 &gt;them&nbsp;to&nbsp;completion&nbsp;or&nbsp;blocking.&nbsp;In&nbsp;which&nbsp;case,&nbsp;the&nbsp;former,&nbsp;we&nbsp;interrupt
 &gt;the&nbsp;vCPUs,&nbsp;just&nbsp;like&nbsp;an&nbsp;(preemptible)&nbsp;OS&nbsp;scheduler&nbsp;interrupts&nbsp;OS's
 &gt;tasks.&nbsp;Whether&nbsp;or&nbsp;not&nbsp;that&nbsp;will&nbsp;result&nbsp;in&nbsp;a&nbsp;preemption,&nbsp;it&nbsp;depends&nbsp;both
 &gt;on&nbsp;the&nbsp;scheduler&nbsp;and&nbsp;on&nbsp;the&nbsp;circumstances.
&gt;
&gt;Sounds&nbsp;better&nbsp;now?
&gt;
&gt;&gt;&nbsp;Can&nbsp;you&nbsp;give&nbsp;me&nbsp;some&nbsp;guidance,&nbsp;where&nbsp;is&nbsp;the&nbsp;code&nbsp;for&nbsp;&nbsp;softirqs&nbsp;&amp;&nbsp;tasklets.
 &gt;&gt;&nbsp;
&gt;Well,&nbsp;grep&nbsp;and&nbsp;find&nbsp;are&nbsp;usually&nbsp;good&nbsp;friends,&nbsp;when&nbsp;the&nbsp;question&nbsp;is&nbsp;where
 &gt;is&nbsp;the&nbsp;code!&nbsp;:-P
&gt;
&gt;Both
&gt;
&gt;$&nbsp;grep&nbsp;tasklet&nbsp;xen.git/xen/*
&gt;
&gt;and
&gt;
&gt;$&nbsp;grep&nbsp;softirq&nbsp;xen.git/xen/*
&gt;
&gt;Produce&nbsp;a&nbsp;lot&nbsp;of&nbsp;output&nbsp;here.&nbsp;Also,&nbsp;I'd&nbsp;try&nbsp;something&nbsp;like&nbsp;that...&nbsp;You
 &gt;know,&nbsp;programmers&nbsp;usually&nbsp;have&nbsp;quite&nbsp;few&nbsp;fantasy
&gt;
&gt;$&nbsp;find&nbsp;./xen.git/xen/&nbsp;-iname&nbsp;tasklet*
&gt;./xen/include/xen/tasklet.h
&gt;./xen/common/tasklet.c
&gt;
&gt;$&nbsp;find&nbsp;./xen.git/xen/&nbsp;-iname&nbsp;softirq*
&gt;./xen/include/asm-x86/softirq.h
&gt;./xen/include/xen/softirq.h
&gt;./xen/include/asm-arm/softirq.h
&gt;./xen/common/softirq.c
&gt;
&gt;&gt;&nbsp;Another&nbsp;question:
&gt;&gt;&nbsp;In&nbsp;the&nbsp;schedule()&nbsp;function&nbsp;of&nbsp;schedule.c&nbsp;f \
ile,&nbsp;at&nbsp;first,&nbsp;it&nbsp;will&nbsp;set&nbsp;the&nbsp;flag&nbsp;tasklet_wo \
rk_scheduled&nbsp;according&nbsp;to&nbsp;whether&nbsp;has&nbsp;the&nbsp;tasklet_work.&nbsp;What&nbsp;is&nbsp;the&nbsp;tasklet&nbsp;work?
 &gt;&gt;
&gt;After&nbsp;having&nbsp;inspected&nbsp;at&nbsp;least&nbsp;some&nbsp;of&nbsp;the&nbsp;sources&nbsp;above,&nbsp;look&nbsp;for&nbsp;the
 &gt;do_tasklet()&nbsp;function,&nbsp;and&nbsp;revise&nbsp;what&nbsp;it&nbsp;does.&nbsp;If&nbsp;it's&nbsp;the&nbsp;concept&nbsp;of
 &gt;tasklet&nbsp;and&nbsp;softirq&nbsp;that&nbsp;you're&nbsp;unfamiliar&nbsp;with,&nbsp;well,&nbsp;very&nbsp;quickly&nbsp;it's
 &gt;just&nbsp;one&nbsp;way&nbsp;of&nbsp;deferring&nbsp;work&nbsp;in&nbsp;an&nbsp;OS&nbsp;(or,&nbsp;in&nbsp;out&nbsp;case,&nbsp;an&nbsp;hypervisor,
 &gt;but&nbsp;still).
&gt;
&gt;Linux&nbsp;makes&nbsp;uses&nbsp;of&nbsp;these&nbsp;kind&nbsp;of&nbsp;things&nbsp;pretty&nbsp;heavily&nbsp;(although&nbsp;the
 &gt;names,&nbsp;the&nbsp;implementation,&nbsp;and&nbsp;the&nbsp;number&nbsp;of&nbsp;different&nbsp;variants&nbsp;of&nbsp;them
 &gt;changes&nbsp;with&nbsp;kernel&nbsp;versions).&nbsp;I&nbsp;trust/hope&nbsp;you&nbsp;can&nbsp;find&nbsp;enough
 &gt;documentation&nbsp;about&nbsp;that&nbsp;on&nbsp;line.&nbsp;:-)
&gt;
&gt;&gt;&nbsp;In&nbsp;the&nbsp;csched_schedule()&nbsp;of&nbsp;&nbsp;sched_credit.c&nbs \
p;file,&nbsp;it&nbsp;will&nbsp;give&nbsp;the&nbsp;idle&nbsp;vcpu&nbsp;boost&nbsp;priority&nbsp;if&nbsp;the&nbsp;tasklet_work_scheduled&nbsp;is&nbsp;set.&nbsp;
 &gt;&gt;&nbsp;I&nbsp;have&nbsp;some&nbsp;difficult&nbsp;for&nbsp;understanding&nbsp;t \
his&nbsp;part.&nbsp;Maybe&nbsp;my&nbsp;confusion&nbsp;is&nbsp;not&nbsp;knowing&nbsp;th \
e&nbsp;tasklet&nbsp;work.&nbsp;Can&nbsp;you&nbsp;give&nbsp;some&nbsp;explanation&nbsp;why&nbsp;designing&nbsp;like&nbsp;this?
 &gt;&gt;&nbsp;
&gt;Again,&nbsp;tasklet&nbsp;is&nbsp;deferred&nbsp;work.&nbsp;That&nbsp;means&nbsp;there&nbsp;is&nbsp;this&nbsp;pretty
 &gt;function&nbsp;you&nbsp;want&nbsp;to&nbsp;call,&nbsp;but&nbsp;you&nbsp;can&nbsp;call&nbsp;it&nbsp;right&nbsp;now.&nbsp;Typical
 &gt;example&nbsp;is&nbsp;because&nbsp;you&nbsp;have&nbsp;interrupt&nbsp;disabled&nbsp;and&nbsp;the&nbsp;pretty&nbsp;function
 &gt;in&nbsp;question&nbsp;wants&nbsp;interrupt&nbsp;enabled,&nbsp;or&nbsp;it&nbsp;is&nbsp;you&nbsp;that&nbsp;you&nbsp;don't&nbsp;want&nbsp;to
 &gt;keep&nbsp;interrupts&nbsp;disabled&nbsp;for&nbsp;too&nbsp;long,&nbsp;or&nbsp;any&nbsp;other&nbsp;reason.
 &gt;
&gt;Ok,&nbsp;what&nbsp;you&nbsp;do&nbsp;is&nbsp;to&nbsp;make&nbsp;a&nbsp;note&nbsp;about&nbsp;calling&nbsp;that&nbsp;function&nbsp;later,&nbsp;and
 &gt;that's&nbsp;exactly&nbsp;what&nbsp;tasklet&nbsp;does.&nbsp;The&nbsp;reason&nbsp;why&nbsp;we&nbsp;execute&nbsp;them&nbsp;in&nbsp;idle
 &gt;domain's&nbsp;context&nbsp;is,&nbsp;well,&nbsp;because&nbsp;we&nbsp;have&nbsp;to&nbsp;execute&nbsp;them
 &gt;somewhere!&nbsp;&nbsp;:-)
&gt;
&gt;Seriously,&nbsp;our&nbsp;scheduler&nbsp;schedules&nbsp;vCPUs,&nbsp;not&nbsp;'functions',&nbsp;so&nbsp;you&nbsp;either
 &gt;call&nbsp;a&nbsp;function&nbsp;from&nbsp;where&nbsp;you&nbsp;are&nbsp;(and&nbsp;we&nbsp;already&nbsp;said&nbsp;you&nbsp;can't)&nbsp;or,
 &gt;when&nbsp;you're&nbsp;done,&nbsp;the&nbsp;scheduler&nbsp;will&nbsp;pick&nbsp;a&nbsp;vCPU&nbsp;and&nbsp;get&nbsp;on&nbsp;with&nbsp;it,&nbsp;and
 &gt;your&nbsp;function&nbsp;will&nbsp;never&nbsp;be&nbsp;called.&nbsp;What&nbsp;we&nbsp;hence&nbsp;do&nbsp;is&nbsp;making&nbsp;sure&nbsp;it
 &gt;is&nbsp;one&nbsp;of&nbsp;the&nbsp;idle&nbsp;domain's&nbsp;vCPUs&nbsp;that&nbsp;is&nbsp;scheduled,&nbsp;as&nbsp;well&nbsp;as&nbsp;making
 &gt;sure&nbsp;that&nbsp;such&nbsp;vCPU&nbsp;will&nbsp;call&nbsp;your&nbsp;function&nbsp;as&nbsp;part&nbsp;of&nbsp;'its&nbsp;workload'.
 &gt;
&gt;Check&nbsp;out&nbsp;the&nbsp;idle_loop()&nbsp;function,&nbsp;it's&nbsp;in&nbsp;xen/arch/x86/domain.c.</pre><pre \
style="color: rgb(255, 0, 0);">Thank you very much once again for your detail \
description!</pre><pre> &gt;
&gt;Regards,
&gt;Dario
&gt;
&gt;
</pre></div><br><br><span title="neteasefooter"><span \
id="netease_mail_footer"></span></span>



_______________________________________________
Xen-users mailing list
Xen-users@lists.xen.org
http://lists.xen.org/xen-users

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic