From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 F404A3B777B for ; Mon, 8 Jun 2026 08:40:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780908059; cv=none; b=jSuJL2q/soc1a0L8iL9T1O+0+3BdWhNnSh8/z9Q5XT8E3vkztSAKoQ3z0hvYWPiRS5iUsLo2vxK8qAzmX/pfz2jqI0EEkuaNucLaF6MGu+bNlsYeUDBJ3pTxdhn0qtJgRrj+CfSP7wYGPtXXzS4Cfuo9X5qBFwmLIMAKMYS/+gA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780908059; c=relaxed/simple; bh=vnQVlmpg+g0un4bccRkR6WRPQgTaTQW+RONtjX7TAow=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EwhwZDdhyeYOLKrGMubQK7SVwAfxK1vaQhbwRwH/lxCVSbxUtPRZ59hGoACf2joD+JtqXEW1T35Ihjaaf1IG/4AzIU9Z1w4+e6ox8h4laHe4HIghpTy2+Taep9h1qwm58Ph93+MQVlV8rmZ1Ex8nTwUGCx/ykH0Pk1XJGyAfblA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IDcIaJ83; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=rJsOfKXz; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IDcIaJ83"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="rJsOfKXz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780908057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=P4H6i1o8NtKwI7+T7msfk1MScFiiY05veUMkpUANhzw=; b=IDcIaJ8368xWVvAknCr2GqCG7xe6Ev1IYnJ+EuM0InyxW6uAoto/CFmww3KWjliaZrYjT3 T2TyJmRSDI9OK+m9h5i0BvfSc9EcCVyhOK5aDbQPm35Ww1WHDoAyVTjB0r50+dp7m2yIEn Jy0G4lEF3xHey1F/dWownPUQJAYLmtY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-Djb2YBe9NHKaj_HC4EUaxw-1; Mon, 08 Jun 2026 04:40:56 -0400 X-MC-Unique: Djb2YBe9NHKaj_HC4EUaxw-1 X-Mimecast-MFC-AGG-ID: Djb2YBe9NHKaj_HC4EUaxw_1780908055 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-46011aa5000so1700562f8f.3 for ; Mon, 08 Jun 2026 01:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780908055; x=1781512855; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=P4H6i1o8NtKwI7+T7msfk1MScFiiY05veUMkpUANhzw=; b=rJsOfKXzS2M4z5VaM7YrxG0kZaxelic6QF1Bd2X5/aVwekpjbJCfV0SLAbWj7tx97Y T5d3htQYslwytjGwZhxRPtQiwha2pTYuMCa2llz9ptKxURcfaYuonKjz9hNqZUYq9m/U KuMMko6iRlXACJy1/r8bTU4BV1JBTh+zgGJEDn1OFWPJ3Ya4zgopHIql23lXdb9IFiM3 MUrYFeZhVkq4+3VqQG3UnH4LOPzy4dIHEuCVPnHdJacufVsNlyjfWmLmIcPXYySrHJ50 7rYCzuZc8sJkFq2VzWnqkabS3VQ/GbEJODnUe0AsbJUXWs7e0PRE7gvZvbS/ucYSKwfZ 3mIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780908055; x=1781512855; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P4H6i1o8NtKwI7+T7msfk1MScFiiY05veUMkpUANhzw=; b=REq6NvnPAkVplhOuxfR4jHCI1EoWDIR7zTmIw2+kryHocdHOlhFyMLGMnIeoYeylBQ mBkL+HBXpeulZiqQDj6ZBPiAxY82BK+ZU8JjF8Y5Ke+IENoey/5I5+uyVI+OMMi/9GYq e1As+mloM2e84sIda0gFaONoSk2G/ZaupiTABmuEs4jKAVs13a38Mkzkgrjr7ahdJErL ix2S4XMzOJEa7bU7WsMI1QyJ9QfkTda0QEb1yg/2M5duxMLRVsRdp1xFB8i0YDvnWAx+ AodsgELqjfJ9gubKO5IQxU3/0mmu/krKELa4X1lV7SySje4r6PVdqRsuOf7xAYaNWIjt u0pQ== X-Gm-Message-State: AOJu0YyeBqRwAC1Fh5+os/jUy1vIfK/pm058uvKk5hZxOuMWHlQa08f8 XauFICmEnBTTnmi/DjMU6FbJLUSTJrBwMC4ymWjxDvQdhOSAF8UM+37JUX1NGHXhaPnHlws3fl2 Xp+oJzEyz4AdSmB0/abgeLapdofQpHpFjM4uUwW/OoeYoNH2nCxDPmhNkligp65Tw9wHfYOBBrl 4guIPuJDjbFPCKjg9vLtEoinTIFwfjlpqn1b3/PfJV+4Q= X-Gm-Gg: Acq92OG5DiQHaY7KMvKYFKxj1sfMIKPkLS8ctrjY0dZy/FEGIO9+N+8OQLg7SEi/AjP /x3rb4PrVlam+E0HVzakD3XFUlZih9wrwmDqD0OA2O6xAQgTdWkT2lZfnjhDBRPrl9DUNrxrfy/ 1C413QD6qWLpVxI18sZ9WRyB7FBLExh12fVqNpB0z1UF3Nf15NyjE7fmmRKLI2jCA4niVBML5Gs TvGr4sg6wxsh8S2jo5ReFihuoGolYNlVjsS/V2Mf7O9B6dhyLY0KVyM5E4cAGDaU2Nf5lf5ChLE QciPlLo9aZTfAKrx6o3odX6Rm3Odq0Ju19EpvtaVmSPhzL/TcJedazTaQ4p3VM4vP6Z09y3t8qu vhXIWUwkny+H5Z1fDmycwLkc= X-Received: by 2002:a05:600c:c16f:b0:490:b8e6:be40 with SMTP id 5b1f17b1804b1-490c25fc0d5mr237785225e9.21.1780908054572; Mon, 08 Jun 2026 01:40:54 -0700 (PDT) X-Received: by 2002:a05:600c:c16f:b0:490:b8e6:be40 with SMTP id 5b1f17b1804b1-490c25fc0d5mr237784245e9.21.1780908053964; Mon, 08 Jun 2026 01:40:53 -0700 (PDT) Received: from redhat.com ([31.152.37.159]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490bc3b5b06sm343164275e9.3.2026.06.08.01.40.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 01:40:53 -0700 (PDT) Date: Mon, 8 Jun 2026 04:40:45 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , Muchun Song , Oscar Salvador , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Hugh Dickins , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Axel Rasmussen , Yuanchu Xie , Wei Xu , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , virtualization@lists.linux.dev, linux-mm@kvack.org, Andrea Arcangeli Subject: [PATCH v10 36/37] mm: balloon: use put_page_zeroed for zeroed balloon pages Message-ID: <619342ca2c01c60862fe49cd4a790d171cd65ef3.1780906288.git.mst@redhat.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.51.2.2891.g4157995a80.dirty X-Mutt-Fcc: =sent When a balloon page marked PageZeroed is freed during migration, use put_page_zeroed() to propagate the zeroed hint to the buddy allocator. Previously the hint was silently lost via plain put_page(). No page has PageZeroed set yet; the next patch (VIRTIO_BALLOON_F_DEVICE_INIT_ON_INFLATE) will set it on pages the host has zeroed during inflate. Note: during balloon migration, the migration core holds an extra reference, so put_page_zeroed() will not be the final put. The zeroed hint is lost in that case, which is acceptable: it is a best-effort optimization. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 --- mm/balloon.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/balloon.c b/mm/balloon.c index 96a8f1e20bc6..6c9dd8ab0c5d 100644 --- a/mm/balloon.c +++ b/mm/balloon.c @@ -324,7 +324,15 @@ static int balloon_page_migrate(struct page *newpage, struct page *page, balloon_page_finalize(page); spin_unlock_irqrestore(&balloon_pages_lock, flags); - put_page(page); + if (PageZeroed(page)) { + /* Atomic to serialize with memory_failure's + * TestSetPageHWPoison; not under zone->lock here. + */ + ClearPageZeroed(page); + put_page_zeroed(page); + } else { + put_page(page); + } return 0; } -- MST