aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hv
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2015-03-31 14:16:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-04-03 10:20:12 -0400
commitba0c444153889a9b672974d85a4a57a8eeb49fe3 (patch)
treea00bd2647a8943eabf0c136b249f869f437b3b79 /drivers/hv
parent6a84d63d22a0ac79ab422b69ef2b4d75002c5641 (diff)
Drivers: hv: hv_balloon: correctly handle val.freeram<num_pages case
'Drivers: hv: hv_balloon: refuse to balloon below the floor' fix does not correctly handle the case when val.freeram < num_pages as val.freeram is __kernel_ulong_t and the 'val.freeram - num_pages' value will be a huge positive value instead of being negative. Usually host doesn't ask us to balloon more than val.freeram but in case he have a memory hog started after we post the last pressure report we can get into troubles. Suggested-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv')
-rw-r--r--drivers/hv/hv_balloon.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index 74312c88534a..4052ad8255fa 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1155,7 +1155,7 @@ static void balloon_up(struct work_struct *dummy)
1155 floor = compute_balloon_floor(); 1155 floor = compute_balloon_floor();
1156 1156
1157 /* Refuse to balloon below the floor, keep the 2M granularity. */ 1157 /* Refuse to balloon below the floor, keep the 2M granularity. */
1158 if (val.freeram - num_pages < floor) { 1158 if (val.freeram < num_pages || val.freeram - num_pages < floor) {
1159 num_pages = val.freeram > floor ? (val.freeram - floor) : 0; 1159 num_pages = val.freeram > floor ? (val.freeram - floor) : 0;
1160 num_pages -= num_pages % PAGES_IN_2M; 1160 num_pages -= num_pages % PAGES_IN_2M;
1161 } 1161 }