From nobody Tue Feb 10 00:40:49 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1580826657118614.6712902469991; Tue, 4 Feb 2020 06:30:57 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iyzDX-0003tB-5a; Tue, 04 Feb 2020 14:30:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iyzDW-0003t5-HX for xen-devel@lists.xenproject.org; Tue, 04 Feb 2020 14:30:18 +0000 Received: from webmail.dornerworks.com (unknown [12.207.209.150]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id dc607ede-475a-11ea-b211-bc764e2007e4; Tue, 04 Feb 2020 14:30:17 +0000 (UTC) X-Inumbo-ID: dc607ede-475a-11ea-b211-bc764e2007e4 From: Stewart Hildebrand To: Date: Tue, 4 Feb 2020 09:30:10 -0500 Message-ID: <20200204143010.5117-1-stewart.hildebrand@dornerworks.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-Originating-IP: [172.27.13.130] X-ClientProxiedBy: Mcbain.dw.local (172.27.1.45) To Mcbain.dw.local (172.27.1.45) X-spam-status: No, score=-2.9 required=3.5 tests=ALL_TRUSTED, BAYES_00, MAILSHELL_SCORE_0_4 X-Spam-Flag: NO Subject: [Xen-devel] [XEN PATCH] Check zone before merging adjacent blocks in heap X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jeff Kubascik , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Jeff Kubascik The Xen heap is split up into nodes and zones. Each node + zone is managed as a separate pool of memory. When returning pages to the heap, free_heap_pages will check adjacent blocks to see if they can be combined into a larger block. However, the zone of the adjacent block is not checked. This results in blocks that migrate from one zone to another. When a block migrates to the adjacent zone, the avail counters for the old and new node + zone is not updated accordingly. The avail counter is used when allocating pages to determine whether to skip over a zone. With this behavior, it is possible for free pages to collect in a zone with the avail counter smaller than the actual page count, resulting in free pages that are not allocable. This commit adds a check to compare the adjacent block's zone with the current zone before merging them. Signed-off-by: Jeff Kubascik --- Since this topic came up again, I figure it makes sense to resend it as a real patch using git send-email rather than in reply to an existing email. --- xen/common/page_alloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 97902d42c1..7d39dd5be0 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1462,6 +1462,7 @@ static void free_heap_pages( if ( !mfn_valid(page_to_mfn(predecessor)) || !page_state_is(predecessor, free) || (PFN_ORDER(predecessor) !=3D order) || + (page_to_zone(pg-mask) !=3D zone) || (phys_to_nid(page_to_maddr(predecessor)) !=3D node) ) break; =20 @@ -1485,6 +1486,7 @@ static void free_heap_pages( if ( !mfn_valid(page_to_mfn(successor)) || !page_state_is(successor, free) || (PFN_ORDER(successor) !=3D order) || + (page_to_zone(pg+mask) !=3D zone) || (phys_to_nid(page_to_maddr(successor)) !=3D node) ) break; =20 --=20 2.25.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel