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 1B3B22BD11 for ; Mon, 20 Apr 2026 12:50:27 +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=1776689429; cv=none; b=SmP4epB+tL31TGWCqH6VFvp5T15PIVTubH1cFbYF6Uy7XyFkFWaJ3h0DEjvz3mTz1B8jnZ/U28R1y1FVa7GaCXLq8Vb+1NlNLUAcuswtqW1bhxO57oYSasntpILVnIKp9r1JfDI9tN991yVDvbm5pyt0RIX3Domjjk9zb/OgxjE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776689429; c=relaxed/simple; bh=ElXB4QKq3kqLoKEjiaPaOZnklCWfqoTQmJffudY8v4I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gVorVrvBdx7kxs6ftWDfmj8wmTdSOvxBx3tTzyAO9IdZGFk4mlOqMPbva+fjeW9oQlPymjQkzrcGHOW09N2vY7BH3+LXmQF/StSYNh54K9+4HvqHEHIBUPZmS5wF/vM+QMRNhZzji7FemE6EKRlJtM9vpV/proKXJt1ZkdlxbH4= 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=frQaB9iC; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZjBJnpGW; 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="frQaB9iC"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZjBJnpGW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776689427; 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=IelIqVYy/AcgVP/OqP2S72GFWZ6ux/wlNrxvOYGdRd0=; b=frQaB9iCMvw8cI2delL6QcPCfh9pNXbsWoxVWxbv468YG1nDIsOU1Irl99rsYH9WFZlZvp +o7ze2fH9zwloo4puQqC8ABxFJLwxrgsxO73mL3qcebPZCYurZGvo65RGGCydEo7MnZeHh M90+LsgYpDCCvtEe6tEuBJ8KEyiZ4jY= 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-27-fGIZEB84OuS3d2IBrVI82A-1; Mon, 20 Apr 2026 08:50:26 -0400 X-MC-Unique: fGIZEB84OuS3d2IBrVI82A-1 X-Mimecast-MFC-AGG-ID: fGIZEB84OuS3d2IBrVI82A_1776689425 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4411a69f565so698028f8f.2 for ; Mon, 20 Apr 2026 05:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776689424; x=1777294224; 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=IelIqVYy/AcgVP/OqP2S72GFWZ6ux/wlNrxvOYGdRd0=; b=ZjBJnpGW+P4GoNJLvnCdMqSMc0P/WsT37OR9dsdCvrIoNzoMsszAEdvoOi63Yt6w20 bPjH87bE3z86UR9ppy5UjAD+xoLdpVKfKJyAmj5DGXfOQFyyyq9CH1rEyWqrbLiKtscY Tlq+iV67eDwbBc4/b5qaAX6dOACFZdh3JhfAxutj4aq1T58I9w2D0fhoNvFfj5G1Mh+U khGHQj+eoSSrB1z88BJOTgMqzE57QGd69s3PW+V0dAaQ9LFuB/DQl3RHrs0GVXRqPUHr Kp/jlQpSHUmKrwBCKSVguqSnJ2qAdKZ0Y8X7+E87FBl8AplwVudxPlCEhbtzyR2VZkS4 vf5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776689424; x=1777294224; 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=IelIqVYy/AcgVP/OqP2S72GFWZ6ux/wlNrxvOYGdRd0=; b=bVDP44cvKCNhNdlsqeiEjfSbssuniQOY5Ux9W2slytK2oXUIWoUW2I0TF7tx1XCMh3 bY/FnWGQ5vtg4AQduSRaUrT4ybD4pf7ygqO4FsZ4EDBdu8A7Zv6/ppZ8iLry0qIGCyNn HfT21aX9CCeFK6y0jpyUHTWzeMYt9QluaHZ+cw+q5f2ArNL89/dwvnRgfzV+UxlYVWhW WGbJXVOSzoPP+B5/9JywKLcSTZ5/GrmM91LnzYH3Hd9TnaPqKFVKpvD3OLksp7/NfcIa E/y6yDZ59k0RnarWA+HolXSgt795iTeu0i2S7VVdBPxuYpyc8OcnRSA8UKwk6QdXlnAf zHog== X-Gm-Message-State: AOJu0Yx1ASSgX7+RjSiuKL3NttyQwJjDkbi4+yGGN06VadC5KU6/Bbze sgSKAz29napgI4gsUT/nsXKCLcstBVUSI2JCPlCYSybRSv/8b/4qmhjpQGEmxMegqGP0oXavthn 5smh8d/5THb797mH2Mu8MQBw47dXt1w/npsOJpU5AMw8tbzN3GqZsSH5kulGAk2U/nr6O+MIxGb vTJ6B2ITLpKYwEgJx7yS5/zLRXmg8t8WjelcsqO1SdtE4= X-Gm-Gg: AeBDieszwV1MR20UgbEUp8f5yevqcathbbgLX38bk88Otu9HMqp/K2YF+L/8ZNATc6k kUY1L/MU7USGInml5d+Ywcmabjbq7MV3w7ZhB37Cz/28PHULXUaVs8vo2TNuKPqjuIgYQ5eZF2V hHaaGASu8ApuiUj/p/Hv4v4dGDjddK7N6nIIB8g27lmbAnWgGKFCCtz5CbACezWxc6rSlmB7XFF kSt0hZFqx+c3HUNFnL7XfGDKR+JTjFYZfqdN/mbUIpMF0OU70MgDZrpdrFA7Q7+SJOMIMvF1CsW uyyh8WyVLa25Uj9TafAkWJQzwGE9hvwvMdFHfsdBFFZEw5qbLa95pX5Z7vFJkuXMJHkjesv2fZG 7xyuq6QAg21tmw/z/RUN0u7Ec1uSm5NRbRw+xHits2t0VaGA99FeuZg== X-Received: by 2002:a5d:5f89:0:b0:441:1c95:17e7 with SMTP id ffacd0b85a97d-4411c951810mr250614f8f.15.1776689424238; Mon, 20 Apr 2026 05:50:24 -0700 (PDT) X-Received: by 2002:a5d:5f89:0:b0:441:1c95:17e7 with SMTP id ffacd0b85a97d-4411c951810mr250513f8f.15.1776689423506; Mon, 20 Apr 2026 05:50:23 -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-43fe4e3a397sm31385276f8f.23.2026.04.20.05.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 05:50:22 -0700 (PDT) Date: Mon, 20 Apr 2026 08:50:20 -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 v2 01/18] mm: page_alloc: propagate PageReported flag across buddy splits Message-ID: <8fb5a2dd7eee6fb8ead6b2cb84dc5cc0c45a0f32.1776689093.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 Assisted-by: cursor-agent:GPT-5.4-xhigh --- 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