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 C0DEB314B6E for ; Sun, 12 Apr 2026 22:50:46 +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=1776034251; cv=none; b=o/SY4vl+CDNMMXS9gS93gz4TyHl4ARdnZB6eXPdOn5lBuPImFmY1zKSpTKmNa4WuNCXfKiZUp6kMyN8URstblvpOuSJmHkVVVvEyL9CRr+qTFJvCqaJr0iXwIviGHMvWyXKfioXAnGUHNp7hb+MJa3AL259oko6ioXw9vVvl1qo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776034251; c=relaxed/simple; bh=1Xi6QJj55uFprY3+j41AxpGhuS0+qcgoEfdSGDN0Als=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TRIv+GOUgVYzYzt+9gXL4T74ZzLAyIOA2Fwd429ldae395i5VIzQctHmTDtEIOWCNX4jsViv+gMOTsw881nNLPwdwP/zL0n/ApMG5gDD7SLfLInV3/B/JOGjgKNdCZTnNpx9jyNXm6SScBD3Br7xU0ZU9yDWhMZAFiOPn86A2i0= 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=dkzMMe1A; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=DhN5To+T; 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="dkzMMe1A"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="DhN5To+T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776034245; 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=gWKRsIFuB+Hs22ZUHt8b4Lo3W4KNzkmERVB6NJaMrU4=; b=dkzMMe1AnBzhYkbq3aB+RawjIKRCscWy9oqegzEqTheQsJkG2U7le3wQ4GHtkznM9Lmoga fUr9w2QFsDxNsNMyBJNz8WXtQZf34F8NanpUHcDR4Wcg9NChIeFX0XqnjDTT0AtLAKbL5Y egANBNmMBYMZcyBBV2bhQvhH0OM59ac= 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-561-kcVTTWtgPQqK10xEZV3WVA-1; Sun, 12 Apr 2026 18:50:44 -0400 X-MC-Unique: kcVTTWtgPQqK10xEZV3WVA-1 X-Mimecast-MFC-AGG-ID: kcVTTWtgPQqK10xEZV3WVA_1776034244 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-43d7a5b9678so79827f8f.2 for ; Sun, 12 Apr 2026 15:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776034243; x=1776639043; 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=gWKRsIFuB+Hs22ZUHt8b4Lo3W4KNzkmERVB6NJaMrU4=; b=DhN5To+TIbLU0h9kQk/Q6dmvvDQ2A2uvZUoJAN7IbUQnZ0t92TALbt+2GB1uEhrMcJ eb4cQDRf/G5v9P2KR30Z53yZqHfkc6+x7mpUQp0LlGPJRgIdtogdJdPrgkG8CoBDuJQr /3MadAykbYRE/OIUwc4/VjiPw68aMtxdF+0BmlOeoiMEuGYalLqT5WToXWhoe+y3f/nK 9E3Iq7je5Iy+B18w878QbE+pNRuytjNp6nyt+GooBD8kJNQQ86Q5kGa/teoSGScxwqXg SnZh5ZbqMnrzoyQrxgpVoRmAf6xAumE18jNxubGW1l7/K1ZXO+M64DQKe3CwJemYGUsR gABQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776034243; x=1776639043; 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=gWKRsIFuB+Hs22ZUHt8b4Lo3W4KNzkmERVB6NJaMrU4=; b=ne7svghK9OJCBQKWTUVGeF6gCZ37XvO5vNa8xuZEKTLN9IAH0alrTm9VJJuQV9me/X aC0Snzk56IrzvjYsGck2/ErU8pRYEhiX51Eu3nF3W4nEQ3uw5lWwjkflCrFsqJ7Xx3wR GM4jbXGTfhVThRwRG2JcjMuPO84Skb3plWNC1Ap+acVnvrZ1vvtHvqHq1+VbnbjgXuaI PWEWzirWsv6BuPf8q3LN5P1ko3x+YIdX/toJTM7qU/KuUqpwVt/dZesoWg8iOAYQBzuC v/C8qAT7DArcvnvXP+4P0CBwdux6N3XM+qaYW6q5h697BwiedCPwkOFx/vFuQJFA+VYy q4Tw== X-Gm-Message-State: AOJu0YxX+pF6xnFOQAa5jy/VYSuayArYjvmWIESW+qiKJjm7pYPCQ9qb 53U1HPH329+MFLnpFtmWmwTiTqI3O/LIedc87YcjFDTD3Buf6eD+GzXH4e0pAeZNY9RfUK9eB+h HPgHQMnLXTCzFbK7LnBoH5v9ZB/1xNPmcZ+OEwjxHMByIudXhwczRRoVmgGVDx9Yt1Y3v4NubRC NM/gq8s1/dfQ/E4l2izq9jqr/rGcDn0oL1ssNCMs8YmHA= X-Gm-Gg: AeBDievKDy50s3V4iDVGKir8MA0Zy92Ji2uZsuiOcJARrMlEHXJAM792niEmW6QmK3t DWwkIY8uVb9yr0+OxFGjuT+WUg8FW22G+TDXBCT6XsXBaQMYrOtW3N9GqqDH6hVkGZbrC8QMm7G DjqUAjAOdzfC1mHf+ioa8rkNLsVRGjs3id+lE/vY64/6l0Sv+bvPW+mHY8seGV5XcXZd8fZxMRF I3LVrdKhnyMZqkUwZK0XHp5kALK2aYHbajUi1K7VRVfnT5vEfqDqSzD/BgiaJh0blRIdYxebAbD QIYnRSbnRGTcbjWpr7mN+lvegHSXxEBnIpLW/iS/3WUxr47pQda1G546pYhjXtWaIxE/93/JYu4 QOORtNOE5X9F0UUYTmHkE8JLNb8aGVO3KMbzR2Df+YR8= X-Received: by 2002:a5d:5f53:0:b0:43d:242:b9bb with SMTP id ffacd0b85a97d-43d642711ffmr16823643f8f.18.1776034243280; Sun, 12 Apr 2026 15:50:43 -0700 (PDT) X-Received: by 2002:a5d:5f53:0:b0:43d:242:b9bb with SMTP id ffacd0b85a97d-43d642711ffmr16823615f8f.18.1776034242809; Sun, 12 Apr 2026 15:50:42 -0700 (PDT) Received: from redhat.com (IGLD-80-230-25-21.inter.net.il. [80.230.25.21]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d63dec295sm27487393f8f.14.2026.04.12.15.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2026 15:50:42 -0700 (PDT) Date: Sun, 12 Apr 2026 18:50:40 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Andrew Morton , David Hildenbrand , Vlastimil Babka , Brendan Jackman , Michal Hocko , Suren Baghdasaryan , Jason Wang , Andrea Arcangeli , linux-mm@kvack.org, virtualization@lists.linux.dev, Johannes Weiner , Zi Yan Subject: [PATCH RFC 1/9] 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. Propagate the PageReported flag to sub-pages during expand() 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 | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2d4b6f1a554e..edbb1edf463d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1730,7 +1730,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; @@ -1752,6 +1752,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; @@ -1762,9 +1771,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); } @@ -2322,7 +2332,8 @@ try_to_claim_block(struct zone *zone, struct page *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, + false); account_freepages(zone, nr_added, start_type); return page; } -- MST