From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yasuaki Ishimatsu Subject: [RFC PATCH 2/12] memory-hogplug : check memory offline in offline_pages Date: Wed, 27 Jun 2012 14:44:17 +0900 Message-ID: <4FEA9DB1.7010303@jp.fujitsu.com> References: <4FEA9C88.1070800@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-2022-JP" Content-Transfer-Encoding: 7bit Return-path: Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:39736 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750708Ab2F0Fof (ORCPT ); Wed, 27 Jun 2012 01:44:35 -0400 In-Reply-To: <4FEA9C88.1070800@jp.fujitsu.com> Sender: linux-acpi-owner@vger.kernel.org List-Id: linux-acpi@vger.kernel.org To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org Cc: len.brown@intel.com, benh@kernel.crashing.org, paulus@samba.org, cl@linux.com, minchan.kim@gmail.com, akpm@linux-foundation.org, kosaki.motohiro@jp.fujitsu.com, wency@cn.fujitsu.com When offline_pages() is called to offlined memory, the function fails since all memory has been offlined. In this case, the function should succeed. The patch adds the check function into offline_pages(). CC: Len Brown CC: Benjamin Herrenschmidt CC: Paul Mackerras CC: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 20 ++++++++++++++++++++ include/linux/memory.h | 1 + mm/memory_hotplug.c | 5 +++++ 3 files changed, 26 insertions(+) Index: linux-3.5-rc4/drivers/base/memory.c =================================================================== --- linux-3.5-rc4.orig/drivers/base/memory.c 2012-06-26 13:28:16.726211752 +0900 +++ linux-3.5-rc4/drivers/base/memory.c 2012-06-26 13:34:22.423639904 +0900 @@ -70,6 +70,26 @@ void unregister_memory_isolate_notifier( } EXPORT_SYMBOL(unregister_memory_isolate_notifier); +bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn) +{ + struct memory_block *mem; + struct mem_section *section; + unsigned long pfn, section_nr; + + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + section_nr = pfn_to_section_nr(pfn); + section = __nr_to_section(section_nr); + mem = find_memory_block(section); + if (!mem) + continue; + if (mem->state == MEM_OFFLINE) + continue; + return false; + } + + return true; +} + /* * register_memory - Setup a sysfs device for a memory block */ Index: linux-3.5-rc4/include/linux/memory.h =================================================================== --- linux-3.5-rc4.orig/include/linux/memory.h 2012-06-25 04:53:04.000000000 +0900 +++ linux-3.5-rc4/include/linux/memory.h 2012-06-26 13:34:22.424639891 +0900 @@ -120,6 +120,7 @@ extern int memory_isolate_notify(unsigne extern struct memory_block *find_memory_block_hinted(struct mem_section *, struct memory_block *); extern struct memory_block *find_memory_block(struct mem_section *); +extern bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn); #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION< Received: from fgwmail8.fujitsu.co.jp (fgwmail8.fujitsu.co.jp [192.51.44.38]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9471DB6FBA for ; Wed, 27 Jun 2012 15:51:50 +1000 (EST) Received: from fgwmail6.fujitsu.co.jp (fgwmail6.fujitsu.co.jp [192.51.44.36]) by fgwmail8.fujitsu.co.jp (Postfix) with ESMTP id 0F0011793B54 for ; Wed, 27 Jun 2012 14:44:37 +0900 (JST) Received: from m2.gw.fujitsu.co.jp (unknown [10.0.50.72]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id E37A63EE0AE for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id CD86045DD78 for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id AD2D245DD74 for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 9F702E18004 for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Received: from g01jpexchkw07.g01.fujitsu.local (g01jpexchkw07.g01.fujitsu.local [10.0.194.46]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 5B5C21DB802C for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Message-ID: <4FEA9DB1.7010303@jp.fujitsu.com> Date: Wed, 27 Jun 2012 14:44:17 +0900 From: Yasuaki Ishimatsu MIME-Version: 1.0 To: , , , Subject: [RFC PATCH 2/12] memory-hogplug : check memory offline in offline_pages References: <4FEA9C88.1070800@jp.fujitsu.com> In-Reply-To: <4FEA9C88.1070800@jp.fujitsu.com> Content-Type: text/plain; charset="ISO-2022-JP" Cc: len.brown@intel.com, wency@cn.fujitsu.com, paulus@samba.org, minchan.kim@gmail.com, kosaki.motohiro@jp.fujitsu.com, cl@linux.com, akpm@linux-foundation.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , When offline_pages() is called to offlined memory, the function fails since all memory has been offlined. In this case, the function should succeed. The patch adds the check function into offline_pages(). CC: Len Brown CC: Benjamin Herrenschmidt CC: Paul Mackerras CC: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 20 ++++++++++++++++++++ include/linux/memory.h | 1 + mm/memory_hotplug.c | 5 +++++ 3 files changed, 26 insertions(+) Index: linux-3.5-rc4/drivers/base/memory.c =================================================================== --- linux-3.5-rc4.orig/drivers/base/memory.c 2012-06-26 13:28:16.726211752 +0900 +++ linux-3.5-rc4/drivers/base/memory.c 2012-06-26 13:34:22.423639904 +0900 @@ -70,6 +70,26 @@ void unregister_memory_isolate_notifier( } EXPORT_SYMBOL(unregister_memory_isolate_notifier); +bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn) +{ + struct memory_block *mem; + struct mem_section *section; + unsigned long pfn, section_nr; + + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + section_nr = pfn_to_section_nr(pfn); + section = __nr_to_section(section_nr); + mem = find_memory_block(section); + if (!mem) + continue; + if (mem->state == MEM_OFFLINE) + continue; + return false; + } + + return true; +} + /* * register_memory - Setup a sysfs device for a memory block */ Index: linux-3.5-rc4/include/linux/memory.h =================================================================== --- linux-3.5-rc4.orig/include/linux/memory.h 2012-06-25 04:53:04.000000000 +0900 +++ linux-3.5-rc4/include/linux/memory.h 2012-06-26 13:34:22.424639891 +0900 @@ -120,6 +120,7 @@ extern int memory_isolate_notify(unsigne extern struct memory_block *find_memory_block_hinted(struct mem_section *, struct memory_block *); extern struct memory_block *find_memory_block(struct mem_section *); +extern bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn); #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION< Received: from psmtp.com (na3sys010amx205.postini.com [74.125.245.205]) by kanga.kvack.org (Postfix) with SMTP id B1E786B005A for ; Wed, 27 Jun 2012 01:44:36 -0400 (EDT) Received: from m3.gw.fujitsu.co.jp (unknown [10.0.50.73]) by fgwmail5.fujitsu.co.jp (Postfix) with ESMTP id F24763EE0BD for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Received: from smail (m3 [127.0.0.1]) by outgoing.m3.gw.fujitsu.co.jp (Postfix) with ESMTP id D850F45DEB2 for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (s3.gw.fujitsu.co.jp [10.0.50.93]) by m3.gw.fujitsu.co.jp (Postfix) with ESMTP id B2A7045DE9E for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Received: from s3.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id A5BEC1DB803E for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Received: from g01jpexchkw07.g01.fujitsu.local (g01jpexchkw07.g01.fujitsu.local [10.0.194.46]) by s3.gw.fujitsu.co.jp (Postfix) with ESMTP id 560E51DB803B for ; Wed, 27 Jun 2012 14:44:34 +0900 (JST) Message-ID: <4FEA9DB1.7010303@jp.fujitsu.com> Date: Wed, 27 Jun 2012 14:44:17 +0900 From: Yasuaki Ishimatsu MIME-Version: 1.0 Subject: [RFC PATCH 2/12] memory-hogplug : check memory offline in offline_pages References: <4FEA9C88.1070800@jp.fujitsu.com> In-Reply-To: <4FEA9C88.1070800@jp.fujitsu.com> Content-Type: text/plain; charset="ISO-2022-JP" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org Cc: len.brown@intel.com, benh@kernel.crashing.org, paulus@samba.org, cl@linux.com, minchan.kim@gmail.com, akpm@linux-foundation.org, kosaki.motohiro@jp.fujitsu.com, wency@cn.fujitsu.com When offline_pages() is called to offlined memory, the function fails since all memory has been offlined. In this case, the function should succeed. The patch adds the check function into offline_pages(). CC: Len Brown CC: Benjamin Herrenschmidt CC: Paul Mackerras CC: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 20 ++++++++++++++++++++ include/linux/memory.h | 1 + mm/memory_hotplug.c | 5 +++++ 3 files changed, 26 insertions(+) Index: linux-3.5-rc4/drivers/base/memory.c =================================================================== --- linux-3.5-rc4.orig/drivers/base/memory.c 2012-06-26 13:28:16.726211752 +0900 +++ linux-3.5-rc4/drivers/base/memory.c 2012-06-26 13:34:22.423639904 +0900 @@ -70,6 +70,26 @@ void unregister_memory_isolate_notifier( } EXPORT_SYMBOL(unregister_memory_isolate_notifier); +bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn) +{ + struct memory_block *mem; + struct mem_section *section; + unsigned long pfn, section_nr; + + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + section_nr = pfn_to_section_nr(pfn); + section = __nr_to_section(section_nr); + mem = find_memory_block(section); + if (!mem) + continue; + if (mem->state == MEM_OFFLINE) + continue; + return false; + } + + return true; +} + /* * register_memory - Setup a sysfs device for a memory block */ Index: linux-3.5-rc4/include/linux/memory.h =================================================================== --- linux-3.5-rc4.orig/include/linux/memory.h 2012-06-25 04:53:04.000000000 +0900 +++ linux-3.5-rc4/include/linux/memory.h 2012-06-26 13:34:22.424639891 +0900 @@ -120,6 +120,7 @@ extern int memory_isolate_notify(unsigne extern struct memory_block *find_memory_block_hinted(struct mem_section *, struct memory_block *); extern struct memory_block *find_memory_block(struct mem_section *); +extern bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn); #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION< email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755689Ab2F0Foi (ORCPT ); Wed, 27 Jun 2012 01:44:38 -0400 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:39736 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750708Ab2F0Fof (ORCPT ); Wed, 27 Jun 2012 01:44:35 -0400 X-SecurityPolicyCheck: OK by SHieldMailChecker v1.7.4 Message-ID: <4FEA9DB1.7010303@jp.fujitsu.com> Date: Wed, 27 Jun 2012 14:44:17 +0900 From: Yasuaki Ishimatsu User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 MIME-Version: 1.0 To: , , , CC: , , , , , , , Subject: [RFC PATCH 2/12] memory-hogplug : check memory offline in offline_pages References: <4FEA9C88.1070800@jp.fujitsu.com> In-Reply-To: <4FEA9C88.1070800@jp.fujitsu.com> Content-Type: text/plain; charset="ISO-2022-JP" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When offline_pages() is called to offlined memory, the function fails since all memory has been offlined. In this case, the function should succeed. The patch adds the check function into offline_pages(). CC: Len Brown CC: Benjamin Herrenschmidt CC: Paul Mackerras CC: Christoph Lameter Cc: Minchan Kim CC: Andrew Morton CC: KOSAKI Motohiro CC: Wen Congyang Signed-off-by: Yasuaki Ishimatsu --- drivers/base/memory.c | 20 ++++++++++++++++++++ include/linux/memory.h | 1 + mm/memory_hotplug.c | 5 +++++ 3 files changed, 26 insertions(+) Index: linux-3.5-rc4/drivers/base/memory.c =================================================================== --- linux-3.5-rc4.orig/drivers/base/memory.c 2012-06-26 13:28:16.726211752 +0900 +++ linux-3.5-rc4/drivers/base/memory.c 2012-06-26 13:34:22.423639904 +0900 @@ -70,6 +70,26 @@ void unregister_memory_isolate_notifier( } EXPORT_SYMBOL(unregister_memory_isolate_notifier); +bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn) +{ + struct memory_block *mem; + struct mem_section *section; + unsigned long pfn, section_nr; + + for (pfn = start_pfn; pfn < end_pfn; pfn += PAGES_PER_SECTION) { + section_nr = pfn_to_section_nr(pfn); + section = __nr_to_section(section_nr); + mem = find_memory_block(section); + if (!mem) + continue; + if (mem->state == MEM_OFFLINE) + continue; + return false; + } + + return true; +} + /* * register_memory - Setup a sysfs device for a memory block */ Index: linux-3.5-rc4/include/linux/memory.h =================================================================== --- linux-3.5-rc4.orig/include/linux/memory.h 2012-06-25 04:53:04.000000000 +0900 +++ linux-3.5-rc4/include/linux/memory.h 2012-06-26 13:34:22.424639891 +0900 @@ -120,6 +120,7 @@ extern int memory_isolate_notify(unsigne extern struct memory_block *find_memory_block_hinted(struct mem_section *, struct memory_block *); extern struct memory_block *find_memory_block(struct mem_section *); +extern bool memory_is_offline(unsigned long start_pfn, unsigned long end_pfn); #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<