On 03/13/2018 01:48 PM, Alberto Garcia wrote:
On Tue 13 Mar 2018 07:23:36 PM CET, Eric Blake wrote:
+                *refcount_cache_size =
+                    MIN(combined_cache_size, min_refcount_cache);

but here, if combined_cache_size is smaller than min_refcount_cache,

+                *l2_cache_size = combined_cache_size - *refcount_cache_size;

then l2_cache_size is set to a negative value.

No, it's set to 0.

If combined == 4k and min_refcount == 256, then

    refcount_cache_size = MIN(4k, 256k) // 4k
    l2_cache_size = 4k - 4k; // 0

Ah. Mental breakdown on my part in trying to compute (x - MIN()).

Then the caller ensures that it's always set to the minimum (as it did
with the previous code).

So the caller will use larger than the requested limits if the requested limits are too small, and we are okay with calculations resulting in 0 here. All right, thanks for stepping me through my error; you're good to go with:

Reviewed-by: Eric Blake <ebl...@redhat.com>

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to