diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-17 11:58:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-17 11:58:04 -0400 |
commit | 57a8ec387e1441ea5e1232bc0749fb99a8cba7e7 (patch) | |
tree | b5fb03fc6bc5754de8b5b1f8b0e4f36d67c8315c /drivers/dax/kmem.c | |
parent | 0a8ad0ffa4d80a544f6cbff703bf6394339afcdf (diff) | |
parent | 43e11fa2d1d3b6e35629fa556eb7d571edba2010 (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton:
"VM:
- z3fold fixes and enhancements by Henry Burns and Vitaly Wool
- more accurate reclaimed slab caches calculations by Yafang Shao
- fix MAP_UNINITIALIZED UAPI symbol to not depend on config, by
Christoph Hellwig
- !CONFIG_MMU fixes by Christoph Hellwig
- new novmcoredd parameter to omit device dumps from vmcore, by
Kairui Song
- new test_meminit module for testing heap and pagealloc
initialization, by Alexander Potapenko
- ioremap improvements for huge mappings, by Anshuman Khandual
- generalize kprobe page fault handling, by Anshuman Khandual
- device-dax hotplug fixes and improvements, by Pavel Tatashin
- enable synchronous DAX fault on powerpc, by Aneesh Kumar K.V
- add pte_devmap() support for arm64, by Robin Murphy
- unify locked_vm accounting with a helper, by Daniel Jordan
- several misc fixes
core/lib:
- new typeof_member() macro including some users, by Alexey Dobriyan
- make BIT() and GENMASK() available in asm, by Masahiro Yamada
- changed LIST_POISON2 on x86_64 to 0xdead000000000122 for better
code generation, by Alexey Dobriyan
- rbtree code size optimizations, by Michel Lespinasse
- convert struct pid count to refcount_t, by Joel Fernandes
get_maintainer.pl:
- add --no-moderated switch to skip moderated ML's, by Joe Perches
misc:
- ptrace PTRACE_GET_SYSCALL_INFO interface
- coda updates
- gdb scripts, various"
[ Using merge message suggestion from Vlastimil Babka, with some editing - Linus ]
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (100 commits)
fs/select.c: use struct_size() in kmalloc()
mm: add account_locked_vm utility function
arm64: mm: implement pte_devmap support
mm: introduce ARCH_HAS_PTE_DEVMAP
mm: clean up is_device_*_page() definitions
mm/mmap: move common defines to mman-common.h
mm: move MAP_SYNC to asm-generic/mman-common.h
device-dax: "Hotremove" persistent memory that is used like normal RAM
mm/hotplug: make remove_memory() interface usable
device-dax: fix memory and resource leak if hotplug fails
include/linux/lz4.h: fix spelling and copy-paste errors in documentation
ipc/mqueue.c: only perform resource calculation if user valid
include/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT architectures
scripts/gdb: add helpers to find and list devices
scripts/gdb: add lx-genpd-summary command
drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl
kernel/pid.c: convert struct pid count to refcount_t
drivers/rapidio/devices/rio_mport_cdev.c: NUL terminate some strings
select: shift restore_saved_sigmask_unless() into poll_select_copy_remaining()
select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR
...
Diffstat (limited to 'drivers/dax/kmem.c')
-rw-r--r-- | drivers/dax/kmem.c | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index a02318c6d28a..3d0a7e702c94 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c | |||
@@ -66,23 +66,59 @@ int dev_dax_kmem_probe(struct device *dev) | |||
66 | new_res->name = dev_name(dev); | 66 | new_res->name = dev_name(dev); |
67 | 67 | ||
68 | rc = add_memory(numa_node, new_res->start, resource_size(new_res)); | 68 | rc = add_memory(numa_node, new_res->start, resource_size(new_res)); |
69 | if (rc) | 69 | if (rc) { |
70 | release_resource(new_res); | ||
71 | kfree(new_res); | ||
70 | return rc; | 72 | return rc; |
73 | } | ||
74 | dev_dax->dax_kmem_res = new_res; | ||
71 | 75 | ||
72 | return 0; | 76 | return 0; |
73 | } | 77 | } |
74 | 78 | ||
79 | #ifdef CONFIG_MEMORY_HOTREMOVE | ||
80 | static int dev_dax_kmem_remove(struct device *dev) | ||
81 | { | ||
82 | struct dev_dax *dev_dax = to_dev_dax(dev); | ||
83 | struct resource *res = dev_dax->dax_kmem_res; | ||
84 | resource_size_t kmem_start = res->start; | ||
85 | resource_size_t kmem_size = resource_size(res); | ||
86 | int rc; | ||
87 | |||
88 | /* | ||
89 | * We have one shot for removing memory, if some memory blocks were not | ||
90 | * offline prior to calling this function remove_memory() will fail, and | ||
91 | * there is no way to hotremove this memory until reboot because device | ||
92 | * unbind will succeed even if we return failure. | ||
93 | */ | ||
94 | rc = remove_memory(dev_dax->target_node, kmem_start, kmem_size); | ||
95 | if (rc) { | ||
96 | dev_err(dev, | ||
97 | "DAX region %pR cannot be hotremoved until the next reboot\n", | ||
98 | res); | ||
99 | return rc; | ||
100 | } | ||
101 | |||
102 | /* Release and free dax resources */ | ||
103 | release_resource(res); | ||
104 | kfree(res); | ||
105 | dev_dax->dax_kmem_res = NULL; | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | #else | ||
75 | static int dev_dax_kmem_remove(struct device *dev) | 110 | static int dev_dax_kmem_remove(struct device *dev) |
76 | { | 111 | { |
77 | /* | 112 | /* |
78 | * Purposely leak the request_mem_region() for the device-dax | 113 | * Without hotremove purposely leak the request_mem_region() for the |
79 | * range and return '0' to ->remove() attempts. The removal of | 114 | * device-dax range and return '0' to ->remove() attempts. The removal |
80 | * the device from the driver always succeeds, but the region | 115 | * of the device from the driver always succeeds, but the region is |
81 | * is permanently pinned as reserved by the unreleased | 116 | * permanently pinned as reserved by the unreleased |
82 | * request_mem_region(). | 117 | * request_mem_region(). |
83 | */ | 118 | */ |
84 | return 0; | 119 | return 0; |
85 | } | 120 | } |
121 | #endif /* CONFIG_MEMORY_HOTREMOVE */ | ||
86 | 122 | ||
87 | static struct dax_device_driver device_dax_kmem_driver = { | 123 | static struct dax_device_driver device_dax_kmem_driver = { |
88 | .drv = { | 124 | .drv = { |