From patchwork Tue Oct 9 21:39:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 190466 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 8DA1C2C041F for ; Wed, 10 Oct 2012 08:40:04 +1100 (EST) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) by ozlabs.org (Postfix) with ESMTP id B4A9F2C0090 for ; Wed, 10 Oct 2012 08:39:38 +1100 (EST) Received: from akpm.mtv.corp.google.com (216-239-45-4.google.com [216.239.45.4]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E38EC9B4; Tue, 9 Oct 2012 21:39:36 +0000 (UTC) Date: Tue, 9 Oct 2012 14:39:36 -0700 From: Andrew Morton To: Yasuaki Ishimatsu Subject: Re: memory-hotplug : suppres "Trying to free nonexistent resource " warning Message-Id: <20121009143936.1f74a7fb.akpm@linux-foundation.org> In-Reply-To: <5073913A.3080103@jp.fujitsu.com> References: <506D1F1D.9000301@jp.fujitsu.com> <20121005140938.e3e1e196.akpm@linux-foundation.org> <5073913A.3080103@jp.fujitsu.com> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Cc: len.brown@intel.com, wency@cn.fujitsu.com, linux-acpi@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, dave@linux.vnet.ibm.com, linux-mm@kvack.org, paulus@samba.org, minchan.kim@gmail.com, kosaki.motohiro@jp.fujitsu.com, rientjes@google.com, cl@linux.com, linuxppc-dev@lists.ozlabs.org, liuj97@gmail.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, 9 Oct 2012 11:51:38 +0900 Yasuaki Ishimatsu wrote: > > Anyway, please have a think, and see if we can come up with the best > > and most accurate choice of types and identifiers in this code. > > Your concern is right. Overflow bug may occur in the future. > So I changed type of "i" and "sections_to_remove" to "unsigned long". > Please merge it into your tree instead of previous patch. Too late, the original patch was merged. So I generated the delta. I remain allergic to the `i' identifier so I renamed it to `section'. That's not 100% accurate, but it is better. > __remove_pages() also has same concern. So I'll fix it. Thanks. From: Yasuaki Ishimatsu Subject: arch/powerpc/platforms/pseries/hotplug-memory.c: section removal cleanups Followups to d760afd4d25 ("memory-hotplug: suppress "Trying to free nonexistent resource " warning"). - use unsigned long type, as overflows are conceivable - rename `i' to the less-misleading and more informative `section' Cc: Benjamin Herrenschmidt Signed-off-by: Andrew Morton --- arch/powerpc/platforms/pseries/hotplug-memory.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff -puN mm/memory_hotplug.c~arch-powerpc-platforms-pseries-hotplug-memoryc-section-removal-cleanups mm/memory_hotplug.c diff -puN arch/powerpc/platforms/pseries/hotplug-memory.c~arch-powerpc-platforms-pseries-hotplug-memoryc-section-removal-cleanups arch/powerpc/platforms/pseries/hotplug-memory.c --- a/arch/powerpc/platforms/pseries/hotplug-memory.c~arch-powerpc-platforms-pseries-hotplug-memoryc-section-removal-cleanups +++ a/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -77,8 +77,9 @@ static int pseries_remove_memblock(unsig { unsigned long start, start_pfn; struct zone *zone; - int i, ret; - int sections_to_remove; + int ret; + unsigned long section; + unsigned long sections_to_remove; start_pfn = base >> PAGE_SHIFT; @@ -99,8 +100,8 @@ static int pseries_remove_memblock(unsig * while writing to it. So we have to defer it to here. */ sections_to_remove = (memblock_size >> PAGE_SHIFT) / PAGES_PER_SECTION; - for (i = 0; i < sections_to_remove; i++) { - unsigned long pfn = start_pfn + i * PAGES_PER_SECTION; + for (section = 0; section < sections_to_remove; section++) { + unsigned long pfn = start_pfn + section * PAGES_PER_SECTION; ret = __remove_pages(zone, start_pfn, PAGES_PER_SECTION); if (ret) return ret;