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.133.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 93B7636A035 for ; Mon, 13 Apr 2026 20:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776112337; cv=none; b=V68F2waQ9XvEIwxFr7CKsvUDrJyA4UgXbijd/88OBIjxHoh7nqG4K+vJpZNCJp42SZyeodQlHp8Mx8MFKEIrox0J+mjuPmxF5jhFg5FIfIFDL9a3tBaKhjtfJqexDCNYQuqIsb/M5OvE3xJPcgVVPahoIdBt5oOQ2NWPG+DT7CA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776112337; c=relaxed/simple; bh=3mpoi8a9u2lmPNM30l3zv4vXYeFva/GaZUe1gaAmh8M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Jhkz4sHF7xAZYh1gbMnmjbFPDt3L7iV4unPfVFQP+1yRCTCvdbeR/eLsAzbVkpiu9Khav5QfXesJHKiIr8S3bW2KGG8ebJa/zEpqTnq3UZAZzAF5tMPiBWCoe4Pz31yPAs0yvAb81CZO6ulfn/4/J+aFmXTWCvUSgoUGcdvkLgA= 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=ZhvEP8kh; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=L5iZhVs4; arc=none smtp.client-ip=170.10.133.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="ZhvEP8kh"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="L5iZhVs4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776112335; 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=NWH25+zbxJ7b6HA24/mMxvWwNWDzV+d0yyXTRBBCpp4=; b=ZhvEP8khqJ8gLbZ71HT/RpOt+5i2lN7OvPZSOs/lvMU7hgN42guX/14gaHuAuRwh7BslHN CC+H48izqxAAmF1my1VUY8Z7zXDoxiBJ6AfPYJ0EZT59ixJ4RMAmT3GIDV9IVL/CFHGXbw qaPaFyTiJt1mbHvVjjfJIY89ESxWqs0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-348-Cw2Js-jDP6eEkFfq8pux9Q-1; Mon, 13 Apr 2026 16:32:13 -0400 X-MC-Unique: Cw2Js-jDP6eEkFfq8pux9Q-1 X-Mimecast-MFC-AGG-ID: Cw2Js-jDP6eEkFfq8pux9Q_1776112332 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-488e12db7e0so17696795e9.3 for ; Mon, 13 Apr 2026 13:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776112332; x=1776717132; 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=NWH25+zbxJ7b6HA24/mMxvWwNWDzV+d0yyXTRBBCpp4=; b=L5iZhVs4a5EqCLUsVLc15P3SkzwY914BU9PttrBctqRWGzXGxyBjaDWAyqdxZfEPQ7 67avUUXpGkHHvu0jAeSUC/6N63vDjO+e3vg/h+vTceoj7FHr8qRfYttIVNlFtJlCpxUV sP3/P9v0nh3XbiSyD41FpUcBImnavDo5AqQLFxyNJnaUyJQquNWsuIckI8T/a/wkcJz+ JotWBTJFXyT7v4aMkbQAUrU5R2sBZvudsXjjfadPuv36Y2l5gcuvzyTkDZs4mWn1B1o0 Xc7Jdrjru9zV9FH8z7oSUqYeTUWW7dAVRQIAg5OfCKD7Ys8kskHRQVyCzoQQRk06t2Pl ILpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776112332; x=1776717132; 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=NWH25+zbxJ7b6HA24/mMxvWwNWDzV+d0yyXTRBBCpp4=; b=Laiyz2PaJu4znA+TxAo5C3+haqv7vixZY/svTpgwB/Hkpqcs+ov8F8xPDi3tRWAjhy bHrd0XVmH2TKn4b60HC03Jfdd7/gOFi5UbY+0tjilEHUEaLVTv/GI9d8/lQOnsQ4czpw FDqWDwJqTvGc6I95Nvv58L/5Jq6CjsFcQifo7HEeap/6Mai639VOnEv+P5Okk3QSHUU0 OPmMEU1hwbi2Iz7WW0Rw0IwEEEyFpXVtD97KCtIwLb2enP+hsMjMvXDIjKuPYIQ2t9tD 2h8LduF+5yb8B5E9sFh6jf4DCCtYJPl+JxBrbcr5V/ixsLob5RsY8qzgd2+nPt59p97S 9GOw== X-Gm-Message-State: AOJu0YwOpPadJ4HBKZq3XIbnBkNkt+/cSh3v3TXCRs58nnQNeCUZ1CX8 C5L0T07eK9ruXFoTMuXaRnYknAq8rlCxYhJ4Rh3wR2t3aYy87ds6k2ODsrotZ3Gg7WrDak0RnXg um8iPPTV1xv6Cz6qR5pecyg797TXjsRAGruGZf9RpMauWD+WgYm6WifgO3iVG28C7ww== X-Gm-Gg: AeBDieutzGUAnfdvPfeNC6c0A/PEdrbNOAYNyU+yKQ6TXDy33fuZE9ovRnDQOlZGSSu 3qzbenFa0hIVWOcBUznFEnctk9c5OZu+J8senGfL+shm8OLVdK+B43V4q0bT2B1KNUbpBkTeQSO I28D06I5ncu1eZV7m/9TPPiJ8slGJMVlLLx/g27pUnkkCho/3GuVjMHDSdW9B1df4m8J/4D0Djb qJDap3spaeaPlzCZfGkvaRIoAkn7lfp+xxeF+raQPyaMvGXBixWjV9TW645p/qcnLkH9N6V1YXZ wJY0UUw29ZfZwLIBmro7X8gVLcQs3X9D/+FUKTs7QJLTAWzjyIXF1BTfTXihmjdofP3yIk+7IcO vTFS+jggooxerd0y1Y2m7sw9Py9gm0rbXf5oxYcrWLNo= X-Received: by 2002:a05:600c:4504:b0:485:3b9e:caa7 with SMTP id 5b1f17b1804b1-488d6864f6dmr201909235e9.23.1776112331892; Mon, 13 Apr 2026 13:32:11 -0700 (PDT) X-Received: by 2002:a05:600c:4504:b0:485:3b9e:caa7 with SMTP id 5b1f17b1804b1-488d6864f6dmr201908795e9.23.1776112331276; Mon, 13 Apr 2026 13:32:11 -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 5b1f17b1804b1-488d5cf2e70sm177712665e9.0.2026.04.13.13.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 13:32:10 -0700 (PDT) Date: Mon, 13 Apr 2026 16:32:07 -0400 From: "Michael S. Tsirkin" To: "David Hildenbrand (Arm)" Cc: linux-kernel@vger.kernel.org, Andrew Morton , 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: Re: [PATCH RFC 1/9] mm: page_alloc: propagate PageReported flag across buddy splits Message-ID: <20260413163104-mutt-send-email-mst@kernel.org> 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: On Mon, Apr 13, 2026 at 09:11:51PM +0200, David Hildenbrand (Arm) wrote: > On 4/13/26 00:50, Michael S. Tsirkin wrote: > > 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. > > + */ > > The comment is a bit excessive. I'd say you can drop it completely. > > > + 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); > > In MM land we started doing > > /* reported= */false > > > This raises a good question: how does buddy merging handle the reported > flag? > > -- > Cheers, > > David IIUC it doesn't: reported pages are never merged, if a page is merged it has just entered buddy. -- MST