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 9BFA63D6478 for ; Mon, 11 May 2026 08:55:06 +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=1778489708; cv=none; b=ZJQEkWkA58ctpJJ+bhHSdW7U1Qxuw2RsnqjmlwznhiX4JWDe5fGG0i3ClCWhooqwu0k5uFRsZ1rqCmk8MjUznhdtJZUO+exinad0B9Gs+6g2WNzrJA0nl2hk30GWUZ90ocmu3hxnY/+M5jcpLRCV2C2GfSenWK4eYruDz/hwqhY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778489708; c=relaxed/simple; bh=jg72mm9srvK1uE2wmvtubyBWSeDnP4AXuR+h0vGBnIo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WjD78dFkWkYxg/DRraBTpxeeryg5JegFwap6JNbAZXT7AAvt6T5ZbS/bjmnoRmit0eaJgrUl3nGTTP8fkX/KAN5gOVQxAFrc35tpR1LETLy6jW1ZhiH8fWe4RdyEXtwAxKyIbREs5lxrjmdZ7CrAf55n/fovOvKFwU1UPTNov+Y= 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=eZlLMF5D; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=tamcebPb; 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="eZlLMF5D"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="tamcebPb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778489705; 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=huIB05uLC0/aRI1yhZqtcpv3ok57gc+RgGl8EPTE8A0=; b=eZlLMF5D0QS65QdwP0wIt1xinzAYW4NaJgp+5JtNVeC2kVLWrwDCesYVJ12prr0xNSRyT/ D2Knjg9Q48HLSYV4U6RM/Zuw04VBRHnUy82SMUKunPFWLzk7NPC9oV2XK96DL621ADWKi2 WdEtd98aRXbaPIwjbW3qvq/klIzor1s= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-692-Jou8-71fMoyJLgyFbKU00A-1; Mon, 11 May 2026 04:55:04 -0400 X-MC-Unique: Jou8-71fMoyJLgyFbKU00A-1 X-Mimecast-MFC-AGG-ID: Jou8-71fMoyJLgyFbKU00A_1778489703 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-488c0120047so24122955e9.0 for ; Mon, 11 May 2026 01:55:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778489703; x=1779094503; 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=huIB05uLC0/aRI1yhZqtcpv3ok57gc+RgGl8EPTE8A0=; b=tamcebPbV0RdQ00re3q7tMTBegEPkNg1Q+NTM49/4sUSAifQUnF2IQzD/TC7mnaWzp W6507SrHJPdSNhpkwg9Cq5i7on0s9IKfOd4NfULfQRpVzNqvpWHfThDpCxp90p7Jwex4 BdXyY0U4It5WFJ/ucE+B3f9GGssL3A66E8zAJsPjZo0e5ZSlZ4y2iyfsen2cDLNC2z0l FyZg+EHd6PCFGKNmTRQW6496HXehVDujlj0RUxWldh/tumHHwhoGy/KCLtG9x4K4ccar 3CiB8RoyyitQcP3B2wsSHTFoxOR016jfZa0t/FysbwWdgKUjGKhQtx0HCjZj3+6abYrz fhdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778489703; x=1779094503; 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=huIB05uLC0/aRI1yhZqtcpv3ok57gc+RgGl8EPTE8A0=; b=siyimlNmwrkqbzGAjXcd8TYuq20Eu/dty6FXj89FEIzOZftGLKZSbUHujmCMlOAa3D ZgOAPIE5MYOYZxXChcHQrvFQ+GGFQ77Ugn8eoOk/7oLYKrMFD63+B8HJMfVOhx6zinbm frKrasRP+cgJU8SRUZniZnBAWES+uorIxeJK7906NJ2vFV3b0e7GhA2cavJrD0cX8/Rt E7t0rZaQPmmsBdiisBa1ZMZxvmX0dIUB/F0xahvrA3s2qp13NBsCr1jWr+Ia05obURfm CZ4oVMa3HAGNNyKop5QtvWwjGAPz0O0GmwPbm/OA1YiedsZVxYYE4q1vGlMUczXYhrIE gyHA== X-Gm-Message-State: AOJu0Yyci5+ITiWzRhDvuE/LWiYpz64Sj1SAXYaBEUbIvVjNDL3O+c66 ZSMZTv9+KVbGiOZ1er3nF/8xvfRow+CP9a1BdDoTaUh8rY1L9wDznfMZwcm7Y/5Tknq/Xay4tZl ZpgXM3Xn/5DK5vUvl/45ojp5YmlYoYuUB3YaGggH9XYbu5D5mZeQjzQYmCcC7HASlfh++wYhX9W lSbXEkZfW3ynjXQ4r/7zfMjKMoTprGUtlGfE9LSYFCaljn0g== X-Gm-Gg: Acq92OE8ss3fV9egFALmjqxAwVw3lstBehsFkjAhRJDdQrnSRRLn5ysuh/o6PAwZco+ Dv0AWi2ktRS0+XEShVPYSNBMgf7jGbTpwsr28XYLHwvXMXpSpI+P4Rvil77J5K86U+JTxlYY7ay zpBCVeVCU1lV79h47wzQ8XNAtuqS2PCLBtfjZKIc2a7kzHwOF4HuRdW9En9SARj8htaHUIzNs4z QqpGTEHwlCnNbHlSrUGrwFsHNbB6VAFKgzYpj8wzrGBCNPpIBHL0lPI0m98zZ5HnttPqcrIhVqp iVsfW8iaQcBtHApJlzAQQm8EHw3rYcc2pKv2A2dS4NWMwyLUoVqulZQ6kZAmBvTSoQvw2g/xWyL sE4KJhHQV6uA5dgYvUGdCaE5J38aQzTHeDAet0Jsn4QSoiJtGqpg= X-Received: by 2002:a05:600c:8115:b0:48a:53ea:1408 with SMTP id 5b1f17b1804b1-48e51e1804amr355371575e9.8.1778489702757; Mon, 11 May 2026 01:55:02 -0700 (PDT) X-Received: by 2002:a05:600c:8115:b0:48a:53ea:1408 with SMTP id 5b1f17b1804b1-48e51e1804amr355370355e9.8.1778489701969; Mon, 11 May 2026 01:55:01 -0700 (PDT) Received: from redhat.com (IGLD-80-230-48-7.inter.net.il. [80.230.48.7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e702ec599sm154989305e9.11.2026.05.11.01.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 01:55:01 -0700 (PDT) Date: Mon, 11 May 2026 04:54:57 -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 v6 17/30] mm: page_alloc: propagate PageReported flag across buddy splits Message-ID: <6d98a35c94fa44b550afa66923c620511e2826f0.1778488966.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.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent When a reported free page is split via expand() to satisfy a smaller allocation, the sub-pages placed back on the free lists lose the PageReported flag. This means they will be unnecessarily re-reported to the hypervisor in the next reporting cycle, wasting work. Propagate the PageReported flag to sub-pages during expand(), both in page_del_and_expand() and try_to_claim_block(), so that they are recognized as already-reported. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 --- mm/page_alloc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 842f5080d728..76f39dd026ff 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1699,7 +1699,7 @@ struct page *__pageblock_pfn_to_page(unsigned long start_pfn, * -- nyc */ static inline unsigned int expand(struct zone *zone, struct page *page, int low, - int high, int migratetype) + int high, int migratetype, bool reported) { unsigned int size = 1 << high; unsigned int nr_added = 0; @@ -1721,6 +1721,15 @@ static inline unsigned int expand(struct zone *zone, struct page *page, int low, __add_to_free_list(&page[size], zone, high, migratetype, false); set_buddy_order(&page[size], high); nr_added += size; + + /* + * The parent page has been reported to the host. The + * sub-pages are part of the same reported block, so mark + * them reported too. This avoids re-reporting pages that + * the host already knows about. + */ + if (reported) + __SetPageReported(&page[size]); } return nr_added; @@ -1731,9 +1740,10 @@ static __always_inline void page_del_and_expand(struct zone *zone, int high, int migratetype) { int nr_pages = 1 << high; + bool was_reported = page_reported(page); __del_page_from_free_list(page, zone, high, migratetype); - nr_pages -= expand(zone, page, low, high, migratetype); + nr_pages -= expand(zone, page, low, high, migratetype, was_reported); account_freepages(zone, -nr_pages, migratetype); } @@ -2300,10 +2310,12 @@ try_to_claim_block(struct zone *zone, struct page *page, /* Take ownership for orders >= pageblock_order */ if (current_order >= pageblock_order) { unsigned int nr_added; + bool was_reported = page_reported(page); del_page_from_free_list(page, zone, current_order, block_type); change_pageblock_range(page, current_order, start_type); - nr_added = expand(zone, page, order, current_order, start_type); + nr_added = expand(zone, page, order, current_order, start_type, + was_reported); account_freepages(zone, nr_added, start_type); return page; } -- MST