From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: Re: [ARM] Native application design and discussion (I hope) Date: Tue, 9 May 2017 13:08:32 +0200 Message-ID: <1494328112.9501.9.camel@citrix.com> References: <1492020822.3287.33.camel@citrix.com> <29f244da-2346-70a7-13f0-e5c0cbf490d7@epam.com> <1494324789.9501.7.camel@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0450859167101126267==" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Julien Grall , Stefano Stabellini , Andrii Anisov Cc: Volodymyr Babchuk , Artem Mygaiev , george.dunlap@citrix.com, Xen Devel List-Id: xen-devel@lists.xenproject.org --===============0450859167101126267== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="=-0jK5r7+eZDi/TV3F8bwc" --=-0jK5r7+eZDi/TV3F8bwc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2017-05-09 at 11:32 +0100, Julien Grall wrote: > Hi Dario, >=20 Hey, > On 05/09/2017 11:13 AM, Dario Faggioli wrote: > >=20 > > Which, FTR, is what we do in Xen for a bunch of things already, > > i.e., > > softirqs and tasklets. >=20 > No, we don't switch to the idle vCPU to handle tasklets or softirqs.=C2= =A0 > They will be done before entering to the guest and still in the=C2=A0 > hypervisor context. >=20 Mmm... I don't know who's "we" here, but even if it's "you ARM people", you actually do. In fact, this is common code: static struct task_slice csched_schedule( const struct scheduler *ops, s_time_t now, bool_t tasklet_work_schedule= d) { [...] /* Choices, choices: =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* - If we have a tasklet, we need to run the = idle vcpu no matter what. [...] /* Tasklet work (which runs in idle VCPU context) overrides all else. *= / if ( tasklet_work_scheduled ) { TRACE_0D(TRC_CSCHED_SCHED_TASKLET); snext =3D CSCHED_VCPU(idle_vcpu[cpu]); snext->pri =3D CSCHED_PRI_TS_BOOST; } =C2=A0 [...] } And this is "your" idle loop: void idle_loop(void) { =C2=A0=C2=A0=C2=A0=C2=A0for ( ; ; ) =C2=A0=C2=A0=C2=A0=C2=A0{ [...] =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0local_irq_disable(); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if ( cpu_is_haltable(smp_pr= ocessor_id()) ) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0{=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0dsb= (sy); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0wfi= (); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0} =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0local_irq_enable(); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0do_tasklet(); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0do_softirq(); [...] =C2=A0=C2=A0=C2=A0=C2=A0} } Actually, yes, it was a bit inaccurate of me to cite both softirqs and tasklets, together, like I did. Softirqs indeed are checked and handled before leaving Xen, as you say, as well as, in the idle loop, as shown above. But for tasklet (and, to be 100% precise, for vCPU context tasklet), it's actually the case that we force the idle vCPU in execution to run them. > > And it should not be hard to give such code access to the context > > of > > the vCPU that was previously running (in x86, given we implement > > what > > we call lazy context switch, it's most likely still loaded in the > > pCPU!). >=20 > I agree with Stefano, switching to the idle vCPU is a pretty bad > idea. >=20 > the idle vCPU is a fake vCPU on ARM to stick with the common code > (we=C2=A0 > never leave the hypervisor). In the case of the EL0 app, we want to=C2=A0 > change exception level to run the code with lower privilege. >=20 > Also IHMO, it should only be used when there are nothing to run and > not=C2=A0 > re-purposed for running EL0 app. >=20 It's already purposed for running when there is nothing to do _or_ when there are tasklets. I do see your point about privilege level, though. And I agree with George that it looks very similar to when, in the x86 world, we tried to put the infra together for switching to Ring3 to run some pieces of Xen code. Regards, Dario --=20 <> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK) --=-0jK5r7+eZDi/TV3F8bwc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJZEaMxAAoJEBZCeImluHPuNhwQAK4tR9lpPpyZ/GJkFAxhgWRm 8aNBs5LAfdjaN2tJ0wbXnhfSpUIHYCL6EOJci2WLreruhT/CB+CCI2EwxJp7p3HK 8FzuraJCUAphDTpbtqJ6rtF7gc3PeIYDfZfhpxUbYsGIvyw5puK0Aecqkiv6x2gv WREn2n1RzbNJhpYi8RVJbGNoDDlIiq/Ryp9ZcW7dNrf4CGmR7XOMTNlE2HWUR7PZ ESjJkAcrAp2fnwTdzXIJJmePvQ4jPeUaDshQa+I677Vyd1EzxfxO4u+amFrNhrFm 33YApy1tWvn3C2r+5o1DZuwaJ7N0gQJZotZPWxhet8gijrBr8cYXbjmIpP+Dhopb gASGUsu8X75lx/PG8i9BQoR7QK7qImDcAdGthBV9N68aqxgtq8AwkxS7agG2G0Ls N/eoA1iEUsjlLVvfo5K72BEg5m3v/mcyZFcnjO7zGymK3l8FvJCjG0DIqnWTb2x9 LXK2IbggZgW6OkIK8IlL7U15+5z6SU+NuBKxzXUfKPikIfDYBSscQWHcmv4/RHY1 kwLEY7CtoggQ4Eb/0P2b0DKVAT1NJ7PGJJXblP8wYK7lz61uEG2DhbCBUuw10f6e HcLkI5rJD/J/FVfUxpF7PgyCFlr8evDWW1BFLjYp1xsZ2VDkdf3wM5uBsJo9GML+ cgU0B9zgDeVYXee8U4jL =2JX3 -----END PGP SIGNATURE----- --=-0jK5r7+eZDi/TV3F8bwc-- --===============0450859167101126267== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============0450859167101126267==--