From: Boris Ostrovsky Subject: Re: [PATCH v3 4/9] mm: Scrub memory from idle loop Date: Thu, 11 May 2017 10:19:02 -0400 Message-ID: <34644cef-567d-b558-c580-5ed7d8116fa5@oracle.com> References: <1492184258-3277-1-git-send-email-boris.ostrovsky@oracle.com> <1492184258-3277-5-git-send-email-boris.ostrovsky@oracle.com> <1494498375.7393.5.camel@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2639681618357277915==" Return-path: In-Reply-To: <1494498375.7393.5.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Dario Faggioli , xen-devel@lists.xen.org Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, jbeulich@suse.com List-Id: xen-devel@lists.xenproject.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============2639681618357277915== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qVXvLPfxicXvIscVWdAHvUTJSqcsPQ8VB" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qVXvLPfxicXvIscVWdAHvUTJSqcsPQ8VB Content-Type: multipart/mixed; boundary="dMFM1PCHp4Mwg2a1SCc8A88iEFxb6eoQG"; protected-headers="v1" From: Boris Ostrovsky To: Dario Faggioli , xen-devel@lists.xen.org Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, jbeulich@suse.com Message-ID: <34644cef-567d-b558-c580-5ed7d8116fa5@oracle.com> Subject: Re: [Xen-devel] [PATCH v3 4/9] mm: Scrub memory from idle loop References: <1492184258-3277-1-git-send-email-boris.ostrovsky@oracle.com> <1492184258-3277-5-git-send-email-boris.ostrovsky@oracle.com> <1494498375.7393.5.camel@citrix.com> In-Reply-To: <1494498375.7393.5.camel@citrix.com> --dMFM1PCHp4Mwg2a1SCc8A88iEFxb6eoQG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c >> index 90e2b1f..a5f62b5 100644 >> --- a/xen/arch/x86/domain.c >> +++ b/xen/arch/x86/domain.c >> @@ -118,7 +118,8 @@ static void idle_loop(void) >> { >> if ( cpu_is_offline(smp_processor_id()) ) >> play_dead(); >> - (*pm_idle)(); >> + if ( !scrub_free_pages() ) >> + (*pm_idle)(); >> do_tasklet(); >> > This means that, if we got here to run a tasklet (as in, if the idle > vCPU has been forced into execution, because there were a vCPU context > tasklet wanting to run), we will (potentially) do some scrubbing first.= > > Is this on purpose, and, in any case, ideal? vCPU context tasklets are > not terribly common, but I still don't think it is (ideal). > > Not sure how to address this, though. What (the variants of) pm_idle() > uses for deciding whether or not to actually go to sleep is > cpu_is_haltable(), which checks per_cpu(tasklet_work_to_do, cpu): > > /* > * Used by idle loop to decide whether there is work to do: > * (1) Run softirqs; or (2) Play dead; or (3) Run tasklets. > */ > #define cpu_is_haltable(cpu) \ > (!softirq_pending(cpu) && \ > cpu_online(cpu) && \ > !per_cpu(tasklet_work_to_do, cpu)) > > Pulling it out/adding a call to it (cpu_is_haltable()) is ugly, and > probably not what we want (e.g., it's always called with IRQs disabled,= > while they're on here). > > Maybe we can test tasklet_work_to_do, before calling scrub_free_pages()= > (also ugly, IMO). > Or, if scrub_free_pages() is, and always will be, called only from > here, within the idle loop, test tasklet_work_to_do inside, similarly > to what it does already for pending softirqs... We can move do_tasklet() above scrub_free_pages(). And new tasklet after that would result in a softirq being set so we'd do an early exit from scrub_free_pages(). OTOH since, as you say, we only get to idle loop() if no tasklet is pending (cpu_is_haltable() test) then would even that be needed? -boris --dMFM1PCHp4Mwg2a1SCc8A88iEFxb6eoQG-- --qVXvLPfxicXvIscVWdAHvUTJSqcsPQ8VB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJZFHLWAAoJEIredpCGysGyYHYP/jmU7c9bCrsNVMqxKFlEt4ve MQXbLcFhvwylkTTlrZTivC+xdp6SsCf61lN3YAWbITuVGJso7LaAs880KCiitFcy Z441hDzIxymtY7BZOOfB73BA+9GMFpwGJnX8s82zWbFHzlNScPiLwmyS0l/TWUeJ FTGLGej5LiHb4aaa2Fhs2IJ+oeMh1b9ynD6X+v/hQ00kAhwdZqm7aAe38nmp8tKG /R+BLUVsY8VaAdZTgBsdcrzz3Et7iwQV2l5mNsxmZq7j0ZSshgfsmSHOFUtqpuCQ k996lmcKoDt4jmCSgu4P78Oc7Ggi4cpX7l2Inr/wkXt6keg3gXiYSDkyMg2XszbS KTGv+IDpZsJogDx/KuNEeSNNUFFEZHV+lX/WuG3A3PQDepjWO2wG7cG90O76zSHW a7cI/pAW3rtBXw/RkU/IDnYja3RIPrkKJ8u3RRyVzqCJUKbZh2E99x9Kugccazlz Hg5Oi651a1yCVawGS3f0iz+uGx2dVNO49GLlbxg/2t56u8duRte99M9r5cKlDVsu HVc8SdNpNUyA3xVSMTLKAdC3i/M2tGY+5N4tCamFh3fxz0/xcfKdYgfRHantEoo4 yyu3KrKZ6zhulWyYZLsu+Y2sJbJcf+XqR3/RxbRhb9h51mAEdlEqeptlHKCet8p6 3IN+WAHv4u2Ylmk3Yoij =+WmX -----END PGP SIGNATURE----- --qVXvLPfxicXvIscVWdAHvUTJSqcsPQ8VB-- --===============2639681618357277915== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============2639681618357277915==--