Fine-grained proxy resource charging
Hi John,
Some comments to your last message:
----------------
Quoted 10 lines
Quoted 2 lines
I/O bandwidth is a natural extension for resource accounting and can be addressed as well.
Agreed. An interesting extension of this example: what if a non-I/O privileged service domain B (say, a domain that provides a object encryption service) must sometimes perform some network I/O through a third domain (say, downloading a new encryption algorithm from an external source) in order to continue servicing A's requests? In this case, it will need to be possible for B to transitively specify on whose behalf the third-party work is being performed.
I think it might depend on the goal: if the goal is an "accounting", i.e. charging the domain for the resources it used, then one still can use pair-wise accounting schema, and should be able to derive the transitive charging from the higher level relationships/agreements, or again use some reasonable approximation (split the extra charge among all the parties using this encription service). Otherwise it becomes too complex (need to track the resource usage on the application level, and it seems beyond the Xen reach).
Quoted 10 lines
However, I'd already rejected the idea, and decided to concentrate on alternate/finer-grained/internal-to-B approaches, for several reasons:
- Preventing DoS. The count-page-exchanges scheme is good for CPU accounting, especially since it can be done with an unmodified B. However, in the context of actively rate-limiting A's resource consumption (perhaps by delaying or failing the page exchanges) it wouldn't work, since by the time B invokes a grant table operation it's too late -- B has already been affected.
You are right, the DOS prevention and performance isolation require a more detailed resource usage accounting. The problem is hard:
once the packet is processed by a driver (in B) and it is known which domain it is destined the largest potion of the work is done already... Even if the driver domain (B) decides do not deliver this packet to a destination domain A (due to high resource consumption on behalf of A), it can be somewhat late to react: B already has used a lot of resources for "half" processing packets on behalf of A...
----------------------------------------
Quoted 9 lines
Quoted 4 lines
The problem gets
much harder and more complex when there are different drivers hosted by the same driver domain.Could anybody comment on the current status of breaking dom0 into multiple single-function service domains, and/or not having a driver domain hosting multiple drivers? I'm not caught up on Xen's current events, pun intended.
Yes, I would join in asking the same question: how to get a working configuration for multiple driver domains each hosting a single device driver?
-----------------
Quoted 9 lines
Maybe it'd be
possible to split a driver domain into a group of cooperating mini-domains, that collectively accomplish the same purpose but are independently scheduled? Each mini-domain would service exactly one A-type domain. (How bad are context switches in ring 1...maybe not too bad, so the main challenge would be architecting the mini-domains.) I'd be happy to join in (from a distance) on any continuing whiteboard discussions you have along these lines.
I'm not sure whether this can be done, it seems that it is impossible to split the driver domain in the "mini-domains" you describe, unless you have a separate I/O device per each A-type domain (i.e. the devices are not shared).
Best regards, Lucy
Quoted 3 lines
Yes, I would join in asking the same question: how to get a working configuration for multiple driver domains each hosting a single device driver?
You can only really have one domain running the actual driver. The best strategy would therefore be to keep as much IO processing as possible in other domains (preferably in the guests themselves).
With user-accessible hardware (e.g. Infiniband), unprivileged guests will be able to access their hardware directly using their own CPU time (and get better performance in the process). Of course Infiniband is rather expensive so this won't be the most common way of doing stuff for some time (if at all).
Cheers,
Mark
Quoted 3 lines
the DOS prevention and performance isolation require
a more detailed resource usage accounting. The problem is hard:
once the packet is processed by a driver (in B) and it is known which
domain
Quoted 3 lines
it is destined the largest potion of the work is done already... Even if
the driver domain (B) decides do not deliver this packet to a
destination
Quoted 4 lines
domain A (due to high resource consumption on behalf of A), it can be somewhat late to react: B already has used a lot of resources for "half"
processing packets on behalf of A...
Interesting point. Perhaps a slightly longer-term view of performance isolation is most appropriate here: assume two time quanta, Q1 and Q2, where Q1 immediately precedes Q2. Assume A has already used up its entire resource allocation during Q1. Now, if B unwittingly performs a service for A during Q1 (say, accepting and processing packets from the network), then perhaps A's Q2 allocation could be preemptively charged.
On a related tangent, did you and Rob do any finer-grained analysis of which software components were generating the bulk of the high overheads in dom0? E.g., was it kernel time or user time; which kernel components were the big offenders, etc.? Perhaps if only a small number of components are responsible for the bulk of the overhead, we can more easily solve the more-accurate accounting & isolation problem by focusing on only those components.
------------------------------------------------------------------------
Andi's earlier comments have started me thinking more about the complexities involved in cycle-accurate accounting for service domains. For reference purposes (if we don't solve the problem now, perhaps someone else will in the future), here are the possible approaches I've come up with so far. Does anyone have other approaches to add to the list?
1. Cycle-accurate accounting
A. Ensure each service domain only performs work on behalf of a single
client (a one-to-one mapping), and charge the client for the service domain's consumption.
B. Ensure a service domain performs exactly the same amount of work for
each client, and charge the client based on the number of requests it generates.
C. Ensure each intradomain/OS-oriented protection mechanism [threads,
processes] only performs work on behalf of a single client, as in 1A.
D. For each thread/process that multiplexes its time among several
clients, ensure that it identifies to the accounting/charging mechanism on which client's behalf it is performing the work. This could be done by, for example, using system calls to explicitly affiliate and later disassociate with a particular domid.
E. [Resource containers, Banga99.] For each thread/process that
multiplexes its time among several tasks (such as incoming packets, where each packet represents a task), ensure that it identifies to the accounting mechanism on which task it is currently operating. Later, once a task is associated with the appropriate source or destination client, the charging mechanism applies the credits consumed by the task to the client.
2. Near-accurate accounting
A. Measure a priori the average resources consumed per request (or per
IPC), and charge the client based on the number of requests it generates.
B. [Cherkasova05.] Assign a proportional allocation of a service
domain's resource consumption to clients, based on the number of requests (or IPCs) generated by each client.
C. Assign weights to each request (or IPC) in 2B, to modify the
assignment based on additional knowledge (such as the rate or frequency of requests, the magnitude of the IPC, or the [non]uniformity of a series of IPCs from the client).
At first glance the approach that makes the most sense is 1E, except that it would seemingly require substantial modifications to Linux and any user-level software in the service domain. But maybe there's a way to leverage something like SELinux? For example, by treating the flow of resources through a system the same way SELinux treats information flows.
JLG