Skip to content

Commit

Permalink
hv_balloon: simplify math in alloc_balloon_pages()
Browse files Browse the repository at this point in the history
'alloc_unit' in alloc_balloon_pages() is either '512' for 2M allocations or
'1' for 4k allocations. So

1 << get_order(alloc_unit << PAGE_SHIFT)

equals to 'alloc_unit' and the for loop basically sets all them offline.
Simplify the math to improve the readability.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Link: https://lore.kernel.org/r/20201202161245.2406143-2-vkuznets@redhat.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
  • Loading branch information
Vitaly Kuznetsov authored and Wei Liu committed Dec 13, 2020
1 parent 5c641fe commit 7f3f227
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hv/hv_balloon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ static unsigned int alloc_balloon_pages(struct hv_dynmem_device *dm,
split_page(pg, get_order(alloc_unit << PAGE_SHIFT));

/* mark all pages offline */
for (j = 0; j < (1 << get_order(alloc_unit << PAGE_SHIFT)); j++)
for (j = 0; j < alloc_unit; j++)
__SetPageOffline(pg + j);

bl_resp->range_count++;
Expand Down

0 comments on commit 7f3f227

Please sign in to comment.