History

Merge tag 'mm-hotfixes-stable-2022-06-26' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Pull hotfixes from Andrew Morton: "Minor things, mainly - mailmap updates, MAINTAINERS updates, etc. Fixes for this merge window: - fix for a damon boot hang, from SeongJae - fix for a kfence warning splat, from Jason Donenfeld - fix for zero-pfn pinning, from Alex Williamson - fix for fallocate hole punch clearing, from Mike Kravetz Fixes for previous releases: - fix for a performance regression, from Marcelo - fix for a hwpoisining BUG from zhenwei pi" * tag 'mm-hotfixes-stable-2022-06-26' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: mailmap: add entry for Christian Marangi mm/memory-failure: disable unpoison once hw error happens hugetlbfs: zero partial pages during fallocate hole punch mm: memcontrol: reference to tools/cgroup/memcg_slabinfo.py mm: re-allow pinning of zero pfns mm/kfence: select random number before taking raw lock MAINTAINERS: add maillist information for LoongArch MAINTAINERS: update MM tree references MAINTAINERS: update Abel Vesa's email MAINTAINERS: add MEMORY HOT(UN)PLUG section and add David as reviewer MAINTAINERS: add Miaohe Lin as a memory-failure reviewer mailmap: add alias for jarkko@profian.com mm/damon/reclaim: schedule 'damon_reclaim_timer' only after 'system_wq' is initialized kthread: make it clear that kthread_create_on_node() might be terminated by any fatal signal mm: lru_cache_disable: use synchronize_rcu_expedited mm/page_isolation.c: fix one kernel-doc comment

Linus Torvalds committed 4 years ago

Commit 413c1f12 parents 893d1ea e67679c15 files · +117 −35Browse files

Unified · Split

15 files
  1. .mailmap +4 −0
  2. Documentation/vm/hwpoison.rst +2 −1
  3. MAINTAINERS +17 −4
  4. drivers/base/memory.c +1 −1
  5. fs/hugetlbfs/inode.c +53 −15
  6. include/linux/mm.h +2 −1
  7. kernel/kthread.c +7 −7
  8. mm/damon/reclaim.c +8 −0
  9. mm/hwpoison-inject.c +1 −1
  10. mm/kfence/core.c +5 −2
  11. mm/madvise.c +1 −1
  12. mm/memcontrol.c +1 −1
  13. mm/memory-failure.c +12 −0
  14. mm/page_isolation.c +2 −0
  15. mm/swap.c +1 −1
.mailmap+4−0
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 # Please keep this list dictionary sorted.
1111 #
1212 Aaron Durbin <adurbin@google.com>
13+Abel Vesa <abelvesa@kernel.org> <abel.vesa@nxp.com>
14+Abel Vesa <abelvesa@kernel.org> <abelvesa@gmail.com>
1315 Abhinav Kumar <quic_abhinavk@quicinc.com> <abhinavk@codeaurora.org>
1416 Adam Oldham <oldhamca@gmail.com>
1517 Adam Radford <aradford@gmail.com>
@@ -85,6 +87,7 @@ Christian Borntraeger <borntraeger@linux.ibm.com> <borntrae@de.ibm.com> · 69 unmodified lines
8587 Christian Brauner <brauner@kernel.org> <christian@brauner.io>
8688 Christian Brauner <brauner@kernel.org> <christian.brauner@canonical.com>
8789 Christian Brauner <brauner@kernel.org> <christian.brauner@ubuntu.com>
90+Christian Marangi <ansuelsmth@gmail.com>
8891 Christophe Ricard <christophe.ricard@gmail.com>
8992 Christoph Hellwig <hch@lst.de>
9093 Colin Ian King <colin.king@intel.com> <colin.king@canonical.com>
@@ -165,6 +168,7 @@ Jan Glauber <jan.glauber@gmail.com> <jang@de.ibm.com> · 74 unmodified lines
165168 Jan Glauber <jan.glauber@gmail.com> <jang@linux.vnet.ibm.com>
166169 Jan Glauber <jan.glauber@gmail.com> <jglauber@cavium.com>
167170 Jarkko Sakkinen <jarkko@kernel.org> <jarkko.sakkinen@linux.intel.com>
171+Jarkko Sakkinen <jarkko@kernel.org> <jarkko@profian.com>
168172 Jason Gunthorpe <jgg@ziepe.ca> <jgg@mellanox.com>
169173 Jason Gunthorpe <jgg@ziepe.ca> <jgg@nvidia.com>
170174 Jason Gunthorpe <jgg@ziepe.ca> <jgunthorpe@obsidianresearch.com>
Documentation/vm/hwpoison.rst+2−1
@@ -120,7 +120,8 @@ Testing · 119 unmodified lines
120120 unpoison-pfn
121121 Software-unpoison page at PFN echoed into this file. This way
122122 a page can be reused again. This only works for Linux
123− injected failures, not for real memory failures.
123+ injected failures, not for real memory failures. Once any hardware
124+ memory failure happens, this feature is disabled.
124125
125126 Note these injection interfaces are not stable and might change between
126127 kernel versions
MAINTAINERS+17−4
@@ -9152,6 +9152,7 @@ F: drivers/media/platform/st/sti/hva · 9151 unmodified lines
91529152
91539153 HWPOISON MEMORY FAILURE HANDLING
91549154 M: Naoya Horiguchi <naoya.horiguchi@nec.com>
9155+R: Miaohe Lin <linmiaohe@huawei.com>
91559156 L: linux-mm@kvack.org
91569157 S: Maintained
91579158 F: mm/hwpoison-inject.c
@@ -11623,6 +11624,7 @@ F: drivers/gpu/drm/bridge/lontium-lt8912b.c · 2465 unmodified lines
1162311624 LOONGARCH
1162411625 M: Huacai Chen <chenhuacai@kernel.org>
1162511626 R: WANG Xuerui <kernel@xen0n.name>
11627+L: loongarch@lists.linux.dev
1162611628 S: Maintained
1162711629 T: git git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson.git
1162811630 F: arch/loongarch/
@@ -12879,9 +12881,8 @@ M: Andrew Morton <akpm@linux-foundation.org> · 1250 unmodified lines
1287912881 L: linux-mm@kvack.org
1288012882 S: Maintained
1288112883 W: http://www.linux-mm.org
12882−T: quilt https://ozlabs.org/~akpm/mmotm/
12883−T: quilt https://ozlabs.org/~akpm/mmots/
12884−T: git git://github.com/hnaz/linux-mm.git
12884+T: git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
12885+T: quilt git://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new
1288512886 F: include/linux/gfp.h
1288612887 F: include/linux/memory_hotplug.h
1288712888 F: include/linux/mm.h
@@ -12891,6 +12892,18 @@ F: include/linux/vmalloc.h · 3 unmodified lines
1289112892 F: mm/
1289212893 F: tools/testing/selftests/vm/
1289312894
12895+MEMORY HOT(UN)PLUG
12896+M: David Hildenbrand <david@redhat.com>
12897+M: Oscar Salvador <osalvador@suse.de>
12898+L: linux-mm@kvack.org
12899+S: Maintained
12900+F: Documentation/admin-guide/mm/memory-hotplug.rst
12901+F: Documentation/core-api/memory-hotplug.rst
12902+F: drivers/base/memory.c
12903+F: include/linux/memory_hotplug.h
12904+F: mm/memory_hotplug.c
12905+F: tools/testing/selftests/memory-hotplug/
12906+
1289412907 MEMORY TECHNOLOGY DEVICES (MTD)
1289512908 M: Miquel Raynal <miquel.raynal@bootlin.com>
1289612909 M: Richard Weinberger <richard@nod.at>
@@ -14295,7 +14308,7 @@ F: drivers/iio/gyro/fxas21002c_i2c.c · 1398 unmodified lines
1429514308 F: drivers/iio/gyro/fxas21002c_spi.c
1429614309
1429714310 NXP i.MX CLOCK DRIVERS
14298−M: Abel Vesa <abel.vesa@nxp.com>
14311+M: Abel Vesa <abelvesa@kernel.org>
1429914312 L: linux-clk@vger.kernel.org
1430014313 L: linux-imx@nxp.com
1430114314 S: Maintained
drivers/base/memory.c+1−1
@@ -558,7 +558,7 @@ static ssize_t hard_offline_page_store(struct device *dev, · 557 unmodified lines
558558 if (kstrtoull(buf, 0, &pfn) < 0)
559559 return -EINVAL;
560560 pfn >>= PAGE_SHIFT;
561− ret = memory_failure(pfn, 0);
561+ ret = memory_failure(pfn, MF_SW_SIMULATED);
562562 if (ret == -EOPNOTSUPP)
563563 ret = 0;
564564 return ret ? ret : count;
fs/hugetlbfs/inode.c+53−15
@@ -600,41 +600,79 @@ static void hugetlb_vmtruncate(struct inode *inode, loff_t offset) · 599 unmodified lines
600600 remove_inode_hugepages(inode, offset, LLONG_MAX);
601601 }
602602
603+static void hugetlbfs_zero_partial_page(struct hstate *h,
604+ struct address_space *mapping,
605+ loff_t start,
606+ loff_t end)
607+{
608+ pgoff_t idx = start >> huge_page_shift(h);
609+ struct folio *folio;
610+
611+ folio = filemap_lock_folio(mapping, idx);
612+ if (!folio)
613+ return;
614+
615+ start = start & ~huge_page_mask(h);
616+ end = end & ~huge_page_mask(h);
617+ if (!end)
618+ end = huge_page_size(h);
619+
620+ folio_zero_segment(folio, (size_t)start, (size_t)end);
621+
622+ folio_unlock(folio);
623+ folio_put(folio);
624+}
625+
603626 static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
604627 {
628+ struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
629+ struct address_space *mapping = inode->i_mapping;
605630 struct hstate *h = hstate_inode(inode);
606631 loff_t hpage_size = huge_page_size(h);
607632 loff_t hole_start, hole_end;
608633
609634 /*
610− * For hole punch round up the beginning offset of the hole and
611− * round down the end.
635+ * hole_start and hole_end indicate the full pages within the hole.
612636 */
613637 hole_start = round_up(offset, hpage_size);
614638 hole_end = round_down(offset + len, hpage_size);
615639
616− if (hole_end > hole_start) {
617− struct address_space *mapping = inode->i_mapping;
618− struct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);
640+ inode_lock(inode);
619641
620− inode_lock(inode);
642+ /* protected by i_rwsem */
643+ if (info->seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE)) {
644+ inode_unlock(inode);
645+ return -EPERM;
646+ }
621647
622− /* protected by i_rwsem */
623− if (info->seals & (F_SEAL_WRITE | F_SEAL_FUTURE_WRITE)) {
624− inode_unlock(inode);
625− return -EPERM;
626− }
648+ i_mmap_lock_write(mapping);
649+
650+ /* If range starts before first full page, zero partial page. */
651+ if (offset < hole_start)
652+ hugetlbfs_zero_partial_page(h, mapping,
653+ offset, min(offset + len, hole_start));
627654
628− i_mmap_lock_write(mapping);
655+ /* Unmap users of full pages in the hole. */
656+ if (hole_end > hole_start) {
629657 if (!RB_EMPTY_ROOT(&mapping->i_mmap.rb_root))
630658 hugetlb_vmdelete_list(&mapping->i_mmap,
631659 hole_start >> PAGE_SHIFT,
632660 hole_end >> PAGE_SHIFT, 0);
633− i_mmap_unlock_write(mapping);
634− remove_inode_hugepages(inode, hole_start, hole_end);
635− inode_unlock(inode);
636661 }
637662
663+ /* If range extends beyond last full page, zero partial page. */
664+ if ((offset + len) > hole_end && (offset + len) > hole_start)
665+ hugetlbfs_zero_partial_page(h, mapping,
666+ hole_end, offset + len);
667+
668+ i_mmap_unlock_write(mapping);
669+
670+ /* Remove full pages from the file. */
671+ if (hole_end > hole_start)
672+ remove_inode_hugepages(inode, hole_start, hole_end);
673+
674+ inode_unlock(inode);
675+
638676 return 0;
639677 }
640678
include/linux/mm.h+2−1
@@ -1600,7 +1600,7 @@ static inline bool is_pinnable_page(struct page *page) · 1599 unmodified lines
16001600 if (mt == MIGRATE_CMA || mt == MIGRATE_ISOLATE)
16011601 return false;
16021602 #endif
1603− return !(is_zone_movable_page(page) || is_zero_pfn(page_to_pfn(page)));
1603+ return !is_zone_movable_page(page) || is_zero_pfn(page_to_pfn(page));
16041604 }
16051605 #else
16061606 static inline bool is_pinnable_page(struct page *page)
@@ -3232,6 +3232,7 @@ enum mf_flags { · 1625 unmodified lines
32323232 MF_MUST_KILL = 1 << 2,
32333233 MF_SOFT_OFFLINE = 1 << 3,
32343234 MF_UNPOISON = 1 << 4,
3235+ MF_SW_SIMULATED = 1 << 5,
32353236 };
32363237 extern int memory_failure(unsigned long pfn, int flags);
32373238 extern void memory_failure_queue(unsigned long pfn, int flags);
kernel/kthread.c+7−7
@@ -340,7 +340,7 @@ static int kthread(void *_create) · 339 unmodified lines
340340
341341 self = to_kthread(current);
342342
343− /* If user was SIGKILLed, I release the structure. */
343+ /* Release the structure when caller killed by a fatal signal. */
344344 done = xchg(&create->done, NULL);
345345 if (!done) {
346346 kfree(create);
@@ -398,7 +398,7 @@ static void create_kthread(struct kthread_create_info *create) · 51 unmodified lines
398398 /* We want our own signal handler (we take no signals by default). */
399399 pid = kernel_thread(kthread, create, CLONE_FS | CLONE_FILES | SIGCHLD);
400400 if (pid < 0) {
401− /* If user was SIGKILLed, I release the structure. */
401+ /* Release the structure when caller killed by a fatal signal. */
402402 struct completion *done = xchg(&create->done, NULL);
403403
404404 if (!done) {
@@ -440,9 +440,9 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data), · 35 unmodified lines
440440 */
441441 if (unlikely(wait_for_completion_killable(&done))) {
442442 /*
443− * If I was SIGKILLed before kthreadd (or new kernel thread)
444− * calls complete(), leave the cleanup of this structure to
445− * that thread.
443+ * If I was killed by a fatal signal before kthreadd (or new
444+ * kernel thread) calls complete(), leave the cleanup of this
445+ * structure to that thread.
446446 */
447447 if (xchg(&create->done, NULL))
448448 return ERR_PTR(-EINTR);
@@ -876,7 +876,7 @@ fail_task: · 427 unmodified lines
876876 *
877877 * Returns a pointer to the allocated worker on success, ERR_PTR(-ENOMEM)
878878 * when the needed structures could not get allocated, and ERR_PTR(-EINTR)
879− * when the worker was SIGKILLed.
879+ * when the caller was killed by a fatal signal.
880880 */
881881 struct kthread_worker *
882882 kthread_create_worker(unsigned int flags, const char namefmt[], ...)
@@ -925,7 +925,7 @@ EXPORT_SYMBOL(kthread_create_worker); · 42 unmodified lines
925925 * Return:
926926 * The pointer to the allocated worker on success, ERR_PTR(-ENOMEM)
927927 * when the needed structures could not get allocated, and ERR_PTR(-EINTR)
928− * when the worker was SIGKILLed.
928+ * when the caller was killed by a fatal signal.
929929 */
930930 struct kthread_worker *
931931 kthread_create_worker_on_cpu(int cpu, unsigned int flags,
mm/damon/reclaim.c+8−0
@@ -374,6 +374,8 @@ static void damon_reclaim_timer_fn(struct work_struct *work) · 373 unmodified lines
374374 }
375375 static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn);
376376
377+static bool damon_reclaim_initialized;
378+
377379 static int enabled_store(const char *val,
378380 const struct kernel_param *kp)
379381 {
@@ -382,6 +384,10 @@ static int enabled_store(const char *val, · 2 unmodified lines
382384 if (rc < 0)
383385 return rc;
384386
387+ /* system_wq might not initialized yet */
388+ if (!damon_reclaim_initialized)
389+ return rc;
390+
385391 if (enabled)
386392 schedule_delayed_work(&damon_reclaim_timer, 0);
387393
@@ -449,6 +455,8 @@ static int __init damon_reclaim_init(void) · 61 unmodified lines
449455 damon_add_target(ctx, target);
450456
451457 schedule_delayed_work(&damon_reclaim_timer, 0);
458+
459+ damon_reclaim_initialized = true;
452460 return 0;
453461 }
454462
mm/hwpoison-inject.c+1−1
@@ -48,7 +48,7 @@ static int hwpoison_inject(void *data, u64 val) · 47 unmodified lines
4848
4949 inject:
5050 pr_info("Injecting memory failure at pfn %#lx\n", pfn);
51− err = memory_failure(pfn, 0);
51+ err = memory_failure(pfn, MF_SW_SIMULATED);
5252 return (err == -EOPNOTSUPP) ? 0 : err;
5353 }
5454
mm/kfence/core.c+5−2
@@ -360,6 +360,9 @@ static void *kfence_guarded_alloc(struct kmem_cache *cache, size_t size, gfp_t g · 359 unmodified lines
360360 unsigned long flags;
361361 struct slab *slab;
362362 void *addr;
363+ const bool random_right_allocate = prandom_u32_max(2);
364+ const bool random_fault = CONFIG_KFENCE_STRESS_TEST_FAULTS &&
365+ !prandom_u32_max(CONFIG_KFENCE_STRESS_TEST_FAULTS);
363366
364367 /* Try to obtain a free object. */
365368 raw_spin_lock_irqsave(&kfence_freelist_lock, flags);
@@ -404,7 +407,7 @@ static void *kfence_guarded_alloc(struct kmem_cache *cache, size_t size, gfp_t g · 38 unmodified lines
404407 * is that the out-of-bounds accesses detected are deterministic for
405408 * such allocations.
406409 */
407− if (prandom_u32_max(2)) {
410+ if (random_right_allocate) {
408411 /* Allocate on the "right" side, re-calculate address. */
409412 meta->addr += PAGE_SIZE - size;
410413 meta->addr = ALIGN_DOWN(meta->addr, cache->align);
@@ -444,7 +447,7 @@ static void *kfence_guarded_alloc(struct kmem_cache *cache, size_t size, gfp_t g · 33 unmodified lines
444447 if (cache->ctor)
445448 cache->ctor(addr);
446449
447− if (CONFIG_KFENCE_STRESS_TEST_FAULTS && !prandom_u32_max(CONFIG_KFENCE_STRESS_TEST_FAULTS))
450+ if (random_fault)
448451 kfence_protect(meta->addr); /* Random "faults" by protecting the object. */
449452
450453 atomic_long_inc(&counters[KFENCE_COUNTER_ALLOCATED]);
mm/madvise.c+1−1
@@ -1112,7 +1112,7 @@ static int madvise_inject_error(int behavior, · 1111 unmodified lines
11121112 } else {
11131113 pr_info("Injecting memory failure for pfn %#lx at process virtual address %#lx\n",
11141114 pfn, start);
1115− ret = memory_failure(pfn, MF_COUNT_INCREASED);
1115+ ret = memory_failure(pfn, MF_COUNT_INCREASED | MF_SW_SIMULATED);
11161116 if (ret == -EOPNOTSUPP)
11171117 ret = 0;
11181118 }
mm/memcontrol.c+1−1
@@ -4859,7 +4859,7 @@ static int mem_cgroup_slab_show(struct seq_file *m, void *p) · 4858 unmodified lines
48594859 {
48604860 /*
48614861 * Deprecated.
4862− * Please, take a look at tools/cgroup/slabinfo.py .
4862+ * Please, take a look at tools/cgroup/memcg_slabinfo.py .
48634863 */
48644864 return 0;
48654865 }
mm/memory-failure.c+12−0
@@ -69,6 +69,8 @@ int sysctl_memory_failure_recovery __read_mostly = 1; · 68 unmodified lines
6969
7070 atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
7171
72+static bool hw_memory_failure __read_mostly = false;
73+
7274 static bool __page_handle_poison(struct page *page)
7375 {
7476 int ret;
@@ -1768,6 +1770,9 @@ int memory_failure(unsigned long pfn, int flags) · 1693 unmodified lines
17681770
17691771 mutex_lock(&mf_mutex);
17701772
1773+ if (!(flags & MF_SW_SIMULATED))
1774+ hw_memory_failure = true;
1775+
17711776 p = pfn_to_online_page(pfn);
17721777 if (!p) {
17731778 res = arch_memory_failure(pfn, flags);
@@ -2103,6 +2108,13 @@ int unpoison_memory(unsigned long pfn) · 329 unmodified lines
21032108
21042109 mutex_lock(&mf_mutex);
21052110
2111+ if (hw_memory_failure) {
2112+ unpoison_pr_info("Unpoison: Disabled after HW memory failure %#lx\n",
2113+ pfn, &unpoison_rs);
2114+ ret = -EOPNOTSUPP;
2115+ goto unlock_mutex;
2116+ }
2117+
21062118 if (!PageHWPoison(p)) {
21072119 unpoison_pr_info("Unpoison: Page was already unpoisoned %#lx\n",
21082120 pfn, &unpoison_rs);
mm/page_isolation.c+2−0
@@ -286,6 +286,8 @@ __first_valid_page(unsigned long pfn, unsigned long nr_pages) · 285 unmodified lines
286286 * @flags: isolation flags
287287 * @gfp_flags: GFP flags used for migrating pages
288288 * @isolate_before: isolate the pageblock before the boundary_pfn
289+ * @skip_isolation: the flag to skip the pageblock isolation in second
290+ * isolate_single_pageblock()
289291 *
290292 * Free and in-use pages can be as big as MAX_ORDER-1 and contain more than one
291293 * pageblock. When not all pageblocks within a page are isolated at the same
mm/swap.c+1−1
@@ -881,7 +881,7 @@ void lru_cache_disable(void) · 880 unmodified lines
881881 * lru_disable_count = 0 will have exited the critical
882882 * section when synchronize_rcu() returns.
883883 */
884− synchronize_rcu();
884+ synchronize_rcu_expedited();
885885 #ifdef CONFIG_SMP
886886 __lru_add_drain_all(true);
887887 #else

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t