Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 174433
b: refs/heads/master
c: bc2c030
h: refs/heads/master
i:
  174431: a30ade1
v: v3
  • Loading branch information
Ian Campbell authored and Jeremy Fitzhardinge committed Dec 4, 2009
1 parent 5092d80 commit 2c3e50e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3d65c9488cadd2f11bd4d60c7266e639ece5d0d6
refs/heads/master: bc2c0303226ec716854d3c208c7f84fe7aa35cd7
31 changes: 5 additions & 26 deletions trunk/drivers/xen/balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ struct balloon_stats {
/* We aim for 'current allocation' == 'target allocation'. */
unsigned long current_pages;
unsigned long target_pages;
/* We may hit the hard limit in Xen. If we do then we remember it. */
unsigned long hard_limit;
/*
* Drivers may alter the memory reservation independently, but they
* must inform the balloon driver so we avoid hitting the hard limit.
Expand Down Expand Up @@ -185,7 +183,7 @@ static void balloon_alarm(unsigned long unused)

static unsigned long current_target(void)
{
unsigned long target = min(balloon_stats.target_pages, balloon_stats.hard_limit);
unsigned long target = balloon_stats.target_pages;

target = min(target,
balloon_stats.current_pages +
Expand Down Expand Up @@ -221,23 +219,10 @@ static int increase_reservation(unsigned long nr_pages)
set_xen_guest_handle(reservation.extent_start, frame_list);
reservation.nr_extents = nr_pages;
rc = HYPERVISOR_memory_op(XENMEM_populate_physmap, &reservation);
if (rc < nr_pages) {
if (rc > 0) {
int ret;

/* We hit the Xen hard limit: reprobe. */
reservation.nr_extents = rc;
ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
&reservation);
BUG_ON(ret != rc);
}
if (rc >= 0)
balloon_stats.hard_limit = (balloon_stats.current_pages + rc -
balloon_stats.driver_pages);
if (rc < 0)
goto out;
}

for (i = 0; i < nr_pages; i++) {
for (i = 0; i < rc; i++) {
page = balloon_retrieve();
BUG_ON(page == NULL);

Expand All @@ -263,12 +248,12 @@ static int increase_reservation(unsigned long nr_pages)
__free_page(page);
}

balloon_stats.current_pages += nr_pages;
balloon_stats.current_pages += rc;

out:
spin_unlock_irqrestore(&balloon_lock, flags);

return 0;
return rc < 0 ? rc : rc != nr_pages;
}

static int decrease_reservation(unsigned long nr_pages)
Expand Down Expand Up @@ -369,7 +354,6 @@ static void balloon_process(struct work_struct *work)
static void balloon_set_new_target(unsigned long target)
{
/* No need for lock. Not read-modify-write updates. */
balloon_stats.hard_limit = ~0UL;
balloon_stats.target_pages = target;
schedule_work(&balloon_worker);
}
Expand Down Expand Up @@ -428,7 +412,6 @@ static int __init balloon_init(void)
balloon_stats.balloon_low = 0;
balloon_stats.balloon_high = 0;
balloon_stats.driver_pages = 0UL;
balloon_stats.hard_limit = ~0UL;

init_timer(&balloon_timer);
balloon_timer.data = 0;
Expand Down Expand Up @@ -473,9 +456,6 @@ module_exit(balloon_exit);
BALLOON_SHOW(current_kb, "%lu\n", PAGES2KB(balloon_stats.current_pages));
BALLOON_SHOW(low_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_low));
BALLOON_SHOW(high_kb, "%lu\n", PAGES2KB(balloon_stats.balloon_high));
BALLOON_SHOW(hard_limit_kb,
(balloon_stats.hard_limit!=~0UL) ? "%lu\n" : "???\n",
(balloon_stats.hard_limit!=~0UL) ? PAGES2KB(balloon_stats.hard_limit) : 0);
BALLOON_SHOW(driver_kb, "%lu\n", PAGES2KB(balloon_stats.driver_pages));

static ssize_t show_target_kb(struct sys_device *dev, struct sysdev_attribute *attr,
Expand Down Expand Up @@ -545,7 +525,6 @@ static struct attribute *balloon_info_attrs[] = {
&attr_current_kb.attr,
&attr_low_kb.attr,
&attr_high_kb.attr,
&attr_hard_limit_kb.attr,
&attr_driver_kb.attr,
NULL
};
Expand Down

0 comments on commit 2c3e50e

Please sign in to comment.