From patchwork Tue Feb 4 15:14:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Hildebrand X-Patchwork-Id: 11364831 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6DA41395 for ; Tue, 4 Feb 2020 15:16:13 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8D73E20730 for ; Tue, 4 Feb 2020 15:16:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D73E20730 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=dornerworks.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iyzuc-0007bP-LK; Tue, 04 Feb 2020 15:14:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iyzub-0007bE-D0 for xen-devel@lists.xenproject.org; Tue, 04 Feb 2020 15:14:49 +0000 X-Inumbo-ID: 1459e4e6-4761-11ea-b211-bc764e2007e4 Received: from webmail.dornerworks.com (unknown [12.207.209.150]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id 1459e4e6-4761-11ea-b211-bc764e2007e4; Tue, 04 Feb 2020 15:14:48 +0000 (UTC) From: Stewart Hildebrand To: Date: Tue, 4 Feb 2020 10:14:40 -0500 Message-ID: <20200204151441.10626-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 v2 1/2] 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 , David Woodhouse 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 Signed-off-by: Stewart Hildebrand --- v2: s/pg-mask/predecessor/ --- 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..735049fe3e 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) != order) || + (page_to_zone(predecessor) != zone) || (phys_to_nid(page_to_maddr(predecessor)) != node) ) break; @@ -1485,6 +1486,7 @@ static void free_heap_pages( if ( !mfn_valid(page_to_mfn(successor)) || !page_state_is(successor, free) || (PFN_ORDER(successor) != order) || + (page_to_zone(successor) != zone) || (phys_to_nid(page_to_maddr(successor)) != node) ) break;