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: 749581 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w2ZRM6Xlgz9sN5 for ; Wed, 12 Apr 2017 03:53:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HpFy3nsf"; 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 3w2ZRM5V0VzDq9m for ; Wed, 12 Apr 2017 03:53:35 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HpFy3nsf"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (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 3w2ZCG3RJ6zDq7h for ; Wed, 12 Apr 2017 03:43:06 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HpFy3nsf"; dkim-atps=neutral Received: by mail-pg0-x244.google.com with SMTP id g2so674704pge.2 for ; Tue, 11 Apr 2017 10:43:06 -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=OuvN+v0uPaULXRpBn/ECZKuOfZhqzm7ZqLOeWp40QLzvqeLQojSS75Ea4ONZ+bF7sA 4kW4W5KObMxqSYy6sZhm+bqs/by5kXxnggs6p1ly30rKg8DPqSuKdcNoNLr/g0BlYA4r /2+XWMB2SQ4J4LVu5UGJ+3IdyvPuGx/Ycdw5I0spoP+H7WOQz56DOo3JOErOw7j39uMP Uuy/cacAqeEzY8aroDlKIrXEHTXh0J6N4kyLgWF8WLQNZxwM91UKfmdePnvRrb/+iahr k4DHmdbA7TprmTgol9Gj5k/gdhqBxUtudb92aMUgJ9ankYDH58cW28OVKstLRNhwfNoH Avhg== X-Gm-Message-State: AN3rC/5d6V0Sc/DQ3fjDIt7OHwtUPmtYTs/x82geIFbLFeDCj4YEzg/tK9hp8eJmy9HZoQ== 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: 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 , arbab@linux.vnet.ibm.com, linux-nvdimm@lists.01.org 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. 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