All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Cc: Julien Grall <julien.grall@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Artem Mygaiev <joculator@gmail.com>,
	Xen Devel <xen-devel@lists.xen.org>
Subject: Re: [ARM] Native application design and discussion (I hope)
Date: Fri, 7 Apr 2017 16:36:05 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.10.1704071622390.2759@sstabellini-ThinkPad-X260> (raw)
In-Reply-To: <CAOcqxo2n9gtwUz0xv0t22aA=mO8UZboT3ciuoN_e5q6isAWaNw@mail.gmail.com>

On Fri, 7 Apr 2017, Volodymyr Babchuk wrote:
> >> Native application is an another domain type. It has own vCPU (only one at this
> >> moment) Native app is loaded as any other kernel, using ELF loader.
> >> It looks like another stub-domain such as MiniOS, but there are two big
> >> differences:
> >
> > Could you describe the reason why you are suggesting it? Unless strictly
> > necessary, I wouldn't go down the vcpu route, because as soon as we
> > bring a vcpu into the picture, we have a number of problems, including
> > scheduling, affinity, etc. It is also user-visible (xl vcpu-list) which
> > I don't think it should be.
> I used this in my PoC because I didn't want to do extra work. Also this looks
> very natural. Domain is actually the same as a process, vcpu is like a thread.
> But yes, I already had some issues with scheduler. Manageable, thought.
> 
> > I understand that one of the goals is "Modularity", which makes us think
> > of an ELF loader, such as the one for a new domain. I agree that
> > modularity is important, but I would solve it as a second step. In first
> > instance, I would limit the scope to run some code under
> > /xen/arch/arm/apps or, better, /apps (for example) in a lower privilege
> > mode. After that is done and working, I am sure we can find a way to
> > dynamically load more apps at run time.
> Again, use of existing domain framework was the easiest way. I needed
> some container to hold app and domain fits perfectly. I need to map pages
> there, need routines to copy to and from its memory, need p2m code, etc.
> 
> But, yes, if we are going to implement this in right way, then maybe we need
> separate identities like 'app_container' and 'app_thread'. See below.
> 
> >
> > A vcpu is expected to be running simultenously with other vcpus of the
> > same domain or different domains. The scheduler is expected to choose
> > when it is supposed to be running. On the other end, an el0 app runs to
> > handle/emulate a single request from a guest vcpu, which will be paused
> > until the el0 app finishes. After that, the guest vcpu will resume.
> Okay, but what should be stored in `current` while el0 application is running?
> Remember, that it can issue syscalls, which will be handled in hypervisor.
> 
> We can create separates types for native applications. But then we can end
> having two parallel and mostly identical frameworks. One for domains and
> another one - for apps. What do you think?

This is a great topic for the Xen Hackathon.

This is the most difficult problem that we need to solve as part of this
work. It is difficult to have the right answer at the beginning, before
seeing any code. If the app_container/app_thread approach causes too
much duplication of work, the alternative would be to fix/improve
stubdoms (minios) until they match what we need. Specifically, these
would be the requirements:

1) Determinism: a stubdom servicing a given guest needs to be scheduled
   immediately after the guest vcpu traps into Xen. It needs to
   deterministic. The stubdom vcpu has to be scheduled on the same pcpu.
   This is probably the most important missing thing at the moment.

2) Accounting: memory and cpu time of a stubdom should be accounted
   agaist the domain it is servicing. Otherwise it's not fair.

3) Visibility: stub domains and vcpus should be marked differently from other
   vcpus as not to confuse the user. Otherwise "xl list" becomes
   confusing.


1) and 2) are particularly important. If we had them, we would not need
el0 apps. I believe stubdoms would be as fast as el0 apps too.



> >> At this moment entry point is hardcoded and you need to update it every time
> >> you rebuild native application. Also there are no actual parameters passed.
> >> Also, whole code is a piece of gosa, because it was first time I hacked XEN.
> >
> > :-)
> > I would start by introducing a proper way to pass parameters and return
> > values.
> >
> >> I don't want to repeat benchmark results, because they already was posted in ML.
> >> You can find them at [3].
> >>
> >> I understand that I have missed many things:
> >>
> >> 1. How to ship and load native app, because some of them will be needed even
> >> before dom0 is created.
> >
> > I envision something like Linux's insmod, but I suggest postponing this
> > problem. At the moment, it would be fine to assume that all apps need to
> > be built statically and cannot be loaded at runtime.
> Okay. Then we need to hold them in special sections of hypervisor image
> and also we need some sort of loader in hypervisor.
> 
> >> 2. How to distinguish multiple native apps
> >
> > Each apps need to specify a range of MMIO/SMC handlers. Xen will invoke
> > the right one.
> What about device drivers? Consider power management for example. This is
> crucial if we want to use XEN in mobile devices. Our (there, in EPAM) idea is
> to hold drivers for PM, drivers for coprocessors and so on in native apps.
> Probably we will need different types of apps: SMC handler, MMIO handler,
> PM driver, and so on.

Yes, something like that.


> >> 3. Concurrency in native apps
> >
> > This is an interesting problem: what do we do if two guest vcpus make
> > simultenous requests that need to be handled by the same app?
> > Technically, we could run the same app twice on two different pcpus
> > simultenously. But then, the apps would need to be able to cope with
> > concurrency (spin_locks, etc.) From Xen point of view, it should be OK
> > though.
> Yes. Probably, we can pass id of pcpu to app, so it can have per-cpu storage
> if it wants to. Plus spin_locks and no blocking syscalls.
> 
> >
> >> 4. How to restart misbehaved apps.
> >
> > A related question is the following: do we expect to allocate each app
> > once at boot or once per guest? Apps need to have some per-domain
> > context, but it could be passed from Xen to the app on a shared page,
> > possibly reducing the need for allocating the same app once per guest?
> SMC handler needs to be cross-domain for example. Emulators can be
> tied to guests, I think. Device drivers should be cross-domain also.
> 
> >
> >> But at this moment I want to discuss basic approach. If there are will be no
> >> objections against basic concept, then we can develop details.
> >>
> >> [1] https://github.com/lorc/xen_app_stub - native app
> >> [2] https://github.com/lorc/xen/tree/el0_app - my branch with PoC
> >> [3] http://marc.info/?l=xen-devel&m=149088856116797&w=2 - benchmark results

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

  reply	other threads:[~2017-04-07 23:36 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 20:21 [ARM] Native application design and discussion (I hope) Volodymyr Babchuk
2017-04-06 21:31 ` Stefano Stabellini
2017-04-07 11:03   ` Volodymyr Babchuk
2017-04-07 23:36     ` Stefano Stabellini [this message]
2017-04-11 20:32       ` Stefano Stabellini
2017-04-12 18:13         ` Dario Faggioli
2017-04-12 19:17           ` Stefano Stabellini
2017-04-20 20:20             ` Volodymyr Babchuk
2017-04-21 14:42               ` Andrii Anisov
2017-04-21 15:49                 ` Julien Grall
2017-04-21 16:08                   ` Volodymyr Babchuk
2017-04-21 16:20                   ` Andrii Anisov
2017-04-21 20:58                 ` Stefano Stabellini
2017-04-21 21:17                   ` Stefano Stabellini
2017-04-24 16:56                   ` Andrii Anisov
2017-04-24 18:08                     ` Stefano Stabellini
2017-04-25 10:15                       ` Andrii Anisov
2017-05-05 10:51                       ` Andrii Anisov
2017-05-05 19:28                         ` Stefano Stabellini
2017-05-08 10:46                           ` George Dunlap
2017-05-08 18:31                             ` Stefano Stabellini
2017-05-08 18:33                               ` Julien Grall
2017-05-09  8:53                               ` George Dunlap
2017-05-10 16:38                                 ` Andrii Anisov
2017-05-09 10:13                           ` Dario Faggioli
2017-05-09 10:32                             ` Julien Grall
2017-05-09 11:08                               ` Dario Faggioli
2017-05-09 11:19                                 ` Julien Grall
2017-05-09 18:29                                 ` Stefano Stabellini
2017-05-10  9:56                                   ` George Dunlap
2017-05-10 10:00                                     ` Julien Grall
2017-05-10 10:03                                       ` George Dunlap
2017-05-10 10:48                                         ` Julien Grall
2017-05-10 17:37                                           ` Volodymyr Babchuk
2017-05-10 18:05                                             ` Stefano Stabellini
2017-05-10 19:04                                             ` Julien Grall
2017-05-11 10:07                                               ` Julien Grall
2017-05-11 11:28                                                 ` Volodymyr Babchuk
2017-05-10 18:08                                     ` Andrii Anisov
2017-05-10 18:24                                       ` Stefano Stabellini
2017-05-11 15:19                                         ` Volodymyr Babchuk
2017-05-11 15:35                                           ` Modules support in Xen (WAS: Re: [ARM] Native application design and discussion (I hope)) Julien Grall
2017-05-11 16:35                                             ` George Dunlap
2017-05-11 17:14                                               ` Volodymyr Babchuk
2017-05-11 17:20                                                 ` George Dunlap
2017-05-11 17:53                                                   ` Lars Kurth
2017-05-11 17:14                                             ` George Dunlap
2017-05-11 17:16                                               ` George Dunlap
2017-05-11 18:13                                               ` Volodymyr Babchuk
2017-05-12 11:48                                                 ` George Dunlap
2017-05-12 18:43                                                   ` Stefano Stabellini
2017-05-12 19:04                                                     ` Volodymyr Babchuk
2017-05-15 11:21                                                       ` George Dunlap
2017-05-15 17:32                                                         ` Stefano Stabellini
2017-05-11 18:04                                             ` Stefano Stabellini
2017-05-11 18:39                                               ` Volodymyr Babchuk
2017-05-05 11:09                       ` [ARM] Native application design and discussion (I hope) Andrii Anisov
2017-04-24 19:11                     ` Julien Grall
2017-04-24 21:41                       ` Volodymyr Babchuk
2017-04-25 11:43                         ` Julien Grall
2017-04-26 21:44                           ` Volodymyr Babchuk
2017-04-27 17:26                             ` Volodymyr Babchuk
2017-05-02 12:52                               ` Julien Grall
2017-05-02 12:42                             ` Julien Grall
2017-04-25  8:52                       ` Andrii Anisov
2017-04-21 15:57               ` Julien Grall
2017-04-21 16:16                 ` Volodymyr Babchuk
2017-04-21 16:47                   ` Julien Grall
2017-04-21 17:04                     ` Volodymyr Babchuk
2017-04-21 17:38                       ` Julien Grall
2017-04-21 18:35                         ` Volodymyr Babchuk
2017-04-24 11:00                           ` Julien Grall
2017-04-24 21:29                             ` Volodymyr Babchuk
2017-04-21 21:24                         ` Stefano Stabellini
2017-04-24 16:14                           ` Andrii Anisov
2017-04-24 16:46                           ` Andrii Anisov
2017-04-27 15:25                           ` George Dunlap
2017-05-02 12:45                             ` Julien Grall
2017-05-12 18:47 Volodymyr Babchuk
2017-05-15 12:51 ` George Dunlap
2017-05-15 17:35   ` Stefano Stabellini
2017-05-15 13:54 ` Andrii Anisov

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=alpine.DEB.2.10.1704071622390.2759@sstabellini-ThinkPad-X260 \
    --to=sstabellini@kernel.org \
    --cc=joculator@gmail.com \
    --cc=julien.grall@arm.com \
    --cc=vlad.babchuk@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.