Skip to content

Commit

Permalink
xen/balloon: Clarify credit calculation
Browse files Browse the repository at this point in the history
Move credit calculation to current_target()
and rename it to current_credit().

Acked-by: Ian Campbell <[email protected]>
Acked-by: Daniel De Graaf <[email protected]>
Signed-off-by: Daniel Kiper <[email protected]>
Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
  • Loading branch information
dkiper authored and konradwilk committed Mar 30, 2011
1 parent 4dfe22f commit 83be7e5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/xen/balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static enum bp_state update_schedule(enum bp_state state)
return BP_EAGAIN;
}

static unsigned long current_target(void)
static long current_credit(void)
{
unsigned long target = balloon_stats.target_pages;

Expand All @@ -202,7 +202,7 @@ static unsigned long current_target(void)
balloon_stats.balloon_low +
balloon_stats.balloon_high);

return target;
return target - balloon_stats.current_pages;
}

static enum bp_state increase_reservation(unsigned long nr_pages)
Expand Down Expand Up @@ -337,7 +337,7 @@ static void balloon_process(struct work_struct *work)
mutex_lock(&balloon_mutex);

do {
credit = current_target() - balloon_stats.current_pages;
credit = current_credit();

if (credit > 0)
state = increase_reservation(credit);
Expand Down Expand Up @@ -420,7 +420,7 @@ void free_xenballooned_pages(int nr_pages, struct page** pages)
}

/* The balloon may be too large now. Shrink it if needed. */
if (current_target() != balloon_stats.current_pages)
if (current_credit())
schedule_delayed_work(&balloon_worker, 0);

mutex_unlock(&balloon_mutex);
Expand Down

0 comments on commit 83be7e5

Please sign in to comment.