From patchwork Tue Apr 11 17:42:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 9675875 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 730E660231 for ; Tue, 11 Apr 2017 17:43:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BD2428538 for ; Tue, 11 Apr 2017 17:43:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60F6C2859A; Tue, 11 Apr 2017 17:43:06 +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=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 30F9D28538 for ; Tue, 11 Apr 2017 17:43:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1F23C20D7649D; Tue, 11 Apr 2017 10:43:06 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2B6ED2095C3C9 for ; Tue, 11 Apr 2017 10:43:05 -0700 (PDT) Received: by mail-pg0-x242.google.com with SMTP id o123so688765pga.1 for ; Tue, 11 Apr 2017 10:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vr9fqj9/5yaFY0d7pXXOGTZ5YhAx4KoDXctsvfkV+sE=; b=HpFy3nsfe0Zdv1K+vtPvO4kPTydgG7R6QBSW8Vi2xCprWAs9l+xWo9ud7VM9JHiSan TgQh7xhpO8nY4KsvX70GifRVjR4tSPcUITFo/Rcu/l3bkFMH4OC/xPnPsgsobh1U/bzU ytDZojByPHYKQzInzOhmIooVo8BxLjbtg39FTqN18j7HSwipvqW/XJEOL3+zxlEGmuMU jAsizoqIn9PCC/zyVf5GgacacskEHBGY0YYh1TmJF6pXsVAUCW3h+KVjaBmdbjrAo0R7 lykpyKHQmWadU6HV0pqmbNWI27lpcNVK/gebquZM5b3icuXbCOveQ6y8afsLGwcmZyQs 7MVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Vr9fqj9/5yaFY0d7pXXOGTZ5YhAx4KoDXctsvfkV+sE=; b=GsIG+nXQ9Q346v3DsiKgQytIM86cFJyJfbOqkrd51RH+AGeluMnsFOOT2nBiS8TW5p mcfV2tjYsEZvjIqed42wrbGBnQZbeICPpeIK+0WLx6cbxeB0kIkAO7EPhUo1FCxJFMrG uGuSewtdvgbzPpTHcRfCNbX7jbj2dax5bflLH3Rj1xjQEATQAfdR+jVUzVhD+cfzuhLw vz9HwCg5WwItUUEvUbS2AKwhvjcDcD7jL76p1t6Ne9FF7NpmmfZnLH4dC07CzA40DJkL uleJzokPmmizldIH5qiUqd+2qkk1lgx3MBiNw4UzuWCvRSyGgkBDmvq/9c2eYfoGBjYL jGqg== X-Gm-Message-State: AN3rC/57pGxoC9n9hdri2/RjsH+4w8KvtvZlPmvGx74nCYwIobF86orHPsMyD3w9zpU/7Q== X-Received: by 10.98.36.23 with SMTP id r23mr23763057pfj.164.1491932584864; Tue, 11 Apr 2017 10:43:04 -0700 (PDT) Received: from localhost.localdomain ([103.57.0.128]) by smtp.gmail.com with ESMTPSA id r185sm20182582pfr.72.2017.04.11.10.43.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Apr 2017 10:43:04 -0700 (PDT) From: Oliver O'Halloran To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 4/9] powerpc/mm: Reshuffle vmemmap_free() Date: Wed, 12 Apr 2017 03:42:28 +1000 Message-Id: <20170411174233.21902-5-oohall@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170411174233.21902-1-oohall@gmail.com> References: <20170411174233.21902-1-oohall@gmail.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bsingharora@gmail.com, arbab@linux.vnet.ibm.com, linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Removes an indentation level and shuffles some code around to make the following patch cleaner. No functional changes. Signed-off-by: Oliver O'Halloran --- arch/powerpc/mm/init_64.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c index ec84b31c6c86..f8124edb6ffa 100644 --- a/arch/powerpc/mm/init_64.c +++ b/arch/powerpc/mm/init_64.c @@ -234,12 +234,15 @@ static unsigned long vmemmap_list_free(unsigned long start) void __ref vmemmap_free(unsigned long start, unsigned long end) { unsigned long page_size = 1 << mmu_psize_defs[mmu_vmemmap_psize].shift; + unsigned long page_order = get_order(page_size); start = _ALIGN_DOWN(start, page_size); pr_debug("vmemmap_free %lx...%lx\n", start, end); for (; start < end; start += page_size) { + struct page *page = pfn_to_page(addr >> PAGE_SHIFT); + unsigned int nr_pages; unsigned long addr; /* @@ -251,29 +254,29 @@ void __ref vmemmap_free(unsigned long start, unsigned long end) continue; addr = vmemmap_list_free(start); - if (addr) { - struct page *page = pfn_to_page(addr >> PAGE_SHIFT); - - if (PageReserved(page)) { - /* allocated from bootmem */ - if (page_size < PAGE_SIZE) { - /* - * this shouldn't happen, but if it is - * the case, leave the memory there - */ - WARN_ON_ONCE(1); - } else { - unsigned int nr_pages = - 1 << get_order(page_size); - while (nr_pages--) - free_reserved_page(page++); - } - } else - free_pages((unsigned long)(__va(addr)), - get_order(page_size)); - - vmemmap_remove_mapping(start, page_size); + if (!addr) + continue; + + page = pfn_to_page(addr >> PAGE_SHIFT); + nr_pages = 1 << page_order; + + if (PageReserved(page)) { + /* allocated from bootmem */ + if (page_size < PAGE_SIZE) { + /* + * this shouldn't happen, but if it is + * the case, leave the memory there + */ + WARN_ON_ONCE(1); + } else { + while (nr_pages--) + free_reserved_page(page++); + } + } else { + free_pages((unsigned long)(__va(addr)), page_order); } + + vmemmap_remove_mapping(start, page_size); } } #endif