From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jianguo Wu Subject: Re: [Patch v4 09/12] memory-hotplug: remove page table of x86_64 architecture Date: Fri, 7 Dec 2012 15:06:16 +0800 Message-ID: <50C19568.7080500@huawei.com> References: <1354010422-19648-1-git-send-email-wency@cn.fujitsu.com> <1354010422-19648-10-git-send-email-wency@cn.fujitsu.com> <50C19022.9000501@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <50C19022.9000501@cn.fujitsu.com> Sender: linux-kernel-owner@vger.kernel.org To: Tang Chen Cc: Wen Congyang , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-ia64@vger.kernel.org, cmetcalf@tilera.com, sparclinux@vger.kernel.org, David Rientjes , Jiang Liu , Len Brown , benh@kernel.crashing.org, paulus@samba.org, Christoph Lameter , Minchan Kim , Andrew Morton , KOSAKI Motohiro , Yasuaki Ishimatsu , Jiang Liu List-Id: linux-acpi@vger.kernel.org On 2012/12/7 14:43, Tang Chen wrote: > On 11/27/2012 06:00 PM, Wen Congyang wrote: >> For hot removing memory, we sholud remove page table about the memory. >> So the patch searches a page table about the removed memory, and clear >> page table. > > (snip) > >> +void __meminit >> +kernel_physical_mapping_remove(unsigned long start, unsigned long end) >> +{ >> + unsigned long next; >> + bool pgd_changed = false; >> + >> + start = (unsigned long)__va(start); >> + end = (unsigned long)__va(end); > > Hi Wu, > > Here, you expect start and end are physical addresses. But in > phys_xxx_remove() function, I think using virtual addresses is just > fine. Functions like pmd_addr_end() and pud_index() only calculate > an offset. > Hi Tang, Virtual addresses will work fine, I used physical addresses in order to keep consistent with phys_pud[pmd/pte]_init(), So I think we should keep this. Thanks, Jianguo Wu > So, would you please tell me if we have to use physical addresses here ? > > Thanks. :) > >> + >> + for (; start< end; start = next) { >> + pgd_t *pgd = pgd_offset_k(start); >> + pud_t *pud; >> + >> + next = pgd_addr_end(start, end); >> + >> + if (!pgd_present(*pgd)) >> + continue; >> + >> + pud = map_low_page((pud_t *)pgd_page_vaddr(*pgd)); >> + phys_pud_remove(pud, __pa(start), __pa(next)); >> + if (free_pud_table(pud, pgd)) >> + pgd_changed = true; >> + unmap_low_page(pud); >> + } >> + >> + if (pgd_changed) >> + sync_global_pgds(start, end - 1); >> + >> + flush_tlb_all(); >> +} >> + >> #ifdef CONFIG_MEMORY_HOTREMOVE >> int __ref arch_remove_memory(u64 start, u64 size) >> { >> @@ -692,6 +921,8 @@ int __ref arch_remove_memory(u64 start, u64 size) >> ret = __remove_pages(zone, start_pfn, nr_pages); >> WARN_ON_ONCE(ret); >> >> + kernel_physical_mapping_remove(start, start + size); >> + >> return ret; >> } >> #endif > > > > . > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jianguo Wu Date: Fri, 07 Dec 2012 07:06:16 +0000 Subject: Re: [Patch v4 09/12] memory-hotplug: remove page table of x86_64 architecture Message-Id: <50C19568.7080500@huawei.com> List-Id: References: <1354010422-19648-1-git-send-email-wency@cn.fujitsu.com> <1354010422-19648-10-git-send-email-wency@cn.fujitsu.com> <50C19022.9000501@cn.fujitsu.com> In-Reply-To: <50C19022.9000501@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Tang Chen Cc: Wen Congyang , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-ia64@vger.kernel.org, cmetcalf@tilera.com, sparclinux@vger.kernel.org, David Rientjes , Jiang Liu , Len Brown , benh@kernel.crashing.org, paulus@samba.org, Christoph Lameter , Minchan Kim , Andrew Morton , KOSAKI Motohiro , Yasuaki Ishimatsu , Jiang Liu On 2012/12/7 14:43, Tang Chen wrote: > On 11/27/2012 06:00 PM, Wen Congyang wrote: >> For hot removing memory, we sholud remove page table about the memory. >> So the patch searches a page table about the removed memory, and clear >> page table. > > (snip) > >> +void __meminit >> +kernel_physical_mapping_remove(unsigned long start, unsigned long end) >> +{ >> + unsigned long next; >> + bool pgd_changed = false; >> + >> + start = (unsigned long)__va(start); >> + end = (unsigned long)__va(end); > > Hi Wu, > > Here, you expect start and end are physical addresses. But in > phys_xxx_remove() function, I think using virtual addresses is just > fine. Functions like pmd_addr_end() and pud_index() only calculate > an offset. > Hi Tang, Virtual addresses will work fine, I used physical addresses in order to keep consistent with phys_pud[pmd/pte]_init(), So I think we should keep this. Thanks, Jianguo Wu > So, would you please tell me if we have to use physical addresses here ? > > Thanks. :) > >> + >> + for (; start< end; start = next) { >> + pgd_t *pgd = pgd_offset_k(start); >> + pud_t *pud; >> + >> + next = pgd_addr_end(start, end); >> + >> + if (!pgd_present(*pgd)) >> + continue; >> + >> + pud = map_low_page((pud_t *)pgd_page_vaddr(*pgd)); >> + phys_pud_remove(pud, __pa(start), __pa(next)); >> + if (free_pud_table(pud, pgd)) >> + pgd_changed = true; >> + unmap_low_page(pud); >> + } >> + >> + if (pgd_changed) >> + sync_global_pgds(start, end - 1); >> + >> + flush_tlb_all(); >> +} >> + >> #ifdef CONFIG_MEMORY_HOTREMOVE >> int __ref arch_remove_memory(u64 start, u64 size) >> { >> @@ -692,6 +921,8 @@ int __ref arch_remove_memory(u64 start, u64 size) >> ret = __remove_pages(zone, start_pfn, nr_pages); >> WARN_ON_ONCE(ret); >> >> + kernel_physical_mapping_remove(start, start + size); >> + >> return ret; >> } >> #endif > > > > . > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [119.145.14.64]) by ozlabs.org (Postfix) with ESMTP id D3F0C2C00DA for ; Fri, 7 Dec 2012 18:06:47 +1100 (EST) Message-ID: <50C19568.7080500@huawei.com> Date: Fri, 7 Dec 2012 15:06:16 +0800 From: Jianguo Wu MIME-Version: 1.0 To: Tang Chen Subject: Re: [Patch v4 09/12] memory-hotplug: remove page table of x86_64 architecture References: <1354010422-19648-1-git-send-email-wency@cn.fujitsu.com> <1354010422-19648-10-git-send-email-wency@cn.fujitsu.com> <50C19022.9000501@cn.fujitsu.com> In-Reply-To: <50C19022.9000501@cn.fujitsu.com> Content-Type: text/plain; charset="UTF-8" Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, linux-mm@kvack.org, paulus@samba.org, sparclinux@vger.kernel.org, Christoph Lameter , linux-s390@vger.kernel.org, x86@kernel.org, linux-acpi@vger.kernel.org, Yasuaki Ishimatsu , KOSAKI Motohiro , David Rientjes , Jiang Liu , Len Brown , Jiang Liu , Wen Congyang , cmetcalf@tilera.com, linux-kernel@vger.kernel.org, Minchan Kim , Andrew Morton , linuxppc-dev@lists.ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On 2012/12/7 14:43, Tang Chen wrote: > On 11/27/2012 06:00 PM, Wen Congyang wrote: >> For hot removing memory, we sholud remove page table about the memory. >> So the patch searches a page table about the removed memory, and clear >> page table. > > (snip) > >> +void __meminit >> +kernel_physical_mapping_remove(unsigned long start, unsigned long end) >> +{ >> + unsigned long next; >> + bool pgd_changed = false; >> + >> + start = (unsigned long)__va(start); >> + end = (unsigned long)__va(end); > > Hi Wu, > > Here, you expect start and end are physical addresses. But in > phys_xxx_remove() function, I think using virtual addresses is just > fine. Functions like pmd_addr_end() and pud_index() only calculate > an offset. > Hi Tang, Virtual addresses will work fine, I used physical addresses in order to keep consistent with phys_pud[pmd/pte]_init(), So I think we should keep this. Thanks, Jianguo Wu > So, would you please tell me if we have to use physical addresses here ? > > Thanks. :) > >> + >> + for (; start< end; start = next) { >> + pgd_t *pgd = pgd_offset_k(start); >> + pud_t *pud; >> + >> + next = pgd_addr_end(start, end); >> + >> + if (!pgd_present(*pgd)) >> + continue; >> + >> + pud = map_low_page((pud_t *)pgd_page_vaddr(*pgd)); >> + phys_pud_remove(pud, __pa(start), __pa(next)); >> + if (free_pud_table(pud, pgd)) >> + pgd_changed = true; >> + unmap_low_page(pud); >> + } >> + >> + if (pgd_changed) >> + sync_global_pgds(start, end - 1); >> + >> + flush_tlb_all(); >> +} >> + >> #ifdef CONFIG_MEMORY_HOTREMOVE >> int __ref arch_remove_memory(u64 start, u64 size) >> { >> @@ -692,6 +921,8 @@ int __ref arch_remove_memory(u64 start, u64 size) >> ret = __remove_pages(zone, start_pfn, nr_pages); >> WARN_ON_ONCE(ret); >> >> + kernel_physical_mapping_remove(start, start + size); >> + >> return ret; >> } >> #endif > > > > . > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx135.postini.com [74.125.245.135]) by kanga.kvack.org (Postfix) with SMTP id 9C4226B005D for ; Fri, 7 Dec 2012 02:07:42 -0500 (EST) Message-ID: <50C19568.7080500@huawei.com> Date: Fri, 7 Dec 2012 15:06:16 +0800 From: Jianguo Wu MIME-Version: 1.0 Subject: Re: [Patch v4 09/12] memory-hotplug: remove page table of x86_64 architecture References: <1354010422-19648-1-git-send-email-wency@cn.fujitsu.com> <1354010422-19648-10-git-send-email-wency@cn.fujitsu.com> <50C19022.9000501@cn.fujitsu.com> In-Reply-To: <50C19022.9000501@cn.fujitsu.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Tang Chen Cc: Wen Congyang , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-ia64@vger.kernel.org, cmetcalf@tilera.com, sparclinux@vger.kernel.org, David Rientjes , Jiang Liu , Len Brown , benh@kernel.crashing.org, paulus@samba.org, Christoph Lameter , Minchan Kim , Andrew Morton , KOSAKI Motohiro , Yasuaki Ishimatsu , Jiang Liu On 2012/12/7 14:43, Tang Chen wrote: > On 11/27/2012 06:00 PM, Wen Congyang wrote: >> For hot removing memory, we sholud remove page table about the memory. >> So the patch searches a page table about the removed memory, and clear >> page table. > > (snip) > >> +void __meminit >> +kernel_physical_mapping_remove(unsigned long start, unsigned long end) >> +{ >> + unsigned long next; >> + bool pgd_changed = false; >> + >> + start = (unsigned long)__va(start); >> + end = (unsigned long)__va(end); > > Hi Wu, > > Here, you expect start and end are physical addresses. But in > phys_xxx_remove() function, I think using virtual addresses is just > fine. Functions like pmd_addr_end() and pud_index() only calculate > an offset. > Hi Tang, Virtual addresses will work fine, I used physical addresses in order to keep consistent with phys_pud[pmd/pte]_init(), So I think we should keep this. Thanks, Jianguo Wu > So, would you please tell me if we have to use physical addresses here ? > > Thanks. :) > >> + >> + for (; start< end; start = next) { >> + pgd_t *pgd = pgd_offset_k(start); >> + pud_t *pud; >> + >> + next = pgd_addr_end(start, end); >> + >> + if (!pgd_present(*pgd)) >> + continue; >> + >> + pud = map_low_page((pud_t *)pgd_page_vaddr(*pgd)); >> + phys_pud_remove(pud, __pa(start), __pa(next)); >> + if (free_pud_table(pud, pgd)) >> + pgd_changed = true; >> + unmap_low_page(pud); >> + } >> + >> + if (pgd_changed) >> + sync_global_pgds(start, end - 1); >> + >> + flush_tlb_all(); >> +} >> + >> #ifdef CONFIG_MEMORY_HOTREMOVE >> int __ref arch_remove_memory(u64 start, u64 size) >> { >> @@ -692,6 +921,8 @@ int __ref arch_remove_memory(u64 start, u64 size) >> ret = __remove_pages(zone, start_pfn, nr_pages); >> WARN_ON_ONCE(ret); >> >> + kernel_physical_mapping_remove(start, start + size); >> + >> return ret; >> } >> #endif > > > > . > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: 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 S1755336Ab2LGHGp (ORCPT ); Fri, 7 Dec 2012 02:06:45 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:20368 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753493Ab2LGHGm (ORCPT ); Fri, 7 Dec 2012 02:06:42 -0500 Message-ID: <50C19568.7080500@huawei.com> Date: Fri, 7 Dec 2012 15:06:16 +0800 From: Jianguo Wu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Tang Chen CC: Wen Congyang , , , , , , , , , , , David Rientjes , Jiang Liu , Len Brown , , , Christoph Lameter , Minchan Kim , Andrew Morton , KOSAKI Motohiro , Yasuaki Ishimatsu , Jiang Liu Subject: Re: [Patch v4 09/12] memory-hotplug: remove page table of x86_64 architecture References: <1354010422-19648-1-git-send-email-wency@cn.fujitsu.com> <1354010422-19648-10-git-send-email-wency@cn.fujitsu.com> <50C19022.9000501@cn.fujitsu.com> In-Reply-To: <50C19022.9000501@cn.fujitsu.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.135.74.216] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2012/12/7 14:43, Tang Chen wrote: > On 11/27/2012 06:00 PM, Wen Congyang wrote: >> For hot removing memory, we sholud remove page table about the memory. >> So the patch searches a page table about the removed memory, and clear >> page table. > > (snip) > >> +void __meminit >> +kernel_physical_mapping_remove(unsigned long start, unsigned long end) >> +{ >> + unsigned long next; >> + bool pgd_changed = false; >> + >> + start = (unsigned long)__va(start); >> + end = (unsigned long)__va(end); > > Hi Wu, > > Here, you expect start and end are physical addresses. But in > phys_xxx_remove() function, I think using virtual addresses is just > fine. Functions like pmd_addr_end() and pud_index() only calculate > an offset. > Hi Tang, Virtual addresses will work fine, I used physical addresses in order to keep consistent with phys_pud[pmd/pte]_init(), So I think we should keep this. Thanks, Jianguo Wu > So, would you please tell me if we have to use physical addresses here ? > > Thanks. :) > >> + >> + for (; start< end; start = next) { >> + pgd_t *pgd = pgd_offset_k(start); >> + pud_t *pud; >> + >> + next = pgd_addr_end(start, end); >> + >> + if (!pgd_present(*pgd)) >> + continue; >> + >> + pud = map_low_page((pud_t *)pgd_page_vaddr(*pgd)); >> + phys_pud_remove(pud, __pa(start), __pa(next)); >> + if (free_pud_table(pud, pgd)) >> + pgd_changed = true; >> + unmap_low_page(pud); >> + } >> + >> + if (pgd_changed) >> + sync_global_pgds(start, end - 1); >> + >> + flush_tlb_all(); >> +} >> + >> #ifdef CONFIG_MEMORY_HOTREMOVE >> int __ref arch_remove_memory(u64 start, u64 size) >> { >> @@ -692,6 +921,8 @@ int __ref arch_remove_memory(u64 start, u64 size) >> ret = __remove_pages(zone, start_pfn, nr_pages); >> WARN_ON_ONCE(ret); >> >> + kernel_physical_mapping_remove(start, start + size); >> + >> return ret; >> } >> #endif > > > > . >