On Thu, 2016-09-01 at 11:52 +0100, anshul makkar wrote: > On 17/08/16 18:19, Dario Faggioli wrote: > >  > > +    /* > > +     * We're doing soft-affinity, and we know that the current > > vcpu on cpu > > +     * has a soft affinity. We now want to know whether cpu itself > > is in > Please can you explain the above statment. If the vcpu has soft > affinity  > and its currently executing, doesn;t it always means that its running > on  > one of the pcpu which is there in its soft affinity or hard affinity? > A vcpu will always run on a pcpu from its own hard-affinity (that's the definition of hard-affinity). On the other hand, a vcpu will, most of the time, run on a cpu from its own soft affinity, but can run on a cpu that is in its hard-affinity, but *IS NOT* in its soft-affinity. That's the definition of soft-affinity: the scheduler will try to run it there, but it that can't happen, it will run it will run it outside of it (but still within its hard-affinity, of course). So, yes, we know already that it's running in a cpu at least from its hard affinity, what is it exactly that you are not understanding? > > +     * such affinity. In fact, since we now that new (in > > runq_tickle()) is > Typo:   * such affinity. In fact, since now we know that new (in  > runq_tickle()) is > Thanks. :-) > > +     *  - if cpu is not in cur's soft-affinity, we should indeed > > check to > > +     *    see whether new should preempt cur. If that will be the > > case, that > > +     *    would be an improvement wrt respecting soft affinity; > > +     *  - if cpu is in cur's soft-affinity, we leave it alone and > > (in > > +     *    runq_tickle()) move on to another cpu. In fact, we don't > > want to > > +     *    be too harsh with someone which is running within its > > soft-affinity. > > +     *    This is safe because later, if we don't fine anyone else > > during the > > +     *    soft-affinity step, we will check cpu for preemption > > anyway, when > > +     *    doing hard-affinity. > > +     */ > Regards, Dario -- <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)