lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 18 Nov 2019 17:52:56 -0500
From:   "Michael S. Tsirkin" <mst@...hat.com>
To:     Khazhismel Kumykov <khazhy@...gle.com>
Cc:     jasowang@...hat.com, wei.w.wang@...el.com,
        linux-kernel@...r.kernel.org,
        virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH 1/2] virtio_balloon: fix pages_to_free calculation

On Mon, Nov 18, 2019 at 01:38:10PM -0800, Khazhismel Kumykov wrote:
> freed_pages was accumulating total freed pages, but was also subtracted
> on each iteration from pages_to_free, which could potentially result in
> attempting to free fewer pages than asked for. This change also makes
> both freed_pages and pages_to_free in terms of "balloon pages", where
> they were mismatched before.

And then patch 2/2 changes it back to both be regular pages.
Which is good, but why do we have to go back and forth
breaking then fixing it back?


> 
> Fixes: 71994620bb25 ("virtio_balloon: replace oom notifier with shrinker")
> Cc: Wei Wang <wei.w.wang@...el.com>
> Signed-off-by: Khazhismel Kumykov <khazhy@...gle.com>
> ---
>  drivers/virtio/virtio_balloon.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 226fbb995fb0..7cf9540a40b8 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -782,11 +782,8 @@ static unsigned long shrink_balloon_pages(struct virtio_balloon *vb,
>  	 * VIRTIO_BALLOON_ARRAY_PFNS_MAX balloon pages, so we call it
>  	 * multiple times to deflate pages till reaching pages_to_free.
>  	 */
> -	while (vb->num_pages && pages_to_free) {
> -		pages_freed += leak_balloon(vb, pages_to_free) /
> -					VIRTIO_BALLOON_PAGES_PER_PAGE;
> -		pages_to_free -= pages_freed;
> -	}
> +	while (vb->num_pages && pages_to_free > pages_freed)
> +		pages_freed += leak_balloon(vb, pages_to_free - pages_freed);
>  	update_balloon_size(vb);
>  
>  	return pages_freed;
> -- 
> 2.24.0.432.g9d3f5f5b63-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ