]> xenbits.xensource.com Git - libvirt.git/commit
virNumaGetHugePageInfo: Return page_avail and page_free as ULL
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 23 Apr 2018 14:36:53 +0000 (16:36 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 24 Apr 2018 09:02:28 +0000 (11:02 +0200)
commit31daccf5a550e7ede35532004006b34ba5c5b92e
treed7bf96b5c9ea626e4d44e7397a543e685b9b6079
parentcce57265c42e630036ed4d292d6399cdee08fd78
virNumaGetHugePageInfo: Return page_avail and page_free as ULL

https://bugzilla.redhat.com/show_bug.cgi?id=1569678

On some large systems (with ~400GB of RAM) it is possible for
unsigned int to overflow in which case we report invalid number
of 4K pages pool size. Switch to unsigned long long.

We hit overflow in virNumaGetPages when doing:

    huge_page_sum += 1024 * page_size * page_avail;

because although 'huge_page_sum' is an unsigned long long, the
page_size and page_avail are both unsigned int, so the promotion
to unsigned long long doesn't happen until the sum has been
calculated, by which time we've already overflowed.

Turning page_avail into a unsigned long long is not strictly
needed until we need ability to represent more than 2^32
4k pages, which equates to 16 TB of RAM. That's not
outside the realm of possibility, so makes sense that we
change it to unsigned long long to avoid future problems.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/capabilities.c
src/conf/capabilities.h
src/util/virhostmem.c
src/util/virnuma.c
src/util/virnuma.h
tests/virnumamock.c