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 B122C21B9F6 for ; Sun, 26 Apr 2026 21:48:19 +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=1777240101; cv=none; b=peyRmSkaiIxYDYncu3lQgnkbE+IKP9B2tAiOFZwoq3rUvN+Cy2U/zDMplQBGS+jT0/tNuB3o1OXEzYbMcWAX1/J1GieazByhnxipbkIj08i51wvwDK7g3mG2Ul2pugaULUfWg0WmfMbB3heb5rIWQSaEvSboO5SyRkM9IbmKUVU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777240101; c=relaxed/simple; bh=IxckQwCgbZJbxxjvhlOEmINi1CgwfFxzwO5yadjBe7c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aPTOtNq21eHKQXmD6MyJLSN50pG8hRFHmAnA7S/x0sY9F09Z7BmjANPPiAm2+VSYsDU2EtqKPtDkPB5rQk3+i9QLHrCRefaKLez6l5HF2Pm7HMI+ZIo1LSU0kly/ENz+Rd6Mi8pKB4TFt540eYeh9kNfkpue9idBgSkbjfc2iy4= 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=a6T2JzsQ; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=HPqYSX8l; 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="a6T2JzsQ"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="HPqYSX8l" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777240098; 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=8jzD5+aaEj/qpAoN4ceRyyQr8AzYBOgh6GvhLOGpHCU=; b=a6T2JzsQibgyHcY7ss1SGU/lOrwYhrPOB6cjBv//n4xr6dfSNUS1+rDM4zCqS7czA+NNpQ UtLoR3n9DJCo5pSjqH3mf/5FwkudY1QkdEVoZfqS8zJMBrbZXVpDVPF5HWmNHhD0qXfgsL vRgE3HzlkXTq1jFFDBPfoj4FVK0gulU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-235-ebPKbZMbO5ed-yzs-6OStg-1; Sun, 26 Apr 2026 17:48:17 -0400 X-MC-Unique: ebPKbZMbO5ed-yzs-6OStg-1 X-Mimecast-MFC-AGG-ID: ebPKbZMbO5ed-yzs-6OStg_1777240097 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4837b6f6b93so102942475e9.3 for ; Sun, 26 Apr 2026 14:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1777240096; x=1777844896; 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=8jzD5+aaEj/qpAoN4ceRyyQr8AzYBOgh6GvhLOGpHCU=; b=HPqYSX8lJQCsJRIQ3mpWauY/BDwlHDAIZm2jVQg64s82lptb7rtu1n7NFy1nyzLY9d SR/FQPoOinq8i7un+i5wLIw94KM3w6tcfloK7Zi0kTQcwlR8ZghnSsKpSsERtQBqh+nV dzegN3RrwjJz6ostLbvRwq63hxQbkeY+yVTVo8Epi9clKQJzsG5Xj+BxIffbK88XCYIV LogTo/NHNBr9y5NnmCe59IwpAsQzXy7DuUnt9NIHP2Qs8M9i6du0XJEFx8wIcj9X3E4Y XfDJFbZ8Y4KpGrFdh21SLnZUTCDMGDMs8cnQiuGqM/p7Xf2j1PHiTn0s4vSI/66DCgIq BLog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777240096; x=1777844896; 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=8jzD5+aaEj/qpAoN4ceRyyQr8AzYBOgh6GvhLOGpHCU=; b=Aqk56SrbgHhzVz42fZHQZf65vB+54x5jR4gHPjrldxR03tH2rENRGZryhyV7pue6Tj AAdwaDdVOjLJypUj9mnPtPA7Y4LwagFpaOGuIsyVqPBtqAsyPxnxbikeXwOeDx0jCnJB h+TIvEOrBcuTAebmaILXS1w8yaeg3uoZPflDG9+pZbxgJG90D69ltjkXOYmoW4a41bE6 BTXiuLPQzYqN4NHIQmb04hqfCkA4z4MGiXn8kPK/P5ogP/miCnhNx+xRyWa2NVSKwvQT A0B8jjy9COAMavzb52ko0D+H+WM35IKAr1tK3tGLatdMh2xyRSmbchnk0qeHk4ywMo1a bj1Q== X-Gm-Message-State: AOJu0Yx4xJzL5wOcfjMXfJ78CP5VJUDjH0SoIvwQNsUob0ei0ToCgVl0 cbXEKJdYSTI8UYegEhR75cGhP7AgcmI7Xb/QJNF3FJeDLBIYS38ezN5sUOEQKiRiSHXhIKw1AAR fOjCys5AC6lrckmvvcEDIECc3rvpUSjKHuzuXHZj4uUxSFqD7TEncRMB/++pEGdYm9jzyMUDaJc Wc48fW/BGcne7/MreRkCh62GJ1/QMXTKrePgahg7a38Cg= X-Gm-Gg: AeBDiev5OEdt+/WljyMyKarGRNPv+TXZ6q/jhpKa9aD5XFeQ3646jyY0hPShZpJwlPC RMRE9HCPoIzqy+N7MOV/J9PZFne8HlTWKiYMLe876GWU5WMAn7gJDtthNwQqPZb4F7thc3fVBrQ uCmm3yDrpxnvavAd/JFdQQd4Q3I87eOEpiFKnO1d+Y6ZZikE7mdjJDuBfybd1gzdArZs6I9enEj 9XVRaQJUmT6ETeR4JRw2y4itsu3WonY56xr8aU4A0W/zVYbwUDzDiVP86g8vkmHaH5tYVbOk9nl 4JsKMV0WKYADd/5YX0OJlcNhnqGfZ7gAHGqbFEl4oZ3H50ux/8RFxn2wIBC/iwj8oEQhv97zNT7 ruOtFYlzyuUZwABVhqeTTBHSr/GIW4eUtFqTK1wnwSsVCnH6cEWwBkZDR X-Received: by 2002:a05:600c:820d:b0:48a:569c:abab with SMTP id 5b1f17b1804b1-48a569cadacmr341610075e9.14.1777240096225; Sun, 26 Apr 2026 14:48:16 -0700 (PDT) X-Received: by 2002:a05:600c:820d:b0:48a:569c:abab with SMTP id 5b1f17b1804b1-48a569cadacmr341609585e9.14.1777240095687; Sun, 26 Apr 2026 14:48:15 -0700 (PDT) Received: from redhat.com (IGLD-80-230-47-179.inter.net.il. [80.230.47.179]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4412150a071sm39398823f8f.21.2026.04.26.14.48.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 14:48:15 -0700 (PDT) Date: Sun, 26 Apr 2026 17:48:13 -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 , Gregory Price , linux-mm@kvack.org, virtualization@lists.linux.dev, Johannes Weiner , Zi Yan Subject: [PATCH RFC v4 13/22] mm: page_alloc: propagate PageReported flag across buddy splits Message-ID: <68154113e50456eb8adab9bc5419c30effc59144.1777223007.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() 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 7791bc1eeefa..ca4f9c0948af 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); } @@ -2334,7 +2344,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