From patchwork Tue Aug 8 21:44:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 9889129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 269AE603F9 for ; Tue, 8 Aug 2017 21:46:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 190A52890F for ; Tue, 8 Aug 2017 21:46:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DC582892F; Tue, 8 Aug 2017 21:46:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 193FC28A2A for ; Tue, 8 Aug 2017 21:46:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfCH9-00081F-Dk; Tue, 08 Aug 2017 21:42:55 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfCH8-0007zi-02 for xen-devel@lists.xen.org; Tue, 08 Aug 2017 21:42:54 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id C9/D3-01729-D503A895; Tue, 08 Aug 2017 21:42:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkkeJIrShJLcpLzFFi42KZM10+UDfaoCv SYPkGI4slHxezODB6HN39mymAMYo1My8pvyKBNePEF5WCqYIVC/6+Y2xgfMfdxcjFISQwiUmi f/MfRgjnD6PEhSfbmCGc9YwSs78cZ4NwehglOl+2ATmcHGwCRhJnj05nBLFFBKQlrn2+DNbOL DCNSWLvt3dgCWEBM4mJq1rZQWwWAVWJp3t/MIHYvAJeEhvn/2YFsSUEFCSmPHzPDGJzCnhLzL zwlwXEFgKqmTF5KjNEjbFE36w+lgmMfAsYGVYxahSnFpWlFukaWeglFWWmZ5TkJmbm6BoamOr lphYXJ6an5iQmFesl5+duYgQGSz0DA+MOxr5VfocYJTmYlER5N2l3RgrxJeWnVGYkFmfEF5Xm pBYfYpTh4FCS4GXX74oUEixKTU+tSMvMAYYtTFqCg0dJhLcdJM1bXJCYW5yZDpE6xajL8WrC/ 29MQix5+XmpUuK8WSBFAiBFGaV5cCNgMXSJUVZKmJeRgYFBiKcgtSg3swRV/hWjOAejkjBvHM gUnsy8ErhNr4COYAI6IsK3E+SIkkSElFQDY0DSzWt5/7gTq+cnPDhesPDDy/d/1WK/nDz+kI1 ldbyscvjf99ZL0/Ryfxpbhqe4xNiWKR39pM6e0JaaycLNY6Blf8ZZaOGbS7uF/oo48TQUnyhY eiv6aesDT48vlg8vdjKa1+/av25d4zXxOSlABVxPg6yVt3fKWepemX7f6qO7hcHWAzVKLMUZi YZazEXFiQCoZ8tCnAIAAA== X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-2.tower-206.messagelabs.com!1502228569!85813842!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30737 invoked from network); 8 Aug 2017 21:42:51 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-2.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Aug 2017 21:42:51 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v78Lgf4i032336 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2017 21:42:42 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v78LgdbK008951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 8 Aug 2017 21:42:39 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v78LgcEe026061; Tue, 8 Aug 2017 21:42:38 GMT Received: from ovs104.us.oracle.com (/10.149.76.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 08 Aug 2017 14:42:38 -0700 From: Boris Ostrovsky To: xen-devel@lists.xen.org Date: Tue, 8 Aug 2017 17:44:59 -0400 Message-Id: <1502228707-31883-2-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1502228707-31883-1-git-send-email-boris.ostrovsky@oracle.com> References: <1502228707-31883-1-git-send-email-boris.ostrovsky@oracle.com> X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, tim@xen.org, julien.grall@arm.com, jbeulich@suse.com, Boris Ostrovsky Subject: [Xen-devel] [PATCH v7 1/9] mm: Clean up free_heap_pages() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make buddy merging part of free_heap_pages() a bit more readable. Signed-off-by: Boris Ostrovsky Reviewed-by: Wei Liu Reviewed-by: Jan Beulich --- Changes in v7: * New in this version (this used to be part of patch 2, splitting into separate patch) xen/common/page_alloc.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 8bcef6a..330f8ed 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -977,24 +977,31 @@ static void free_heap_pages( if ( (page_to_mfn(pg) & mask) ) { + struct page_info *predecessor = pg - mask; + /* Merge with predecessor block? */ - if ( !mfn_valid(_mfn(page_to_mfn(pg-mask))) || - !page_state_is(pg-mask, free) || - (PFN_ORDER(pg-mask) != order) || - (phys_to_nid(page_to_maddr(pg-mask)) != node) ) + if ( !mfn_valid(_mfn(page_to_mfn(predecessor))) || + !page_state_is(predecessor, free) || + (PFN_ORDER(predecessor) != order) || + (phys_to_nid(page_to_maddr(predecessor)) != node) ) break; - pg -= mask; - page_list_del(pg, &heap(node, zone, order)); + + page_list_del(predecessor, &heap(node, zone, order)); + + pg = predecessor; } else { + struct page_info *successor = pg + mask; + /* Merge with successor block? */ - if ( !mfn_valid(_mfn(page_to_mfn(pg+mask))) || - !page_state_is(pg+mask, free) || - (PFN_ORDER(pg+mask) != order) || - (phys_to_nid(page_to_maddr(pg+mask)) != node) ) + if ( !mfn_valid(_mfn(page_to_mfn(successor))) || + !page_state_is(successor, free) || + (PFN_ORDER(successor) != order) || + (phys_to_nid(page_to_maddr(successor)) != node) ) break; - page_list_del(pg + mask, &heap(node, zone, order)); + + page_list_del(successor, &heap(node, zone, order)); } order++;