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 4B3A3280CD5 for ; Tue, 21 Apr 2026 22:01:55 +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=1776808916; cv=none; b=XtwcekTtbdyRagldBAy57vZmL6d5PMzf43kMtCSPwT+cwVjeJ6ce7w+iGFeUsHvCQsCERIX3/Hyfd5WsEkoRy+/uZfMood98m5qIxc8kuHWKhklmz4g48H1TrtE9YwkKwxlXch+02NEP6glUpWG2zrwAA3sdYvLm8+Ka9YwR6Ds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776808916; c=relaxed/simple; bh=sDo0b8xddYVEGpaxJMvmIOo2W7GKA24+V8mFvrgK7XQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BRHttwbIBpBvdimLzQok9MjZ8RxQcwg9idEvbkPhN2Y0GwkI+Q5yZhMXNrGOA5cYdPVPZ7NgNNmwvfidULCEsyWD+lbK/feX1iDOLl6Y5JusDCRBgt4lNaw4u1ygbqzDDEQlgEN5wiqqmJ6K9pbElyxXDmPZJOTte15Gto2x3/k= 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=H/bqEOVf; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Noq0WcU1; 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="H/bqEOVf"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Noq0WcU1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776808914; 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=iXNCfNPQyocyWkSCOxjnq/WqPhuX3fxPK4FCFhhbcx8=; b=H/bqEOVfaL1WAPA7faZTBr+Yrrq6SAPRCT6tF89++b6wrodyJnsiD79I7AN/jLlqq2c/jH HicscYZfhJHpLtPxCe3jqRPVXRHQkxvInzDOaq4g9p0BOKOy0S1KPMV2cHuCkuQIA/2ZG+ cARpXVBBG1XGPylwNspqxGYxX3vZyTA= 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-395--WewoLBgPBOe1Km6Gz3eQw-1; Tue, 21 Apr 2026 18:01:52 -0400 X-MC-Unique: -WewoLBgPBOe1Km6Gz3eQw-1 X-Mimecast-MFC-AGG-ID: -WewoLBgPBOe1Km6Gz3eQw_1776808911 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-440d0d7872aso2251345f8f.2 for ; Tue, 21 Apr 2026 15:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776808911; x=1777413711; 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=iXNCfNPQyocyWkSCOxjnq/WqPhuX3fxPK4FCFhhbcx8=; b=Noq0WcU1rIwmZGSzOTEphpBQHauka5o1YK0bfW2eJncn0c9ustOUmRMJfeZ3Utp8xa 4Q1F9ygvvkuT7yhbYKfTTh7exhSNAFgCWCrKrHZyFzdX3fip4O2dM0EQFDT1jLXOqMu5 MJHkRrDeKyM75jFwHb8zD6tvAPA2gLN2msGIF096xY47h9OOsOGx5VUagIogQQj1uiQ1 MDqNyvGtB/s7cUV83T5C9NIRGOhRo3Bhy820WeJykK7O70Cjg7bme9hyQ2wjHrHjirf1 Te3jxwSfIEmgSPinAZCC5yUf3Qt7JFc4TyVdiCO7Fi+XoNFgig+QtCcRQKqqaGLxeyrM hKEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776808911; x=1777413711; 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=iXNCfNPQyocyWkSCOxjnq/WqPhuX3fxPK4FCFhhbcx8=; b=kkPXSwWmUXWkJcTBbSgQALEy+ZJ3ugPQsbm2EbQYkJtEd99OEQ0XWJed6VBl1diHyc f6IraLTdmpstOqIe7ncnMEb24RzExAOfKrcD/ATSPXwiuRpfGvdL9N+pyebPxOi0pfHo uggCUFsEQ5wuAZVO01OQT1988C6G76oUFb2/CnUITN86w3RjJ3cvzxMa0Eep/3ixdgr/ jnYJyr3O8vkXqHjmSUAe33PktJctAMeQEfBD/nxOMLrWO4nZOHaCC3dnhD96+7y8uzLL xDetaFdytv6E8obksZZD8V+arsngtPmmf6r+cFrzEYkbGntGm1oJR8b6a8dqXZkIL9Cz pm1w== X-Gm-Message-State: AOJu0YzRLYGIerYciLIMezIa5qhPN0zHxTLtvXLz6M474DK4UNUvj1LZ A6s1kEptITvp9d9iYZ32TTPH4Lq0em3bHKQO8PgBrgIR6chsBr4z/OA46SWoNixnfNN6C1C4oML 3JR9jZFrI4CjUPED3wJOunu4tbV3+H+xdxNB3YkPzNKSysiLzGk1wabquQ/6xWPN3VPb62+WSAT xvwbkIQPc/f0KJwvftaOCcExnvGtXBBjvmyI40VT/vZFM= X-Gm-Gg: AeBDies9AOu3M5rqyZeQCGwn0MgTxgUD8ACzBy1n89j3gXRkq4iiMln6JRlnejVOQl0 Mu+QUKfhMCIBCZ84bD5VzfWQFQ7T20fFetyhD/w5+E2OfXQ5vhTy1Cxw4qUwtByNfIaBNOkMipB xlfpwyOyhUrzWKMOzZqz5YQs8WrVWYS6aogvJLArrmtohnxooAeDq3zBROptsEEIQPnX0x1Jb3e hHFcJlZUk4PwIR/t3nqT46XMVVdbsLwDngWlJnwLTKEdcI2hjhRlk7Yhv0MTHUjCpuHBHZqAcs6 C/2dWGc5ZgJMGYhFDR996bkMA3StJ2nV396Uu0GNu6IXA9RZAN+prVmKq259Q38sVneGmOWZa17 CCmwF9H5v869TcnnMJ9G6X/xiyyXfGiHsmc3bZDHk86n5riIZ1jTEPA== X-Received: by 2002:a05:6000:2481:b0:43d:77a8:3bb6 with SMTP id ffacd0b85a97d-43fe3e239d9mr31452792f8f.47.1776808910753; Tue, 21 Apr 2026 15:01:50 -0700 (PDT) X-Received: by 2002:a05:6000:2481:b0:43d:77a8:3bb6 with SMTP id ffacd0b85a97d-43fe3e239d9mr31452682f8f.47.1776808909583; Tue, 21 Apr 2026 15:01:49 -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-43fe4cc375dsm36898455f8f.14.2026.04.21.15.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2026 15:01:48 -0700 (PDT) Date: Tue, 21 Apr 2026 18:01:46 -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 v3 11/19] mm: page_alloc: propagate PageReported flag across buddy splits Message-ID: <7d1337e364980896be012ab34fd26bb3bf82c7af.1776808210.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 db2192ffc27c..211e9e32b91d 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