xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Jan Beulich <JBeulich@suse.com>
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
	George.Dunlap@eu.citrix.com, ian.jackson@eu.citrix.com,
	tim@xen.org, xen-devel@lists.xen.org, andrew.cooper3@citrix.com
Subject: Re: [PATCH v4 4/8] mm: Scrub memory from idle loop
Date: Mon, 12 Jun 2017 23:28:36 +0200	[thread overview]
Message-ID: <1497302916.26212.30.camel@citrix.com> (raw)
In-Reply-To: <321c791e-d732-1730-d529-35ad9506b9a9@oracle.com>


[-- Attachment #1.1: Type: text/plain, Size: 3491 bytes --]

On Mon, 2017-06-12 at 13:01 -0400, Boris Ostrovsky wrote:
> On 06/12/2017 04:08 AM, Jan Beulich wrote:
> > > > > On 19.05.17 at 17:50, <boris.ostrovsky@oracle.com> wrote:
> > > 
> > > Instead of scrubbing pages during guest destruction (from
> > > free_heap_pages()) do this opportunistically, from the idle loop.
> > 
> > This is too brief for my taste. In particular the re-ordering ...
> > 
> > > --- a/xen/arch/x86/domain.c
> > > +++ b/xen/arch/x86/domain.c
> > > @@ -118,8 +118,9 @@ static void idle_loop(void)
> > >      {
> > >          if ( cpu_is_offline(smp_processor_id()) )
> > >              play_dead();
> > > -        (*pm_idle)();
> > >          do_tasklet();
> > > +        if ( cpu_is_haltable(smp_processor_id()) &&
> > > !scrub_free_pages() )
> > > +            (*pm_idle)();
> > >          do_softirq();
> > 
> > ... here (and its correctness / safety) needs an explanation. Not
> > processing tasklets right after idle wakeup is a not obviously
> > correct change. 
>
Well, one can also see things the other way round, though. I.e.:
considering that do_tasklet() is here for when we force the idle vcpu
into execution right because we want to process tasklets, doing that
only after having tried to sleep is not obviously correct.

And in fact, there's an unwritten (AFAICT) requirement that every
implementation of pm_idle should not actually sleep if there are
tasklets pending.

Truth is, IMO, that we may be here for two reasons: 1) going to sleep
or 2) running tasklet, and the only think we can do is guessing (and
ordering the call according to such guess) and checking whether we
guessed right or wrong. That is:
 - guess it's 1. Check whether it's really 1. If it is, go ahead with  
    it; if not, go for 2;
 - guess it's 2. Check whether it's really 2. If it is, go ahead with
   it, if not, go for 1;

Now scrubbing is kind of a third reason why we may be here, and doing
as done in the code above (although I'm not super happy of the final
look of the result either), should make all the use cases happy.

Also, what's the scenario where you think this may be problematic?
AFAICT, tasklets are vcpu context, or softirq context. If some softirq
context tasklet work is scheduled for a CPU while it is sleeping,
TASKLET_SOFTIRQ is raised, and the call to do_softirq() --which still
happens right after the wakeup-- will take care of it.

If some vcpu context work is scheduled, SCHEDULE_SOFTIRQ is raised.
do_softirq() will call the scheduler, which will see that there is vcpu
tasklet work to do, and hence confirm in execution the idle vcpu, which
will get to execute do_tasklet().

Anyway...

> > Nor is it immediately clear why this needs to be
> > pulled ahead for your purposes.
> 
> Are you asking for a comment here (i.e. the explanation given by
> Dario
> (added)  in
> https://lists.xenproject.org/archives/html/xen-devel/2017-05/msg01215
> .html)
> or are you saying something is wrong?
> 
...If it's more commenting that's being asked, either in the code or in
the changelog, that would indeed improve things, I agree.

Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 127 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-06-12 21:28 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 15:50 [PATCH v4 0/8] Memory scrubbing from idle loop Boris Ostrovsky
2017-05-19 15:50 ` [PATCH v4 1/8] mm: Place unscrubbed pages at the end of pagelist Boris Ostrovsky
2017-06-09 14:50   ` Jan Beulich
2017-06-09 20:07     ` Boris Ostrovsky
2017-06-12  6:50       ` Jan Beulich
2017-05-19 15:50 ` [PATCH v4 2/8] mm: Extract allocation loop from alloc_heap_pages() Boris Ostrovsky
2017-06-09 15:08   ` Jan Beulich
2017-05-19 15:50 ` [PATCH v4 3/8] mm: Scrub pages in alloc_heap_pages() if needed Boris Ostrovsky
2017-06-09 15:22   ` Jan Beulich
2017-06-09 20:55     ` Boris Ostrovsky
2017-06-12  6:54       ` Jan Beulich
2017-05-19 15:50 ` [PATCH v4 4/8] mm: Scrub memory from idle loop Boris Ostrovsky
2017-06-12  8:08   ` Jan Beulich
2017-06-12 17:01     ` Boris Ostrovsky
2017-06-12 21:28       ` Dario Faggioli [this message]
2017-06-13  8:19         ` Jan Beulich
2017-06-13 18:39           ` Boris Ostrovsky
2017-06-13 20:36             ` Dario Faggioli
2017-06-13 21:54               ` Boris Ostrovsky
2017-06-14  9:18             ` Jan Beulich
2017-06-13  8:12       ` Jan Beulich
2017-06-13 18:20         ` Boris Ostrovsky
2017-06-14  9:17           ` Jan Beulich
2017-05-19 15:50 ` [PATCH v4 5/8] spinlock: Introduce spin_lock_cb() Boris Ostrovsky
2017-06-12  8:23   ` Jan Beulich
2017-05-19 15:50 ` [PATCH v4 6/8] mm: Keep heap accessible to others while scrubbing Boris Ostrovsky
2017-06-12  8:30   ` Jan Beulich
2017-06-12 17:11     ` Boris Ostrovsky
2017-05-19 15:50 ` [PATCH v4 7/8] mm: Print number of unscrubbed pages in 'H' debug handler Boris Ostrovsky
2017-05-19 15:50 ` [PATCH v4 8/8] mm: Make sure pages are scrubbed Boris Ostrovsky
2017-06-12  8:43   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1497302916.26212.30.camel@citrix.com \
    --to=dario.faggioli@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).