[v4 0/2] "Hotremove" persistent memory

2019-05-01 Thread Pavel Tatashin
Changelog: v4 - Addressed comments from Dave Hansen v3 - Addressed comments from David Hildenbrand. Don't release lock_device_hotplug after checking memory status, and rename memblock_offlined_cb() to check_memblock_offlined_cb() v2 - Dan Williams mentioned that drv->remove() return is ignore

[v4 2/2] device-dax: "Hotremove" persistent memory that is used like normal RAM

2019-05-01 Thread Pavel Tatashin
It is now allowed to use persistent memory like a regular RAM, but currently there is no way to remove this memory until machine is rebooted. This work expands the functionality to also allows hotremoving previously hotplugged persistent memory, and recover the device for use for other purposes.

[v4 1/2] device-dax: fix memory and resource leak if hotplug fails

2019-05-01 Thread Pavel Tatashin
When add_memory() function fails, the resource and the memory should be freed. Fixes: c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like normal RAM") Signed-off-by: Pavel Tatashin Reviewed-by: Dave Hansen --- drivers/dax/kmem.c | 5 - 1 file changed, 4 insertions(+), 1 de

[PATCH v2 00/17] kunit: introduce KUnit, the Linux kernel unit testing framework

2019-05-01 Thread Brendan Higgins
## TLDR I rebased the last patchset on 5.1-rc7 in hopes that we can get this in 5.2. Shuah, I think you, Greg KH, and myself talked off thread, and we agreed we would merge through your tree when the time came? Am I remembering correctly? ## Background This patch set proposes KUnit, a lightweig

[PATCH v2 02/17] kunit: test: add test resource management API

2019-05-01 Thread Brendan Higgins
Create a common API for test managed resources like memory and test objects. A lot of times a test will want to set up infrastructure to be used in test cases; this could be anything from just wanting to allocate some memory to setting up a driver stack; this defines facilities for creating "test r

[PATCH v2 03/17] kunit: test: add string_stream a std::stream like string builder

2019-05-01 Thread Brendan Higgins
A number of test features need to do pretty complicated string printing where it may not be possible to rely on a single preallocated string with parameters. So provide a library for constructing the string as you go similar to C++'s std::string. Signed-off-by: Brendan Higgins --- include/kunit

[PATCH v2 01/17] kunit: test: add KUnit test runner core

2019-05-01 Thread Brendan Higgins
Add core facilities for defining unit tests; this provides a common way to define test cases, functions that execute code which is under test and determine whether the code under test behaves as expected; this also provides a way to group together related test cases in test suites (here we call the

[PATCH v2 04/17] kunit: test: add kunit_stream a std::stream like logger

2019-05-01 Thread Brendan Higgins
A lot of the expectation and assertion infrastructure prints out fairly complicated test failure messages, so add a C++ style log library for for logging test results. Signed-off-by: Brendan Higgins --- include/kunit/kunit-stream.h | 85 include/kunit/test.h | 2 +

[PATCH v2 08/17] kunit: test: add support for test abort

2019-05-01 Thread Brendan Higgins
Add support for aborting/bailing out of test cases, which is needed for implementing assertions. An assertion is like an expectation, but bails out of the test case early if the assertion is not met. The idea with assertions is that you use them to state all the preconditions for your test. Logica

[PATCH v2 07/17] kunit: test: add initial tests

2019-05-01 Thread Brendan Higgins
Add a test for string stream along with a simpler example. Signed-off-by: Brendan Higgins --- kunit/Kconfig | 12 ++ kunit/Makefile | 4 ++ kunit/example-test.c | 88 ++ kunit/string-stream-test.c | 61 ++

[PATCH v2 10/17] kunit: test: add the concept of assertions

2019-05-01 Thread Brendan Higgins
Add support for assertions which are like expectations except the test terminates if the assertion is not satisfied. The idea with assertions is that you use them to state all the preconditions for your test. Logically speaking, these are the premises of the test case, so if a premise isn't true,

[PATCH v2 06/17] kbuild: enable building KUnit

2019-05-01 Thread Brendan Higgins
Add KUnit to root Kconfig and Makefile allowing it to actually be built. Signed-off-by: Brendan Higgins --- Kconfig | 2 ++ Makefile | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Kconfig b/Kconfig index 48a80beab6853..10428501edb78 100644 --- a/Kconfig +++ b/Kconfig @@ -

[PATCH v2 11/17] kunit: test: add test managed resource tests

2019-05-01 Thread Brendan Higgins
From: Avinash Kondareddy Tests how tests interact with test managed resources in their lifetime. Signed-off-by: Avinash Kondareddy Signed-off-by: Brendan Higgins --- kunit/test-test.c | 122 ++ 1 file changed, 122 insertions(+) diff --git a/kunit/t

[PATCH v2 05/17] kunit: test: add the concept of expectations

2019-05-01 Thread Brendan Higgins
Add support for expectations, which allow properties to be specified and then verified in tests. Signed-off-by: Brendan Higgins --- include/kunit/test.h | 419 +++ kunit/test.c | 34 2 files changed, 453 insertions(+) diff --git a/include/ku

[PATCH v2 09/17] kunit: test: add tests for kunit test abort

2019-05-01 Thread Brendan Higgins
Add KUnit tests for the KUnit test abort mechanism (see preceding commit). Add tests both for general try catch mechanism as well as non-architecture specific mechanism. Signed-off-by: Brendan Higgins --- kunit/Makefile| 3 +- kunit/test-test.c | 135 +++

[PATCH v2 14/17] Documentation: kunit: add documentation for KUnit

2019-05-01 Thread Brendan Higgins
Add documentation for KUnit, the Linux kernel unit testing framework. - Add intro and usage guide for KUnit - Add API reference Signed-off-by: Felix Guo Signed-off-by: Brendan Higgins --- Documentation/index.rst | 1 + Documentation/kunit/api/index.rst | 16 ++ Documentation/kunit/

[PATCH v2 13/17] kunit: defconfig: add defconfigs for building KUnit tests

2019-05-01 Thread Brendan Higgins
Add defconfig for UML and a fragment that can be used to configure other architectures for building KUnit tests. Add option to kunit_tool to use a defconfig to create the kunitconfig. Signed-off-by: Brendan Higgins --- arch/um/configs/kunit_defconfig | 8 tools/testing/kun

[PATCH v2 16/17] kernel/sysctl-test: Add null pointer test for sysctl.c:proc_dointvec()

2019-05-01 Thread Brendan Higgins
From: Iurii Zaikin KUnit tests for initialized data behavior of proc_dointvec that is explicitly checked in the code. Includes basic parsing tests including int min/max overflow. Signed-off-by: Iurii Zaikin Signed-off-by: Brendan Higgins --- kernel/Makefile | 2 + kernel/sysctl-test.c

[PATCH v2 17/17] MAINTAINERS: add proc sysctl KUnit test to PROC SYSCTL section

2019-05-01 Thread Brendan Higgins
Add entry for the new proc sysctl KUnit test to the PROC SYSCTL section. Signed-off-by: Brendan Higgins --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index c78ae95c56b80..23cc97332c3d7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12524,6 +12524,7

[PATCH v2 12/17] kunit: tool: add Python wrappers for running KUnit tests

2019-05-01 Thread Brendan Higgins
From: Felix Guo The ultimate goal is to create minimal isolated test binaries; in the meantime we are using UML to provide the infrastructure to run tests, so define an abstract way to configure and run tests that allow us to change the context in which tests are built without affecting the user.

[PATCH v2 15/17] MAINTAINERS: add entry for KUnit the unit testing framework

2019-05-01 Thread Brendan Higgins
Add myself as maintainer of KUnit, the Linux kernel's unit testing framework. Signed-off-by: Brendan Higgins --- MAINTAINERS | 10 ++ 1 file changed, 10 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 5c38f21aee787..c78ae95c56b80 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@

Re: [PATCH v6 01/12] mm/sparsemem: Introduce struct mem_section_usage

2019-05-01 Thread Pavel Tatashin
On 19-04-17 11:39:00, Dan Williams wrote: > Towards enabling memory hotplug to track partial population of a > section, introduce 'struct mem_section_usage'. > > A pointer to a 'struct mem_section_usage' instance replaces the existing > pointer to a 'pageblock_flags' bitmap. Effectively it adds on

Re: [PATCH v6 01/12] mm/sparsemem: Introduce struct mem_section_usage

2019-05-01 Thread Dan Williams
On Wed, May 1, 2019 at 4:25 PM Pavel Tatashin wrote: > > On 19-04-17 11:39:00, Dan Williams wrote: > > Towards enabling memory hotplug to track partial population of a > > section, introduce 'struct mem_section_usage'. > > > > A pointer to a 'struct mem_section_usage' instance replaces the existin

[PATCH v7 02/12] mm/sparsemem: Introduce common definitions for the size and mask of a section

2019-05-01 Thread Dan Williams
Up-level the local section size and mask from kernel/memremap.c to global definitions. These will be used by the new sub-section hotplug support. Cc: Michal Hocko Cc: Vlastimil Babka Cc: Jérôme Glisse Cc: Logan Gunthorpe Signed-off-by: Dan Williams --- include/linux/mmzone.h |2 ++ kern

[PATCH v7 05/12] mm/sparsemem: Convert kmalloc_section_memmap() to populate_section_memmap()

2019-05-01 Thread Dan Williams
Allow sub-section sized ranges to be added to the memmap. populate_section_memmap() takes an explict pfn range rather than assuming a full section, and those parameters are plumbed all the way through to vmmemap_populate(). There should be no sub-section usage in current deployments. New warnings a

[PATCH v7 01/12] mm/sparsemem: Introduce struct mem_section_usage

2019-05-01 Thread Dan Williams
Towards enabling memory hotplug to track partial population of a section, introduce 'struct mem_section_usage'. A pointer to a 'struct mem_section_usage' instance replaces the existing pointer to a 'pageblock_flags' bitmap. Effectively it adds one more 'unsigned long' beyond the 'pageblock_flags'

[PATCH v7 00/12] mm: Sub-section memory hotplug support

2019-05-01 Thread Dan Williams
Changes since v6 [1]: - Rebase on next-20190501, no related conflicts or updates - Fix boot crash due to inaccurate setup of the initial section ->map_active bitmask caused by multiple activations of the same section. (Jane, Jeff) - Fix pmem startup crash when devm_memremap_pages() needs

[PATCH v7 04/12] mm/hotplug: Prepare shrink_{zone, pgdat}_span for sub-section removal

2019-05-01 Thread Dan Williams
Sub-section hotplug support reduces the unit of operation of hotplug from section-sized-units (PAGES_PER_SECTION) to sub-section-sized units (PAGES_PER_SUBSECTION). Teach shrink_{zone,pgdat}_span() to consider PAGES_PER_SUBSECTION boundaries as the points where pfn_valid(), not valid_section(), can

[PATCH v7 03/12] mm/sparsemem: Add helpers track active portions of a section at boot

2019-05-01 Thread Dan Williams
Prepare for hot{plug,remove} of sub-ranges of a section by tracking a section active bitmask, each bit representing 2MB (SECTION_SIZE (128M) / map_active bitmask length (64)). If it turns out that 2MB is too large of an active tracking granularity it is trivial to increase the size of the map_activ

[PATCH v7 11/12] libnvdimm/pfn: Fix fsdax-mode namespace info-block zero-fields

2019-05-01 Thread Dan Williams
At namespace creation time there is the potential for the "expected to be zero" fields of a 'pfn' info-block to be filled with indeterminate data. While the kernel buffer is zeroed on allocation it is immediately overwritten by nd_pfn_validate() filling it with the current contents of the on-media

[PATCH v7 09/12] mm/sparsemem: Support sub-section hotplug

2019-05-01 Thread Dan Williams
The libnvdimm sub-system has suffered a series of hacks and broken workarounds for the memory-hotplug implementation's awkward section-aligned (128MB) granularity. For example the following backtrace is emitted when attempting arch_add_memory() with physical address ranges that intersect 'System RA

[PATCH v7 12/12] libnvdimm/pfn: Stop padding pmem namespaces to section alignment

2019-05-01 Thread Dan Williams
Now that the mm core supports section-unaligned hotplug of ZONE_DEVICE memory, we no longer need to add padding at pfn/dax device creation time. The kernel will still honor padding established by older kernels. Reported-by: Jeff Moyer Signed-off-by: Dan Williams --- drivers/nvdimm/pfn.h |

[PATCH v7 10/12] mm/devm_memremap_pages: Enable sub-section remap

2019-05-01 Thread Dan Williams
Teach devm_memremap_pages() about the new sub-section capabilities of arch_{add,remove}_memory(). Effectively, just replace all usage of align_start, align_end, and align_size with res->start, res->end, and resource_size(res). The existing sanity check will still make sure that the two separate rem

[PATCH v7 08/12] mm/sparsemem: Prepare for sub-section ranges

2019-05-01 Thread Dan Williams
Prepare the memory hot-{add,remove} paths for handling sub-section ranges by plumbing the starting page frame and number of pages being handled through arch_{add,remove}_memory() to sparse_{add,remove}_one_section(). This is simply plumbing, small cleanups, and some identifier renames. No intended

[PATCH v7 06/12] mm/hotplug: Kill is_dev_zone() usage in __remove_pages()

2019-05-01 Thread Dan Williams
The zone type check was a leftover from the cleanup that plumbed altmap through the memory hotplug path, i.e. commit da024512a1fa "mm: pass the vmem_altmap to arch_remove_memory and __remove_pages". Cc: Michal Hocko Cc: Logan Gunthorpe Cc: David Hildenbrand Signed-off-by: Dan Williams --- mm/

[PATCH v7 07/12] mm: Kill is_dev_zone() helper

2019-05-01 Thread Dan Williams
Given there are no more usages of is_dev_zone() outside of 'ifdef CONFIG_ZONE_DEVICE' protection, kill off the compilation helper. Cc: Michal Hocko Cc: Logan Gunthorpe Acked-by: David Hildenbrand Reviewed-by: Oscar Salvador Signed-off-by: Dan Williams --- include/linux/mmzone.h | 12 --