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 3B2AC3BA237 for ; Mon, 11 May 2026 09:03:29 +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=1778490210; cv=none; b=O+4mzYC3YlWLy/DLYMulqpQIzPkvh0Orbq2iCKZdQajjKAEeQecw8Khm84/FJX7keZvUnaPAU/hxPlx/fu9ErapNTL65GYoxWmk6KiFFww/sZpe2J9DNBB4UzpTVesI/fUakhgNyHGBHcl1og9+3L6xH27gJYU2/JwhtdN0PuyY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778490210; 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=tSrGcEOjNEb4fvBVvKOPaDLEhb9IFn5ZoS48iGHj034g5rRXgTslWDFQ8HKKxOAqn002ILAXG/wzhsZJYybx+1+qx+ZfF+xBchDBcKHQMeKm/NezepLVv8X8ZIx1DdxN5XtCVfiv6St1ICF1Yw1M+J7mT2YmlwchyKQznhUOCy8= 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=IRGV2+sg; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=dIQysuj2; 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="IRGV2+sg"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="dIQysuj2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778490208; 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=IRGV2+sgKipJEKXMKzzGCfcdgPfaH2G/rCagRDwtlJJ1rTLtJijBOFhoBj1b7nnacccVMT BcfbEcBLC9K2KwKsFoA6wP9hgs3SepWBXuhQO9k3iKizGYYZil7/3i/VDIw0wMNGjjT+bC vN3S7uilytvjklxOZF93w2vc8X4oNpo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-93-8miqW0LTOKS-uD-cXkQbeA-1; Mon, 11 May 2026 05:03:27 -0400 X-MC-Unique: 8miqW0LTOKS-uD-cXkQbeA-1 X-Mimecast-MFC-AGG-ID: 8miqW0LTOKS-uD-cXkQbeA_1778490206 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-44b186b715aso2588132f8f.0 for ; Mon, 11 May 2026 02:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1778490205; x=1779095005; 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=dIQysuj23UoxWmU37rDE57sUaeySgwd2P+X8t5r3qS7AQicF9NtOeFKx+XjAmm4rVy knDB5VfxjqD0costK+WzhoSzniyUk7Dl5HkRRaYstm6xNwUePzFDmFwWqoznDUQZqXnM /VZQC7gvW6nJQNBt3rcbcI9X8CyG7R11Iv5MSLWjB3SY5u6EOvDYLQelbtk4HjUSmW2I JmnonoZTAT91i2cf9Vm24TD7r0KG9OonO8mu5qTE8OXlBLWEr3/6mu8Ds066BdsBA+aO PupAsjuk5ELj1xoJt1jxIkTUVDwI9cmERUtOmtBm+2fE3YoRzebJTTk9wC8OYh9+AV/C uu2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778490205; x=1779095005; 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=oR4OKBBHsYqGDgLL+eAHg0pfJpk0GGPlwKSPQX7R2/nSMty8qIPfsmTRT9v57YxjBx u6xTeK4Pa3oddltCVTDgzIo2Rg+lVQWd5cFkptdA+IPLuffUjY440z5bPwuqXrylQFbH noB22vE0b4SBce5xO+RRIyZueJU9/xIvfujNo/cm1MQ1efm6trBAUelfvYjux7wnLlcf nVqFVdgPECB/obKBoUmYkCUt3n85jQ7MhqVNM1kuNGEmRbSJkjQ4pBgNTWDcxFwo4/tv vVAIU7Wbl/1i2kCtMO1ytTtuSbBQOrpWQ/HMX3vlnJwBrLyEWR4KBGQUpycl15/iAnmJ OUAA== X-Gm-Message-State: AOJu0YwUUNSWiOPza1fJiOFTWHAG9rPETCncQkUExNXx98UOFZTUQUwH W0OXWhUDDGqTe80wWHUuou5WOmgPJYY5331gZyzaRxyzvx8Dr/0i2bIMfhX2yfpF7uca//i1pRU s4T3eCSYNfS+FlhnFuSa0ahXfqhWaSYewA8G2+K4LBvXz9yGwBAgduIYktoTXqVXt8RlyTi8Epo 2bdX4fLhuyr8KUr8RwaHUuSGp5Ztuvh884lKYvb+VrMjU= X-Gm-Gg: Acq92OEwrbh8q6A7vjhhUR/U7gb2c9kSb4ZpbtvrTiudhHD+0TrDQiZkRMJ2N82wzn0 ZMrx7Jee7aksfI2df1t1MUnpmi7rYE4SFjB35ERnHzq+VeXpAY0MQcQiKbf/XPIECU7rIWGqkIE 1NxgJ5oE75ghZcHrDEMXoijZOvqGER10xsQF6yTv8C6ut27q0J2WMQKFZ3BlKtz+7jj+VjAAUzd mq8rutjNwRU7b9JCg5vw1dPdxiXIOfTIu7nnDcc+BY3ZlABMR3XvfKSLJK/UT7j8yd0FUb1YD93 CjM5oREznEBCTcp6pOldtH4aK/t4y8GYrH1opEBvtEk9rRrOG99oixUPVzEMJ/4hmll4OHpqOBA pXXqwMrLGgq0+VVdVku9EMzGv2wdYNAdTMEIZ901z9JduO4qMHag= X-Received: by 2002:a05:6000:26c2:b0:43d:70de:1c71 with SMTP id ffacd0b85a97d-4515b61a7a5mr36392558f8f.11.1778490205407; Mon, 11 May 2026 02:03:25 -0700 (PDT) X-Received: by 2002:a05:6000:26c2:b0:43d:70de:1c71 with SMTP id ffacd0b85a97d-4515b61a7a5mr36392444f8f.11.1778490204503; Mon, 11 May 2026 02:03:24 -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 ffacd0b85a97d-458b3664e3esm8476641f8f.3.2026.05.11.02.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 02:03:24 -0700 (PDT) Date: Mon, 11 May 2026 05:03:19 -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 resend v6 17/30] mm: page_alloc: propagate PageReported flag across buddy splits Message-ID: <6d98a35c94fa44b550afa66923c620511e2826f0.1778489843.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