From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 569AD1E832A; Wed, 11 Feb 2026 20:22:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770841331; cv=none; b=QR4fOR99Z8Z2B+JHwGhtzvhU3JLLHO7/MqeBG9ondeQ6+TKye5k4v+JCY/5uVU587vzL4MMPvt5nHucejNFfqjy5kYZxUDD0YG2n7gZ6A+/PhVhchi26FUUw/OEDBZLbbrwi5iN1M6QoLaaCOza4V0JE/QMyMmdmPxx9ml5qBuY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770841331; c=relaxed/simple; bh=Nryt9yR8IWQszMc/xT3oiDaSlzo8zN5v512alL9SgEw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cSLYCeYJ075mHbOgaZuAeZ4S7ReUp/ZeoTBJ/cPR2YGTk1YypCXjPJA9ZhwtyPGVZYkY61HbcQDKsoiOpK/lVOPcw5+Vj7EMx8l4QYFG9dkYwZ8jM+JoDZaLv0K3TE97/QXioi7FkvGMa4bg/zgZRRDHRVM7Qwa4vm/i3cF9IAs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BJTIo0Vy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BJTIo0Vy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70F98C4CEF7; Wed, 11 Feb 2026 20:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770841331; bh=Nryt9yR8IWQszMc/xT3oiDaSlzo8zN5v512alL9SgEw=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BJTIo0VyYEGQzEBJ0QNnoAG4V6AlsdBwAS2dno3lc6h6LDXHiTWbvnCNHF1k3X8wL lMpRp7cfUX3XKQObnOhtnWFSCrFHx09N8Lr/fZSwaTmwld0xW8TW1GEpYtU2WYqoNJ H2ncR7NZLIcTD8ihzE3NEPtv/QaC43i1mjhk9md5rxYqy73UwoCNFM5NOSwbbBEmnj 5aaYQE+yxX8U1ZpV+BLyFTaQIgR+R0elcXgKeI1mOPoHIbSljuxt4nTe9hXLDykjek mTr3aWSBgg3eXSPppHjRp/iZWZ+twYYHLKvkdkkgs69gniz1ZtNrNSb8gYTquHXmHA MjrxeTZJ/YNsQ== Message-ID: <7ace0c7b-6a3d-48c4-94ee-de5c91af02c7@kernel.org> Date: Wed, 11 Feb 2026 21:22:05 +0100 Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] virtio_balloon: Support wait on ACK for hinting To: "Thomson, Jack" , mst@redhat.com, jasowang@redhat.com Cc: xuanzhuo@linux.alibaba.com, eperezma@redhat.com, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, kalyazin@amazon.co.uk, xmarcalx@amazon.co.uk, jackabt@amazon.com References: <20260119154236.39412-1-jackabt.amazon@gmail.com> <6c3f8061-302e-40c1-829b-2f8555bee70c@kernel.org> From: "David Hildenbrand (Arm)" Content-Language: en-US Autocrypt: addr=david@kernel.org; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KM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7DoMAEQEAAcLBfAQYAQgAJgIbDBYhBBvZyq1zXEw6Rg38yk3e EPcA/4NaBQJonNqrBQkmWAihAAoJEE3eEPcA/4NaKtMQALAJ8PzprBEXbXcEXwDKQu+P/vts IfUb1UNMfMV76BicGa5NCZnJNQASDP/+bFg6O3gx5NbhHHPeaWz/VxlOmYHokHodOvtL0WCC 8A5PEP8tOk6029Z+J+xUcMrJClNVFpzVvOpb1lCbhjwAV465Hy+NUSbbUiRxdzNQtLtgZzOV Zw7jxUCs4UUZLQTCuBpFgb15bBxYZ/BL9MbzxPxvfUQIPbnzQMcqtpUs21CMK2PdfCh5c4gS sDci6D5/ZIBw94UQWmGpM/O1ilGXde2ZzzGYl64glmccD8e87OnEgKnH3FbnJnT4iJchtSvx yJNi1+t0+qDti4m88+/9IuPqCKb6Stl+s2dnLtJNrjXBGJtsQG/sRpqsJz5x1/2nPJSRMsx9 5YfqbdrJSOFXDzZ8/r82HgQEtUvlSXNaXCa95ez0UkOG7+bDm2b3s0XahBQeLVCH0mw3RAQg r7xDAYKIrAwfHHmMTnBQDPJwVqxJjVNr7yBic4yfzVWGCGNE4DnOW0vcIeoyhy9vnIa3w1uZ 3iyY2Nsd7JxfKu1PRhCGwXzRw5TlfEsoRI7V9A8isUCoqE2Dzh3FvYHVeX4Us+bRL/oqareJ CIFqgYMyvHj7Q06kTKmauOe4Nf0l0qEkIuIzfoLJ3qr5UyXc2hLtWyT9Ir+lYlX9efqh7mOY qIws/H2t In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 1/19/26 17:30, Thomson, Jack wrote: > > > On 19/01/2026 3:50 pm, David Hildenbrand (Red Hat) wrote: >> On 1/19/26 16:42, Jack Thomson wrote: >>> From: Jack Thomson >>> >>> This RFC patch adds a new virtio feature for the virtio-balloon driver >>> during free page hinting, which will wait on device ack before >>> committing the range to the free_page_list. The reason for the change is >>> it allows the device to modify this range without it being reclaimed >>> from the free_page_list before the ack is sent. As expected, testing >>> shows this adds overhead to the hinting run duration, increasing it by >>> ~30% with our Firecracker setup. Currently free page hinting is used >>> mainly for live migration, but this would open it up for a new use-case. >>> >>> We would like to leverage this with MADV_DONTNEED to reduce RSS of a >>> guest. We'd like to use hinting because of the flexibility of control it >>> brings compared to reporting, allowing memory to be reclaimed in >>> deterministic periods. >> >> Can you elaborate in more detail why you don't simply use reporting, >> like QEMU? > > Ideally we'd like to use hinting as the API allows us to control when > this reclamation takes place so as not to impact active VMs. For example > if we know a VM is idle we can reclaim memory but also cancel the > reclamation quickly if the VM receives new work (something we can't do > quickly with the traditional balloon.) > >> Could you instead see optimizations being done to reporting that could >> make it fly for your use case? > > One thing that I considered was having reporting running but skip > reported ranges during active times. But this may lead to missing > reclamation opportunities. We could implement a pause+continue option for free-page-reporting option. So the device could tell the VM to pause reporting and later to restart reporting. > >> >> Hinting is a rather special case thing only used for reducing VM >> migration time in QEMU AFAIR. >> > > Yeah, its API allowing direct control was what interested us. With this > extension it made a great pairing just needed the synchronisation to > make it safe. Sorry for getting back to you only now. So, right now the thing is that hinted pages can get reused by the VM any time. The hypervisor must detect if that happened and not discard the pages in that case. While that works for live migration with bitmap dirty tracking (and is a bit confusing ...), it doesn't work when you want to MADV_DONTNEED that memory, because it could be the hypervisor issues MADV_DONTNEED just after the VM reused the memory. So you are proposing to let the VM wait for the ack before possibly reusing the pages. One thing to note is that free page hinting in Linux allocates memory through alloc_pages(VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG, VIRTIO_BALLOON_HINT_BLOCK_ORDER); Meaning a) Limited to MAX_ORDER chunks (e.g., 4MB on x86). This is even bigger than the free-page-reporting granularity (pageblock order, 2MB on x86) b) Cannot free memory on ZONE_MOVABLE or CMA in the VM (as these are unmovable allocations) So it's a bit suboptimal. Also, in contrast to free-page-reporting, these pages are not going to get reused unless we run into the shrinker, which is a bit suboptimal as well. Free-page-reporting is a lot more optimized for that, as it just returns reported pages back to the buddy immediately. So if possible, I would suggest instead to extend free-page-reporting. -- Cheers, David