Re: [PATCH v5 31/45] blackfin/smp: Use get/put_online_cpus_atomic() to prevent CPU offline
On Tue, Jan 22, 2013 at 3:41 PM, Srivatsa S. Bhat wrote: > Once stop_machine() is gone from the CPU offline path, we won't be able to > depend on preempt_disable() or local_irq_disable() to prevent CPUs from > going offline from under us. > > Use the get/put_online_cpus_atomic() APIs to prevent CPUs from going offline, > while invoking from atomic context. > > Cc: Mike Frysinger > Cc: Bob Liu > Cc: Steven Miao > Cc: uclinux-dist-de...@blackfin.uclinux.org > Signed-off-by: Srivatsa S. Bhat Thanks, will be applied to my blackfin arch tree. > --- > > arch/blackfin/mach-common/smp.c |6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/blackfin/mach-common/smp.c b/arch/blackfin/mach-common/smp.c > index bb61ae4..6cc6d7a 100644 > --- a/arch/blackfin/mach-common/smp.c > +++ b/arch/blackfin/mach-common/smp.c > @@ -194,6 +194,7 @@ void send_ipi(const struct cpumask *cpumask, enum > ipi_message_type msg) > struct ipi_data *bfin_ipi_data; > unsigned long flags; > > + get_online_cpus_atomic(); > local_irq_save(flags); > smp_mb(); > for_each_cpu(cpu, cpumask) { > @@ -205,6 +206,7 @@ void send_ipi(const struct cpumask *cpumask, enum > ipi_message_type msg) > } > > local_irq_restore(flags); > + put_online_cpus_atomic(); > } > > void arch_send_call_function_single_ipi(int cpu) > @@ -238,13 +240,13 @@ void smp_send_stop(void) > { > cpumask_t callmap; > > - preempt_disable(); > + get_online_cpus_atomic(); > cpumask_copy(&callmap, cpu_online_mask); > cpumask_clear_cpu(smp_processor_id(), &callmap); > if (!cpumask_empty(&callmap)) > send_ipi(&callmap, BFIN_IPI_CPU_STOP); > > - preempt_enable(); > + put_online_cpus_atomic(); > > return; > } > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- Regards, --Bob ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH v4 7/13] memory-hotplug : remove_memory calls __remove_pages
On Wed, Jul 18, 2012 at 6:12 PM, Yasuaki Ishimatsu wrote: > The patch adds __remove_pages() to remove_memory(). Then the range of > phys_start_pfn argument and nr_pages argument in __remove_pagse() may > have different zone. So zone argument is removed from __remove_pages() > and __remove_pages() caluculates zone in each section. > > When CONFIG_SPARSEMEM_VMEMMAP is defined, there is no way to remove a memmap. > So __remove_section only calls unregister_memory_section(). > > CC: David Rientjes > CC: Jiang Liu > 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 > > --- > arch/powerpc/platforms/pseries/hotplug-memory.c |5 + > include/linux/memory_hotplug.h |3 +-- > mm/memory_hotplug.c | 19 --- > 3 files changed, 14 insertions(+), 13 deletions(-) > > Index: linux-3.5-rc6/mm/memory_hotplug.c > === > --- linux-3.5-rc6.orig/mm/memory_hotplug.c 2012-07-18 18:00:27.440145432 > +0900 > +++ linux-3.5-rc6/mm/memory_hotplug.c 2012-07-18 18:01:02.070712487 +0900 > @@ -275,11 +275,14 @@ static int __meminit __add_section(int n > #ifdef CONFIG_SPARSEMEM_VMEMMAP > static int __remove_section(struct zone *zone, struct mem_section *ms) > { > - /* > -* XXX: Freeing memmap with vmemmap is not implement yet. > -* This should be removed later. > -*/ > - return -EBUSY; > + int ret = -EINVAL; > + > + if (!valid_section(ms)) > + return ret; > + > + ret = unregister_memory_section(ms); > + I saw a patch from Jiang Liu "mm/hotplug: free zone->pageset when a zone becomes empty" to free the zone->pageset and i think there may more cleanup needed when a zone becomes empty. We already have __add_zone() in __add_section(), what about add a function like __remove_zone() to do the cleanup here? > + return ret; > } > #else > static int __remove_section(struct zone *zone, struct mem_section *ms) > @@ -346,11 +349,11 @@ EXPORT_SYMBOL_GPL(__add_pages); > * sure that pages are marked reserved and zones are adjust properly by > * calling offline_pages(). > */ > -int __remove_pages(struct zone *zone, unsigned long phys_start_pfn, > -unsigned long nr_pages) > +int __remove_pages(unsigned long phys_start_pfn, unsigned long nr_pages) > { > unsigned long i, ret = 0; > int sections_to_remove; > + struct zone *zone; > > /* > * We can only remove entire sections > @@ -363,6 +366,7 @@ int __remove_pages(struct zone *zone, un > sections_to_remove = nr_pages / PAGES_PER_SECTION; > for (i = 0; i < sections_to_remove; i++) { > unsigned long pfn = phys_start_pfn + i*PAGES_PER_SECTION; > + zone = page_zone(pfn_to_page(pfn)); > ret = __remove_section(zone, __pfn_to_section(pfn)); > if (ret) > break; > @@ -1031,6 +1035,7 @@ int __ref remove_memory(int nid, u64 sta > /* remove memmap entry */ > firmware_map_remove(start, start + size, "System RAM"); > > + __remove_pages(start >> PAGE_SHIFT, size >> PAGE_SHIFT); > out: > unlock_memory_hotplug(); > return ret; > Index: linux-3.5-rc6/include/linux/memory_hotplug.h > === > --- linux-3.5-rc6.orig/include/linux/memory_hotplug.h 2012-07-18 > 18:00:27.445145371 +0900 > +++ linux-3.5-rc6/include/linux/memory_hotplug.h2012-07-18 > 18:00:40.461982690 +0900 > @@ -89,8 +89,7 @@ extern bool is_pageblock_removable_noloc > /* reasonably generic interface to expand the physical pages in a zone */ > extern int __add_pages(int nid, struct zone *zone, unsigned long start_pfn, > unsigned long nr_pages); > -extern int __remove_pages(struct zone *zone, unsigned long start_pfn, > - unsigned long nr_pages); > +extern int __remove_pages(unsigned long start_pfn, unsigned long nr_pages); > > #ifdef CONFIG_NUMA > extern int memory_add_physaddr_to_nid(u64 start); > Index: linux-3.5-rc6/arch/powerpc/platforms/pseries/hotplug-memory.c > === > --- linux-3.5-rc6.orig/arch/powerpc/platforms/pseries/hotplug-memory.c > 2012-07-18 18:00:27.442145407 +0900 > +++ linux-3.5-rc6/arch/powerpc/platforms/pseries/hotplug-memory.c > 2012-07-18 18:00:40.470982578 +0900 > @@ -76,7 +76,6 @@ unsigned long memory_block_size_bytes(vo > static int pseries_remove_memblock(unsigned long base, unsigned int > memblock_size) > { > unsigned long start, start_pfn; > - struct zone *zone; > int i, ret; > int sections_to_remove; > > @@ -87,8 +86,6 @@ static int pseries_remove_memblock
Re: [RFC PATCH v4 1/13] memory-hotplug : rename remove_memory to offline_memory
Hi Yasuaki, On Wed, Jul 18, 2012 at 6:05 PM, Yasuaki Ishimatsu wrote: > remove_memory() does not remove memory but just offlines memory. The patch > changes name of it to offline_memory(). Since offline_memory() just align the start/end pfn and there is no matched online_memory() function, i think it's better to remove this function and add the alignment into offline_pages(). > > CC: David Rientjes > CC: Jiang Liu > 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/acpi/acpi_memhotplug.c |2 +- > drivers/base/memory.c |4 ++-- > include/linux/memory_hotplug.h |2 +- > mm/memory_hotplug.c|6 +++--- > 4 files changed, 7 insertions(+), 7 deletions(-) > > Index: linux-3.5-rc4/drivers/acpi/acpi_memhotplug.c > === > --- linux-3.5-rc4.orig/drivers/acpi/acpi_memhotplug.c 2012-07-03 > 14:21:46.102416917 +0900 > +++ linux-3.5-rc4/drivers/acpi/acpi_memhotplug.c2012-07-03 > 14:21:49.458374960 +0900 > @@ -318,7 +318,7 @@ static int acpi_memory_disable_device(st > */ > list_for_each_entry_safe(info, n, &mem_device->res_list, list) { > if (info->enabled) { > - result = remove_memory(info->start_addr, > info->length); > + result = offline_memory(info->start_addr, > info->length); > if (result) > return result; > } > Index: linux-3.5-rc4/drivers/base/memory.c > === > --- linux-3.5-rc4.orig/drivers/base/memory.c2012-07-03 14:21:46.095417003 > +0900 > +++ linux-3.5-rc4/drivers/base/memory.c 2012-07-03 14:21:49.459374948 +0900 > @@ -266,8 +266,8 @@ memory_block_action(unsigned long phys_i > break; > case MEM_OFFLINE: > start_paddr = page_to_pfn(first_page) << PAGE_SHIFT; > - ret = remove_memory(start_paddr, > - nr_pages << PAGE_SHIFT); > + ret = offline_memory(start_paddr, > +nr_pages << PAGE_SHIFT); > break; > default: > WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: " > Index: linux-3.5-rc4/mm/memory_hotplug.c > === > --- linux-3.5-rc4.orig/mm/memory_hotplug.c 2012-07-03 14:21:46.102416917 > +0900 > +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-07-03 14:21:49.466374860 +0900 > @@ -990,7 +990,7 @@ out: > return ret; > } > > -int remove_memory(u64 start, u64 size) > +int offline_memory(u64 start, u64 size) > { > unsigned long start_pfn, end_pfn; > > @@ -999,9 +999,9 @@ int remove_memory(u64 start, u64 size) > return offline_pages(start_pfn, end_pfn, 120 * HZ); > } > #else > -int remove_memory(u64 start, u64 size) > +int offline_memory(u64 start, u64 size) > { > return -EINVAL; > } > #endif /* CONFIG_MEMORY_HOTREMOVE */ > -EXPORT_SYMBOL_GPL(remove_memory); > +EXPORT_SYMBOL_GPL(offline_memory); > Index: linux-3.5-rc4/include/linux/memory_hotplug.h > === > --- linux-3.5-rc4.orig/include/linux/memory_hotplug.h 2012-07-03 > 14:21:46.102416917 +0900 > +++ linux-3.5-rc4/include/linux/memory_hotplug.h2012-07-03 > 14:21:49.471374796 +0900 > @@ -233,7 +233,7 @@ static inline int is_mem_section_removab > extern int mem_online_node(int nid); > extern int add_memory(int nid, u64 start, u64 size); > extern int arch_add_memory(int nid, u64 start, u64 size); > -extern int remove_memory(u64 start, u64 size); > +extern int offline_memory(u64 start, u64 size); > extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn, > int nr_pages); > extern void sparse_remove_one_section(struct zone *zone, struct mem_section > *ms); > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majord...@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: mailto:"d...@kvack.org";> em...@kvack.org -- Regards, --Bob ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev