Skip to contentSkip to conversation

blkfront resource use

DISCUSSION Jan Beulich 2 participants 5 messages Feb 6, 2017 – Feb 7, 2017

lore
Share & tools
lore
#0 lore raw

Konrad, Roger,

we've recently had a report of stuck I/O (with slightly over a hundred frontend instances in a single guest), which turned out to be a simple lack of configured grants on the system. This raises two questions:

1) Shouldn't blkfront cope with this situation, by throttling I/O (but not getting stuck), perhaps by forcing requests to be split (or splitting them itself) if gnttab_alloc_grant_references() continues to fail over a measurable time period?

2) Isn't the current grant hunger of blkfront a little extreme? An instance with all defaults can consume 1k grants (32 segs times 32 reqs), but the scaling with ring size, queue count, and number of segs can easily get this to 64k or more. A default configured host, however, allows only for 128k grants (256 frames each holding 512 entries). Interestingly I've found
https://groups.google.com/forum/#!topic/linux.kernel/N6Q171xkIkM
when looking around - is there a reason this or something similar never made it into the driver? Without such adjustment a single spike in I/O can lead to a significant amount of grants to be "lost" in the queue of a single frontend instance.

Thanks, Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw
Quoted 10 lines · Jan Beulich

Konrad, Roger,

we've recently had a report of stuck I/O (with slightly over a hundred frontend instances in a single guest), which turned out to be a simple lack of configured grants on the system. This raises two questions:

1) Shouldn't blkfront cope with this situation, by throttling I/O (but not getting stuck), perhaps by forcing requests to be split (or splitting them itself) if gnttab_alloc_grant_references() continues to fail over a measurable time period?

Right, this was more problematic to implement before, but now that ARM introduced the code to split bios in blkfront, it shouldn't be that hard to split a bio into smaller ones if not enough grants can be allocated for the whole request.

Quoted 4 lines

2) Isn't the current grant hunger of blkfront a little extreme? An instance with all defaults can consume 1k grants (32 segs times 32 reqs), but the scaling with ring size, queue count, and number of segs can easily get this to 64k or more. A default configured

If blkback is using the default values, a single frontend should only use up to 1056 persistent grants (see max_persistent_grants/xen_blkif_max_pgrants) per queue. TBH, I didn't really like the change to account persistent grants per-queue instead of globally [0], because it makes it harder to impose limits on grant utilization.

Quoted 7 lines

host, however, allows only for 128k grants (256 frames each holding 512 entries). Interestingly I've found
https://groups.google.com/forum/#!topic/linux.kernel/N6Q171xkIkM
when looking around - is there a reason this or something similar never made it into the driver? Without such adjustment a single spike in I/O can lead to a significant amount of grants to be "lost" in the queue of a single frontend instance.

IIRC we didn't go for that solution and instead implemented a limit in blkback that can be set by the system administrator. But yes, it is still possible for a single blkfront instance to use a huge amount of grants, although only temporarily. When the IO spike is done (ie: the bio is done) blkfront should release the grants. If this is a system doing a huge amount of IO the default amount of grant tables pages should probably be increased.

Roger.

[0] https://github.com/torvalds/linux/commit/73716df7da4f60dd2d59a9302227d0394f1b8fcc

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 07.02.17 at 14:59, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich

Interestingly I've found
https://groups.google.com/forum/#!topic/linux.kernel/N6Q171xkIkM
when looking around - is there a reason this or something similar never made it into the driver? Without such adjustment a single spike in I/O can lead to a significant amount of grants to be "lost" in the queue of a single frontend instance.

Quoted 6 lines

IIRC we didn't go for that solution and instead implemented a limit in blkback that can be set by the system administrator. But yes, it is still possible for a single blkfront instance to use a huge amount of grants, although only temporarily. When the IO spike is done (ie: the bio is done) blkfront should release the grants. If this is a system doing a huge amount of IO the default amount of grant tables pages should probably be increased.

What would enforce that releasing? The driver itself doesn't appear to actively do anything here. Is that because the backend would limit the number of grants it keeps mapped (which the frontend then notices, releasing the grants)?

In the end, any number of grants not used over an extended periods of time are a waste of resources. Once again, the situation all this came up with was a guest with over a hundred block devices. If for every one of them the driver keeps meaningful amount of grants in its internal queues, there could (in the default config) be over 100k grants no-one can make use of. In the worst case even splitting requests may then not help, when enough grants aren't available for I/O of just a single sector.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 16 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 07.02.17 at 14:59, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich

Interestingly I've found
https://groups.google.com/forum/#!topic/linux.kernel/N6Q171xkIkM
when looking around - is there a reason this or something similar never made it into the driver? Without such adjustment a single spike in I/O can lead to a significant amount of grants to be "lost" in the queue of a single frontend instance.

Quoted 6 lines

IIRC we didn't go for that solution and instead implemented a limit in blkback that can be set by the system administrator. But yes, it is still possible for a single blkfront instance to use a huge amount of grants, although only temporarily. When the IO spike is done (ie: the bio is done) blkfront should release the grants. If this is a system doing a huge amount of IO the default amount of grant tables pages should probably be increased.

Quoted 4 lines

What would enforce that releasing? The driver itself doesn't appear to actively do anything here. Is that because the backend would limit the number of grants it keeps mapped (which the frontend then notices, releasing the grants)?

Yes, see blkif_completion in blkfront (the call to gnttab_query_foreign_access).

Quoted 8 lines

In the end, any number of grants not used over an extended periods of time are a waste of resources. Once again, the situation all this came up with was a guest with over a hundred block devices. If for every one of them the driver keeps meaningful amount of grants in its internal queues, there could (in the default config) be over 100k grants no-one can make use of. In the worst case even splitting requests may then not help, when enough grants aren't available for I/O of just a single sector.

I agree. The best way to solve that AFAIK would be to keep a time stamp of when a grant was last used, and have a threshold (let's say 5s), if the grant has not been used for that threshold it should be unmaped by blkback. blkfront should also have a periodic task that scans the list of grants and releases those no longer mapped by blkback.

Or maybe we should just disable persistent grants by default, by setting xen_blkif_max_pgrants = 0. This feature doesn't scale well, and interacts badly with other things (like indirect descriptors). The amount of code required to maintain this feature in a sane state is getting quite big.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 07.02.17 at 16:24, <[email protected]> wrote:

Or maybe we should just disable persistent grants by default, by setting xen_blkif_max_pgrants = 0. This feature doesn't scale well, and interacts badly with other things (like indirect descriptors). The amount of code required to maintain this feature in a sane state is getting quite big.

This sounds very reasonable. In fact I've been surprised that one can't even disable it in the frontend; I had to create a patch to add a respective command line option.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel