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.129.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 3826A274652 for ; Tue, 12 May 2026 21:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778619926; cv=none; b=Vr9Y/7oQ/dJoWe1086Xdi5tdL7F52UUZRQterdSrMyaouoCmgY+PDDZlD0Skgda98RDDd+ySBldGSz+EJtNdr9RFZ2+4ciOu6S0Zszet9CgffpCKxjWnrZ4BOcxHj80N++FTDHeTA4gDbi9wNLkYzc/pLAeDVRIaqo+LtqjiYx8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778619926; c=relaxed/simple; bh=bGzF3O3suJfDsEpMco/qz1u2W2qF7rZPHMyZKhViaaQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IudVKHH6CUtVqh8MYhVhRBa73d3EAg83rpUTX+vqH3QhtC+da4BaGmkcdjPeHFv6f66HCmhitOqhVCcF36yFfcrKnITHzGHFEJMb54V5KXl0XD2FjbFrTWZJnCp7kfYZSfIuApZogAFCDm3X5qL61gWkmjLRg6V3jfg71TirvDg= 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=F8WXXtXY; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=WQMC41jL; arc=none smtp.client-ip=170.10.129.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="F8WXXtXY"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="WQMC41jL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778619924; 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=Rtq/ad55zrZyrod+V9Nt+5t6fAHZwxPdckwVickks5c=; b=F8WXXtXYXMOr5y5In4tfZY928OdJSOS723gd9pBwfW8WoRnNIcPqb4mXHnBdxTOU3rj9WX Ga/LzSXqJcLg9aq1E1LIJ6ygaMupGkdO8fOMBINzuynfO0fhip97lwi4uPEUwbIzSIrlt8 ba4mB7mewFG8aZxkArZI3GMbqflDSno= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-0Y96dcDxMHydxGwkJV8nZw-1; Tue, 12 May 2026 17:05:23 -0400 X-MC-Unique: 0Y96dcDxMHydxGwkJV8nZw-1 X-Mimecast-MFC-AGG-ID: 0Y96dcDxMHydxGwkJV8nZw_1778619922 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-488d1b5bca0so29445965e9.2 for ; Tue, 12 May 2026 14:05:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778619921; x=1779224721; 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=Rtq/ad55zrZyrod+V9Nt+5t6fAHZwxPdckwVickks5c=; b=WQMC41jLJpZ0C0iKIJAN6zI3NbVnyVPPr1opabo/KZy4Rx6s39iU3Vd0vdilZkBJZ4 BjhpWUVJ6Se1oJxUoAvzPxGAwQh2v0rTJSEiXdcde3wRG7zOKeZuK3rWtYp/hK+nCvjy Swyb3E0l2k1GF0KctQe9eWKh/z44IdGRQOfGlsi+lGNRRuRftLn13/im3NqvahBSh7YL r+QjSoVL9HQAr2EY/tFcASXjykgkT9TWPeK7Yurckm9HbcKApIxVk7w9m4I4TCyRdEjc h8F5JehrPWsuysP0a6+XnZVyTQJJZoeX4dPEjVqlQQTtHBdMHnXsuZwMk87dySizeZGC HfSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778619921; x=1779224721; 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=Rtq/ad55zrZyrod+V9Nt+5t6fAHZwxPdckwVickks5c=; b=EucQyvmpUluIRe3OuBjhjDKRWt+2oXc129agMPhalTv5GPJq60eTMWAeIVGNuULVZo DqruajoJ5BQkFC/cjITqDLpVl3pZAYZZMzK+/5adWDQg8HBSCwpHRBk0pbPBvm1Zn2ab 7L+HF2iMcqv2Rdgect0tpkgszUv7CU0NtHUr+5LfLfUa+N1s4z5ecoPtvJH9fmQku15K UHYAiINWvqP5np9Bsf+fcWD1iF1I6xpjn405SW2DIu6jDl88i7A8R0h5Nj7Iy1xD4WzS 2f1j6ZwV3pBVR86CTdFD08G086qCTrEoWd6sGFNOJyj9CdjhWrHXoF1xVJu4FM+Kgb8t Kp2w== X-Gm-Message-State: AOJu0YxEt02NMGdN/rWFJ+Qxnn30OENX8Xg4X21yFwTfAy7snk7kRjR3 keA9yELQIxd4ZN+2WwMS7kIVHQMEKUKBGj+R7lNxEaPR02VlASFLr0obVvscTF6TapZpRy8WzbD sJyRTt2NUsMgX6JIS4cPAP+9cZ84xQByg0Wcg2DTHtsI14bdHGNnMqVPtfG/Yk+LNf/th+CIeob TkTlRrK7vm3AYYyQYFLHocRiUFhKgedWanOpZ1TnSrHLQ= X-Gm-Gg: Acq92OFbrdV6Hav/RYqE4BazPOTe/DMiSywXvlbFZVM4GqeZy4MlZ+gr3iGhFKvOVtC zgv5K1dftI9fXfShGM3AGpY8D0XULvzGw5Df5AV/Yh3q8HLOJI7tjVsZo/ZYK1AbRK9sbSi3Cxt ZmqcDUm5jRp5J8xr4dgdLm19l3dticCOEWllLKmDJDeYyHt4sF4rTLxs7fiM1wz41ZUW/HXX5dN QJsn0dv62FQgvDqefcEuTdSXWq+wSD882H6wUS1uVYwx4pxdIzsQCzS/0v4nNfiQJ5h9Q13UcKd B+K6r6T8vsAOi0mKDst1GME/zTRCJFQLlfd5+z2eskZIVZvETEiHKI6tOWx4GeelOCHc00l6ZVf MMozv/zmOGdVvDXQVisZ5ao+VLdiLFr/2fbjvWAQa X-Received: by 2002:a05:600c:848c:b0:489:e696:8362 with SMTP id 5b1f17b1804b1-48fc9a30a6amr5860865e9.13.1778619921494; Tue, 12 May 2026 14:05:21 -0700 (PDT) X-Received: by 2002:a05:600c:848c:b0:489:e696:8362 with SMTP id 5b1f17b1804b1-48fc9a30a6amr5860115e9.13.1778619920806; Tue, 12 May 2026 14:05:20 -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-48fc8d27667sm18044215e9.7.2026.05.12.14.05.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 14:05:20 -0700 (PDT) Date: Tue, 12 May 2026 17:05:16 -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 v7 02/31] mm: page_alloc: propagate PageReported flag across buddy splits Message-ID: 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. While I was unable to quantify the performance difference, it is an obvious waste, even if small. 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 227d58dc3de6..e40fd39acbd0 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); } @@ -2288,10 +2298,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