From patchwork Wed Jun 28 01:32:32 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: 781437 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wy5374739z9s2s for ; Wed, 28 Jun 2017 11:35:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="u9bjASW6"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wy5372sJgzDr4C for ; Wed, 28 Jun 2017 11:35:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="u9bjASW6"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wy4zn4WJSzDr3d for ; Wed, 28 Jun 2017 11:32:53 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="u9bjASW6"; dkim-atps=neutral Received: by mail-pf0-x242.google.com with SMTP id z6so6851952pfk.3 for ; Tue, 27 Jun 2017 18:32:53 -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=RMtAdM2wXcn1iHyff7DvwrB/f/rx66owqPu3Owo5Mdg=; b=u9bjASW6RFABV0AKpKTg6AVXrkmcXVQC8ljdUaWOiqpqFEc2aSl8geYvmZ1dPaybQu IHik+tUx8u49aPDyh3ODHZZsTyu6ZD+LB7J0UFUVwwRy5cSZomorXmvaGpn0K6LavLuk 94ebko13eit3xqmcsBdSz+4scwCgzb7WiQfG8sqWWxksAsI5nERIu6nHCSc5uuvRFkG0 /TwNbNFoehH2VqR4RwBFvgfDovnbMWm7K6RxdvHtJ1/MglqwP5O9CFMe2xl+u+MoiSiw PaGVbubBIAq2DclPNMcuZbdTlZq//cr7MwremmpCrKlqOsLQKJQpnQM8tMaftHXDak28 8Uvw== 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=RMtAdM2wXcn1iHyff7DvwrB/f/rx66owqPu3Owo5Mdg=; b=nroxWhA/jLb+MxVPKjW0LXrb0fhP9cAnyax5GQYiW6TbBmlp7bLoi40jOkLfNEf0ak yDV8vhLh+muM+E8GQ0V15WnHsLy2aKuj4HwaQ4r0vFJ6/UZjxp6aRdrB7NxXxWKqzW+A GHypMl31Gnlg96MT14VaI6DJSCd6+UA/FhHJwl4AmPBw/9nZu0/5oqbXLuAEAKkqc++Z B44VEiFTOvaPUxhtj41/UXnSK3ugfCR3WPf3vmsbPVzxRyC1tQ7sLuiDl3R6HhxN94hf 3ZKLyC+hB1I5RpCv0hJWF38CklHakfVAyn6S1c6p6AEAsIKv5PDYTis3Zu25/R0V2ulE OoZw== X-Gm-Message-State: AKS2vOzP7QGnYERkGJhbcQtxmUv/hITtonFjN/TNvi0ZCpV4HFL99CpT fPbbwJrBu7sVXMM7 X-Received: by 10.98.82.87 with SMTP id g84mr8092876pfb.232.1498613571698; Tue, 27 Jun 2017 18:32:51 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id b85sm901938pfe.94.2017.06.27.18.32.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Jun 2017 18:32:51 -0700 (PDT) From: Oliver O'Halloran To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH v4 2/6] powerpc/vmemmap: Reshuffle vmemmap_free() Date: Wed, 28 Jun 2017 11:32:32 +1000 Message-Id: <20170628013236.413-2-oohall@gmail.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170628013236.413-1-oohall@gmail.com> References: <20170628013236.413-1-oohall@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Oliver O'Halloran Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Removes an indentation level and shuffles some code around to make the following patch cleaner. No functional changes. Reviewed-by: Balbir Singh Signed-off-by: Oliver O'Halloran --- v1 -> v2: Remove broken initialiser --- arch/powerpc/mm/init_64.c | 48 ++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c index ec84b31c6c86..8851e4f5dbab 100644 --- a/arch/powerpc/mm/init_64.c +++ b/arch/powerpc/mm/init_64.c @@ -234,13 +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) { - unsigned long addr; + unsigned long nr_pages, addr; + struct page *page; /* * the section has already be marked as invalid, so @@ -251,29 +253,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