Re: MPC5200b jffs2 memcpy alignment problem
Hi Albrecht, > I don't recall who proposed this patch, but exactly this solution is > around for a longer time (mayby you search archives...). On my board, I > have a flash chip attached to the LocalBus in 16-bit mode. Based on > 3.2.16, the patch is: Thanks for your answer and yes, this patch will definitely work. But I want to have a solution in the mainline kernel, that's why I'm asking how to deal best with this problem. Regards, Stephan smime.p7s Description: S/MIME Cryptographic Signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 10/12] memory-hotplug : free memmap of sparse-vmemmap
On 06/27/2012 01:56 PM, Yasuaki Ishimatsu wrote: > I don't think that all pages of virtual mapping in removed memory can be > freed, since page which type is MIX_SECTION_INFO is difficult to free. > So, the patch only frees page which type is SECTION_INFO at first. > > 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/x86/mm/init_64.c | 89 > ++ > include/linux/mm.h|2 + > mm/memory_hotplug.c |5 ++ > mm/sparse.c |5 +- > 4 files changed, 99 insertions(+), 2 deletions(-) > > Index: linux-3.5-rc4/include/linux/mm.h > === > --- linux-3.5-rc4.orig/include/linux/mm.h 2012-06-27 09:11:13.790150442 > +0900 > +++ linux-3.5-rc4/include/linux/mm.h 2012-06-27 09:11:16.433117400 +0900 > @@ -1588,6 +1588,8 @@ int vmemmap_populate(struct page *start_ > void vmemmap_populate_print_last(void); > void register_page_bootmem_memmap(unsigned long section_nr, struct page *map, > unsigned long size); > +void vmemmap_kfree(struct page *memmpa, unsigned long nr_pages); > +void vmemmap_free_bootmem(struct page *memmpa, unsigned long nr_pages); > > enum mf_flags { > MF_COUNT_INCREASED = 1 << 0, > Index: linux-3.5-rc4/mm/sparse.c > === > --- linux-3.5-rc4.orig/mm/sparse.c2012-06-27 09:06:35.317631878 +0900 > +++ linux-3.5-rc4/mm/sparse.c 2012-06-27 09:11:16.434117388 +0900 > @@ -614,12 +614,13 @@ static inline struct page *kmalloc_secti > /* This will make the necessary allocations eventually. */ > return sparse_mem_map_populate(pnum, nid); > } > -static void __kfree_section_memmap(struct page *memmap, unsigned long > nr_pages) > +static void __kfree_section_memmap(struct page *page, unsigned long nr_pages) > { > - return; /* XXX: Not implemented yet */ > + vmemmap_kfree(page, nr_pages); > } > static void free_map_bootmem(struct page *page, unsigned long nr_pages) > { > + vmemmap_free_bootmem(page, nr_pages); > } > #else > static struct page *__kmalloc_section_memmap(unsigned long nr_pages) > Index: linux-3.5-rc4/arch/x86/mm/init_64.c > === > --- linux-3.5-rc4.orig/arch/x86/mm/init_64.c 2012-06-27 09:11:13.791150430 > +0900 > +++ linux-3.5-rc4/arch/x86/mm/init_64.c 2012-06-27 09:11:59.254581998 > +0900 > @@ -978,6 +978,95 @@ vmemmap_populate(struct page *start_page > return 0; > } > > +unsigned long find_and_clear_pte_page(unsigned long addr, unsigned long end, > + struct page *page) I think the third parameter should be "struct page **pp" instead of "struct page *page". And "page = pte_page(*pte)" should be "*pp = pte_page(*pte)". Otherwise the found page pointer can't be returned to the caller and vmemmap_kfree() just sees random value in variable "page". > +{ > + pgd_t *pgd; > + pud_t *pud; > + pmd_t *pmd; > + pte_t *pte; > + unsigned long next; > + > + page = NULL; > + > + pgd = pgd_offset_k(addr); > + if (pgd_none(*pgd)) > + return PAGE_SIZE; > + > + pud = pud_offset(pgd, addr); > + if (pud_none(*pud)) > + return PAGE_SIZE; > + > + if (!cpu_has_pse) { > + next = (addr + PAGE_SIZE) & PAGE_MASK; > + pmd = pmd_offset(pud, addr); > + if (pmd_none(*pmd)) > + return next; > + > + pte = pte_offset_kernel(pmd, addr); > + if (pte_none(*pte)) > + return next; > + > + page = pte_page(*pte); > + pte_clear(&init_mm, addr, pte); > + } else { > + next = pmd_addr_end(addr, end); > + > + pmd = pmd_offset(pud, addr); > + if (pmd_none(*pmd)) > + return next; > + > + page = pmd_page(*pmd); > + pmd_clear(pmd); > + } > + > + return next; > +} > + > +void __meminit > +vmemmap_kfree(struct page *memmap, unsigned long nr_pages) > +{ > + unsigned long addr = (unsigned long)memmap; > + unsigned long end = (unsigned long)(memmap + nr_pages); > + unsigned long next; > + unsigned int order; > + struct page *page; > + > + for (; addr < end; addr = next) { > + next = find_and_clear_pte_page(addr, end, page); > + if (!page) > + continue; > + > + if (is_vmalloc_addr(page)) > + vfree(page); > + else { > + order = next - addr; > + free_pages((unsigned long)page, > +get_order(sizeof(struct page) * order)); > + }
Re: [RFC PATCH 2/12] memory-hogplug : check memory offline in offline_pages
On 06/27/2012 01:44 PM, Yasuaki Ishimatsu wrote: > 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); Seems find_memory_block_hinted() is more efficient than find_memory_block() here. > + 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.0 > +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< enum mem_add_context { BOOT, HOTPLUG }; > #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ > Index: linux-3.5-rc4/mm/memory_hotplug.c > === > --- linux-3.5-rc4.orig/mm/memory_hotplug.c2012-06-26 13:28:16.743211538 > +0900 > +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-06-26 13:48:38.264940468 +0900 > @@ -887,6 +887,11 @@ static int __ref offline_pages(unsigned > > lock_memory_hotplug(); > > + if (memory_is_offline(start_pfn, end_pfn)) { > + ret = 0; > + goto out; > + } > + > zone = page_zone(pfn_to_page(start_pfn)); > node = zone_to_nid(zone); > nr_pages = end_pfn - start_pfn; > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 2/12] memory-hogplug : check memory offline in offline_pages
On 06/27/2012 01:44 PM, Yasuaki Ishimatsu wrote: > 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); Is it possible for __nr_to_section return NULL here? > + mem = find_memory_block(section); > + if (!mem) > + continue; > + if (mem->state == MEM_OFFLINE) > + continue; > + return false; > + } > + > + return true; > +} Need a put_dev(&mem->dev) for the last memory block device handled before return. > + > /* > * 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.0 > +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< enum mem_add_context { BOOT, HOTPLUG }; > #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */ > Index: linux-3.5-rc4/mm/memory_hotplug.c > === > --- linux-3.5-rc4.orig/mm/memory_hotplug.c2012-06-26 13:28:16.743211538 > +0900 > +++ linux-3.5-rc4/mm/memory_hotplug.c 2012-06-26 13:48:38.264940468 +0900 > @@ -887,6 +887,11 @@ static int __ref offline_pages(unsigned > > lock_memory_hotplug(); > > + if (memory_is_offline(start_pfn, end_pfn)) { > + ret = 0; > + goto out; > + } > + > zone = page_zone(pfn_to_page(start_pfn)); > node = zone_to_nid(zone); > nr_pages = end_pfn - start_pfn; > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: MPC5200b jffs2 memcpy alignment problem
Hi Stephan: Am 30.06.12 21:16 schrieb(en) Stephan Gatzka: I have a problem running jffs2 on an MPC5200b board. I run kernel 3.4, but older kernels like 3.1.5 are also affected. Every time I mount jffs2, previously written content gets garbled. The problem was nailed down to memcpy(&fd->name, rd->name, checkedlen); in jffs2_scan_dirent_node in fs/jffs2/scan.c. [snip] 2. use memcpy_fromio in the jffs2 code. memcpy_fromio behaves exactly in the way I described above. This could be also a good solution because flash access via LocalPlus bus is clearly IO. I don't recall who proposed this patch, but exactly this solution is around for a longer time (mayby you search archives...). On my board, I have a flash chip attached to the LocalBus in 16-bit mode. Based on 3.2.16, the patch is: ---8< --- linux-3.2.16-orig/fs/jffs2/scan.c 2012-04-23 00:31:32.0 +0200 +++ linux-3.2.16/fs/jffs2/scan.c2012-04-27 13:23:06.0 +0200 @@ -509,7 +509,11 @@ sumptr = kmalloc(sumlen, GFP_KERNEL); if (!sumptr) return -ENOMEM; +#ifdef CONFIG_PPC_MPC52xx + memcpy_fromio(sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len); +#else memcpy(sumptr + sumlen - buf_len, buf + buf_size - buf_len, buf_len); +#endif } if (buf_len < sumlen) { /* Need to read more so that the entire summary node is present */ @@ -1039,7 +1043,11 @@ if (!fd) { return -ENOMEM; } +#ifdef CONFIG_PPC_MPC52xx + memcpy_fromio(&fd->name, rd->name, checkedlen); +#else memcpy(&fd->name, rd->name, checkedlen); +#endif fd->name[checkedlen] = 0; crc = crc32(0, fd->name, rd->nsize); ---8< Works perfectly with it... Hope this helps, Albrecht. pgpGSw8l7RNeH.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
MPC5200b jffs2 memcpy alignment problem
Hello! First of all, please apologize my cross posting. I have a problem running jffs2 on an MPC5200b board. I run kernel 3.4, but older kernels like 3.1.5 are also affected. Every time I mount jffs2, previously written content gets garbled. The problem was nailed down to memcpy(&fd->name, rd->name, checkedlen); in jffs2_scan_dirent_node in fs/jffs2/scan.c. This is a copy directly from the mapped flash. memcpy from copy_32.S only ensures that the 32 bit stores to the destination ptr are aligned. And that's the problem with the MPC5200b because the user manual (Chapter 9.2, LocalPlus bus features) clearly states that unaligned access is not supported. But the code above results in unaligned loads from the LocalPlus bus. I think there are two possible solutions: 1. Rewrite memcpy this way: Only if both src and dst are 32 bit aligned, use 32 bit load/store to copy, otherwise use byte load/store instructions. (btw. is there a reason for not to use the load multiple and store multiple instructions in memcpy?) This might be the best way to do because in my opinion the semantics of memcpy put no restrictions on the alignment of src and dst. 2. use memcpy_fromio in the jffs2 code. memcpy_fromio behaves exactly in the way I described above. This could be also a good solution because flash access via LocalPlus bus is clearly IO. What is your opinion where to fix this problem? Regards, Stephan smime.p7s Description: S/MIME Cryptographic Signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH -v5 1/6] fault-injection: notifier error injection
The notifier error injection provides the ability to inject artifical errors to specified notifier chain callbacks. It is useful to test the error handling of notifier call chain failures. This adds common basic functions to define which type of events can be fail and to initialize the debugfs interface to control what error code should be returned and which event should be failed. Signed-off-by: Akinobu Mita Cc: Pavel Machek Cc: "Rafael J. Wysocki" Cc: linux...@lists.linux-foundation.org Cc: Greg KH Cc: linux...@kvack.org Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org Cc: Michael Ellerman --- No changes since v4 lib/Kconfig.debug | 11 + lib/Makefile|1 + lib/notifier-error-inject.c | 112 +++ lib/notifier-error-inject.h | 24 ++ 4 files changed, 148 insertions(+) create mode 100644 lib/notifier-error-inject.c create mode 100644 lib/notifier-error-inject.h diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ff5bdee..c848758 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1084,6 +1084,17 @@ config LKDTM Documentation on how to use the module can be found in Documentation/fault-injection/provoke-crashes.txt +config NOTIFIER_ERROR_INJECTION + tristate "Notifier error injection" + depends on DEBUG_KERNEL + select DEBUG_FS + help + This option provides the ability to inject artifical errors to + specified notifier chain callbacks. It is useful to test the error + handling of notifier call chain failures. + + Say N if unsure. + config CPU_NOTIFIER_ERROR_INJECT tristate "CPU notifier error injection module" depends on HOTPLUG_CPU && DEBUG_KERNEL diff --git a/lib/Makefile b/lib/Makefile index 8c31a0c..23fba9e 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -90,6 +90,7 @@ obj-$(CONFIG_AUDIT_GENERIC) += audit.o obj-$(CONFIG_SWIOTLB) += swiotlb.o obj-$(CONFIG_IOMMU_HELPER) += iommu-helper.o obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o +obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o lib-$(CONFIG_GENERIC_BUG) += bug.o diff --git a/lib/notifier-error-inject.c b/lib/notifier-error-inject.c new file mode 100644 index 000..44b92cb --- /dev/null +++ b/lib/notifier-error-inject.c @@ -0,0 +1,112 @@ +#include + +#include "notifier-error-inject.h" + +static int debugfs_errno_set(void *data, u64 val) +{ + *(int *)data = clamp_t(int, val, -MAX_ERRNO, 0); + return 0; +} + +static int debugfs_errno_get(void *data, u64 *val) +{ + *val = *(int *)data; + return 0; +} + +DEFINE_SIMPLE_ATTRIBUTE(fops_errno, debugfs_errno_get, debugfs_errno_set, + "%lld\n"); + +static struct dentry *debugfs_create_errno(const char *name, mode_t mode, + struct dentry *parent, int *value) +{ + return debugfs_create_file(name, mode, parent, value, &fops_errno); +} + +static int notifier_err_inject_callback(struct notifier_block *nb, + unsigned long val, void *p) +{ + int err = 0; + struct notifier_err_inject *err_inject = + container_of(nb, struct notifier_err_inject, nb); + struct notifier_err_inject_action *action; + + for (action = err_inject->actions; action->name; action++) { + if (action->val == val) { + err = action->error; + break; + } + } + if (err) + pr_info("Injecting error (%d) to %s\n", err, action->name); + + return notifier_from_errno(err); +} + +struct dentry *notifier_err_inject_dir; +EXPORT_SYMBOL_GPL(notifier_err_inject_dir); + +struct dentry *notifier_err_inject_init(const char *name, struct dentry *parent, + struct notifier_err_inject *err_inject, int priority) +{ + struct notifier_err_inject_action *action; + mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; + struct dentry *dir; + struct dentry *actions_dir; + + err_inject->nb.notifier_call = notifier_err_inject_callback; + err_inject->nb.priority = priority; + + dir = debugfs_create_dir(name, parent); + if (!dir) + return ERR_PTR(-ENOMEM); + + actions_dir = debugfs_create_dir("actions", dir); + if (!actions_dir) + goto fail; + + for (action = err_inject->actions; action->name; action++) { + struct dentry *action_dir; + + action_dir = debugfs_create_dir(action->name, actions_dir); + if (!action_dir) + goto fail; + + /* +* Create debugfs r/w file containing action->error. If +* notifier call chain is called with action->val, it will +* fail with the error code +
[PATCH -v5 0/6] notifier error injection
This provides kernel modules that can be used to test the error handling of notifier call chain failures by injecting artifical errors to the following notifier chain callbacks. * CPU notifier * PM notifier * memory hotplug notifier * powerpc pSeries reconfig notifier Example: Inject CPU offline error (-1 == -EPERM) # cd /sys/kernel/debug/notifier-error-inject/cpu # echo -1 > actions/CPU_DOWN_PREPARE/error # echo 0 > /sys/devices/system/cpu/cpu1/online bash: echo: write error: Operation not permitted This also adds cpu and memory hotplug tests to tools/testing/selftests These tests first do simple online and offline test and then do fault injection tests if notifier error injection module is available. Changelog: * v5 (change only testing scripts) - make testing scripts a part of tools/testing/selftests - do simple on/offline tests even if no notifier error injection support * v4 (It is about 11 months since v3) - prefix all APIs with notifier_err_inject_* - rearrange debugfs interface (e.g. $DEBUGFS/cpu-notifier-error-inject/CPU_DOWN_PREPARE --> $DEBUGFS/notifier-error-inject/cpu/actions/CPU_DOWN_PREPARE/error) - update modules to follow new interface - add -r option for memory-notifier.sh to specify percent of offlining memory blocks * v3 - rewrite to be kernel modules instead of initializing at late_initcall()s (it makes the diffstat look different but most code remains unchanged) - export err_inject_notifier_block_{init,cleanup} for modules - export pSeries_reconfig_notifier_{,un}register symbols for a module - notifier priority can be specified as a module parameter - add testing scripts in tools/testing/fault-injection * v2 - "PM: Improve error code of pm_notifier_call_chain()" is now in -next - "debugfs: add debugfs_create_int" is dropped - put a comment in err_inject_notifier_block_init() - only allow valid errno to be injected (-MAX_ERRNO <= errno <= 0) - improve Kconfig help text - make CONFIG_PM_NOTIFIER_ERROR_INJECTION visible even if PM_DEBUG is disabled - make CONFIG_PM_NOTIFIER_ERROR_INJECTION default if PM_DEBUG is enabled Akinobu Mita (6): fault-injection: notifier error injection cpu: rewrite cpu-notifier-error-inject module PM: PM notifier error injection module memory: memory notifier error injection module powerpc: pSeries reconfig notifier error injection module fault-injection: add selftests for cpu and memory hotplug lib/Kconfig.debug | 91 +++- lib/Makefile |5 + lib/cpu-notifier-error-inject.c| 63 +++--- lib/memory-notifier-error-inject.c | 48 lib/notifier-error-inject.c| 112 ++ lib/notifier-error-inject.h| 24 ++ lib/pSeries-reconfig-notifier-error-inject.c | 51 + lib/pm-notifier-error-inject.c | 49 + tools/testing/selftests/Makefile |2 +- tools/testing/selftests/cpu-hotplug/Makefile |6 + tools/testing/selftests/cpu-hotplug/on-off-test.sh | 221 +++ tools/testing/selftests/memory-hotplug/Makefile|6 + .../selftests/memory-hotplug/on-off-test.sh| 230 13 files changed, 867 insertions(+), 41 deletions(-) create mode 100644 lib/memory-notifier-error-inject.c create mode 100644 lib/notifier-error-inject.c create mode 100644 lib/notifier-error-inject.h create mode 100644 lib/pSeries-reconfig-notifier-error-inject.c create mode 100644 lib/pm-notifier-error-inject.c create mode 100644 tools/testing/selftests/cpu-hotplug/Makefile create mode 100755 tools/testing/selftests/cpu-hotplug/on-off-test.sh create mode 100644 tools/testing/selftests/memory-hotplug/Makefile create mode 100755 tools/testing/selftests/memory-hotplug/on-off-test.sh Cc: Pavel Machek Cc: "Rafael J. Wysocki" Cc: linux...@lists.linux-foundation.org Cc: Greg KH Cc: linux...@kvack.org Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org Cc: Américo Wang Cc: Michael Ellerman Cc: Dave Jones -- 1.7.10.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH -v5 6/6] fault-injection: add selftests for cpu and memory hotplug
This adds two selftests * tools/testing/selftests/cpu-hotplug/on-off-test.sh is testing script for CPU hotplug 1. Online all hot-pluggable CPUs 2. Offline all hot-pluggable CPUs 3. Online all hot-pluggable CPUs again 4. Exit if cpu-notifier-error-inject.ko is not available 5. Offline all hot-pluggable CPUs in preparation for testing 6. Test CPU hot-add error handling by injecting notifier errors 7. Online all hot-pluggable CPUs in preparation for testing 8. Test CPU hot-remove error handling by injecting notifier errors * tools/testing/selftests/memory-hotplug/on-off-test.sh is doing the similar thing for memory hotplug. 1. Online all hot-pluggable memory 2. Offline 10% of hot-pluggable memory 3. Online all hot-pluggable memory again 4. Exit if memory-notifier-error-inject.ko is not available 5. Offline 10% of hot-pluggable memory in preparation for testing 6. Test memory hot-add error handling by injecting notifier errors 7. Online all hot-pluggable memory in preparation for testing 8. Test memory hot-remove error handling by injecting notifier errors Signed-off-by: Akinobu Mita Suggested-by: Andrew Morton Cc: Pavel Machek Cc: "Rafael J. Wysocki" Cc: linux...@lists.linux-foundation.org Cc: Greg KH Cc: linux...@kvack.org Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org Cc: Américo Wang Cc: Dave Jones --- * v5 - make testing scripts a part of tools/testing/selftests - do simple on/offline tests even if no notifier error injection support tools/testing/selftests/Makefile |2 +- tools/testing/selftests/cpu-hotplug/Makefile |6 + tools/testing/selftests/cpu-hotplug/on-off-test.sh | 221 +++ tools/testing/selftests/memory-hotplug/Makefile|6 + .../selftests/memory-hotplug/on-off-test.sh| 230 5 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/cpu-hotplug/Makefile create mode 100755 tools/testing/selftests/cpu-hotplug/on-off-test.sh create mode 100644 tools/testing/selftests/memory-hotplug/Makefile create mode 100755 tools/testing/selftests/memory-hotplug/on-off-test.sh diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index a4162e1..85baf11 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -1,4 +1,4 @@ -TARGETS = breakpoints kcmp mqueue vm +TARGETS = breakpoints kcmp mqueue vm cpu-hotplug memory-hotplug all: for TARGET in $(TARGETS); do \ diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile new file mode 100644 index 000..7c9c20f --- /dev/null +++ b/tools/testing/selftests/cpu-hotplug/Makefile @@ -0,0 +1,6 @@ +all: + +run_tests: + ./on-off-test.sh + +clean: diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/on-off-test.sh new file mode 100755 index 000..bdde7cf --- /dev/null +++ b/tools/testing/selftests/cpu-hotplug/on-off-test.sh @@ -0,0 +1,221 @@ +#!/bin/bash + +SYSFS= + +prerequisite() +{ + msg="skip all tests:" + + if [ $UID != 0 ]; then + echo $msg must be run as root >&2 + exit 0 + fi + + SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` + + if [ ! -d "$SYSFS" ]; then + echo $msg sysfs is not mounted >&2 + exit 0 + fi + + if ! ls $SYSFS/devices/system/cpu/cpu* > /dev/null 2>&1; then + echo $msg cpu hotplug is not supported >&2 + exit 0 + fi +} + +# +# list all hot-pluggable CPUs +# +hotpluggable_cpus() +{ + local state=${1:-.\*} + + for cpu in $SYSFS/devices/system/cpu/cpu*; do + if [ -f $cpu/online ] && grep -q $state $cpu/online; then + echo ${cpu##/*/cpu} + fi + done +} + +hotplaggable_offline_cpus() +{ + hotpluggable_cpus 0 +} + +hotpluggable_online_cpus() +{ + hotpluggable_cpus 1 +} + +cpu_is_online() +{ + grep -q 1 $SYSFS/devices/system/cpu/cpu$1/online +} + +cpu_is_offline() +{ + grep -q 0 $SYSFS/devices/system/cpu/cpu$1/online +} + +online_cpu() +{ + echo 1 > $SYSFS/devices/system/cpu/cpu$1/online +} + +offline_cpu() +{ + echo 0 > $SYSFS/devices/system/cpu/cpu$1/online +} + +online_cpu_expect_success() +{ + local cpu=$1 + + if ! online_cpu $cpu; then + echo $FUNCNAME $cpu: unexpected fail >&2 + elif ! cpu_is_online $cpu; then + echo $FUNCNAME $cpu: unexpected offline >&2 + fi +} + +online_cpu_expect_fail() +{ + local cpu=$1 + + if online_cpu $cpu 2> /dev/null; then + echo $FUNCNAME $cpu: unexpected success >&2 + elif ! cpu_is_offline $cpu; then + echo $FUNCNAME $cpu: unexpected online >&2 + fi +} + +offline_cpu_expect_success() +{ + local cpu=$1 + + if ! offline_cpu $cpu; the
[PATCH -v5 5/6] powerpc: pSeries reconfig notifier error injection module
This provides the ability to inject artifical errors to pSeries reconfig notifier chain callbacks. It is controlled through debugfs interface under /sys/kernel/debug/notifier-error-inject/pSeries-reconfig If the notifier call chain should be failed with some events notified, write the error code to "actions//error". Signed-off-by: Akinobu Mita Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org --- No changes since v4 lib/Kconfig.debug| 17 + lib/Makefile |2 + lib/pSeries-reconfig-notifier-error-inject.c | 51 ++ 3 files changed, 70 insertions(+) create mode 100644 lib/pSeries-reconfig-notifier-error-inject.c diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 7cceddc..8f8e226 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1166,6 +1166,23 @@ config MEMORY_NOTIFIER_ERROR_INJECT If unsure, say N. +config PSERIES_RECONFIG_NOTIFIER_ERROR_INJECT + tristate "pSeries reconfig notifier error injection module" + depends on PPC_PSERIES && NOTIFIER_ERROR_INJECTION + help + This option provides the ability to inject artifical errors to + pSeries reconfig notifier chain callbacks. It is controlled + through debugfs interface under + /sys/kernel/debug/notifier-error-inject/pSeries-reconfig/ + + If the notifier call chain should be failed with some events + notified, write the error code to "actions//error". + + To compile this code as a module, choose M here: the module will + be called memory-notifier-error-inject. + + If unsure, say N. + config FAULT_INJECTION bool "Fault-injection framework" depends on DEBUG_KERNEL diff --git a/lib/Makefile b/lib/Makefile index a867aa5..d055cb1 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -94,6 +94,8 @@ obj-$(CONFIG_NOTIFIER_ERROR_INJECTION) += notifier-error-inject.o obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o obj-$(CONFIG_PM_NOTIFIER_ERROR_INJECT) += pm-notifier-error-inject.o obj-$(CONFIG_MEMORY_NOTIFIER_ERROR_INJECT) += memory-notifier-error-inject.o +obj-$(CONFIG_PSERIES_RECONFIG_NOTIFIER_ERROR_INJECT) += \ + pSeries-reconfig-notifier-error-inject.o lib-$(CONFIG_GENERIC_BUG) += bug.o diff --git a/lib/pSeries-reconfig-notifier-error-inject.c b/lib/pSeries-reconfig-notifier-error-inject.c new file mode 100644 index 000..7f7c98d --- /dev/null +++ b/lib/pSeries-reconfig-notifier-error-inject.c @@ -0,0 +1,51 @@ +#include +#include + +#include + +#include "notifier-error-inject.h" + +static int priority; +module_param(priority, int, 0); +MODULE_PARM_DESC(priority, "specify pSeries reconfig notifier priority"); + +static struct notifier_err_inject reconfig_err_inject = { + .actions = { + { NOTIFIER_ERR_INJECT_ACTION(PSERIES_RECONFIG_ADD) }, + { NOTIFIER_ERR_INJECT_ACTION(PSERIES_RECONFIG_REMOVE) }, + { NOTIFIER_ERR_INJECT_ACTION(PSERIES_DRCONF_MEM_ADD) }, + { NOTIFIER_ERR_INJECT_ACTION(PSERIES_DRCONF_MEM_REMOVE) }, + {} + } +}; + +static struct dentry *dir; + +static int err_inject_init(void) +{ + int err; + + dir = notifier_err_inject_init("pSeries-reconfig", + notifier_err_inject_dir, &reconfig_err_inject, priority); + if (IS_ERR(dir)) + return PTR_ERR(dir); + + err = pSeries_reconfig_notifier_register(&reconfig_err_inject.nb); + if (err) + debugfs_remove_recursive(dir); + + return err; +} + +static void err_inject_exit(void) +{ + pSeries_reconfig_notifier_unregister(&reconfig_err_inject.nb); + debugfs_remove_recursive(dir); +} + +module_init(err_inject_init); +module_exit(err_inject_exit); + +MODULE_DESCRIPTION("pSeries reconfig notifier error injection module"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Akinobu Mita "); -- 1.7.10.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev