view drivers/md/dm-io.h @ 897:329ea0ccb344

balloon: try harder to balloon up under memory pressure.

Currently if the balloon driver is unable to increase the guest's
reservation it assumes the failure was due to reaching its full
allocation, gives up on the ballooning operation and records the limit
it reached as the "hard limit". The driver will not try again until
the target is set again (even to the same value).

However it is possible that ballooning has in fact failed due to
memory pressure in the host and therefore it is desirable to keep
attempting to reach the target in case memory becomes available. The
most likely scenario is that some guests are ballooning down while
others are ballooning up and therefore there is temporary memory
pressure while things stabilise. You would not expect a well behaved
toolstack to ask a domain to balloon to more than its allocation nor
would you expect it to deliberately over-commit memory by setting
balloon targets which exceed the total host memory.

This patch drops the concept of a hard limit and causes the balloon
driver to retry increasing the reservation on a timer in the same
manner as when decreasing the reservation.

Also if we partially succeed in increasing the reservation
(i.e. receive less pages than we asked for) then we may as well keep
those pages rather than returning them to Xen.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jun 05 14:01:20 2009 +0100 (2009-06-05)
parents 831230e53067
line source
1 /*
2 * Copyright (C) 2003 Sistina Software
3 *
4 * This file is released under the GPL.
5 */
7 #ifndef _DM_IO_H
8 #define _DM_IO_H
10 #include "dm.h"
12 struct io_region {
13 struct block_device *bdev;
14 sector_t sector;
15 sector_t count;
16 };
18 struct page_list {
19 struct page_list *next;
20 struct page *page;
21 };
24 /*
25 * 'error' is a bitset, with each bit indicating whether an error
26 * occurred doing io to the corresponding region.
27 */
28 typedef void (*io_notify_fn)(unsigned long error, void *context);
31 /*
32 * Before anyone uses the IO interface they should call
33 * dm_io_get(), specifying roughly how many pages they are
34 * expecting to perform io on concurrently.
35 *
36 * This function may block.
37 */
38 int dm_io_get(unsigned int num_pages);
39 void dm_io_put(unsigned int num_pages);
41 /*
42 * Synchronous IO.
43 *
44 * Please ensure that the rw flag in the next two functions is
45 * either READ or WRITE, ie. we don't take READA. Any
46 * regions with a zero count field will be ignored.
47 */
48 int dm_io_sync(unsigned int num_regions, struct io_region *where, int rw,
49 struct page_list *pl, unsigned int offset,
50 unsigned long *error_bits);
52 int dm_io_sync_bvec(unsigned int num_regions, struct io_region *where, int rw,
53 struct bio_vec *bvec, unsigned long *error_bits);
55 int dm_io_sync_vm(unsigned int num_regions, struct io_region *where, int rw,
56 void *data, unsigned long *error_bits);
58 /*
59 * Aynchronous IO.
60 *
61 * The 'where' array may be safely allocated on the stack since
62 * the function takes a copy.
63 */
64 int dm_io_async(unsigned int num_regions, struct io_region *where, int rw,
65 struct page_list *pl, unsigned int offset,
66 io_notify_fn fn, void *context);
68 int dm_io_async_bvec(unsigned int num_regions, struct io_region *where, int rw,
69 struct bio_vec *bvec, io_notify_fn fn, void *context);
71 int dm_io_async_vm(unsigned int num_regions, struct io_region *where, int rw,
72 void *data, io_notify_fn fn, void *context);
74 #endif