Skip to content

Commit 413c1f1

Browse files
committed
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
2 parents 893d1ea + e67679c commit 413c1f1

File tree

15 files changed

+117
-35
lines changed

15 files changed

+117
-35
lines changed

.mailmap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
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>
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>
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ Testing
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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9152,6 +9152,7 @@ F: drivers/media/platform/st/sti/hva
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
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>
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
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
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ static ssize_t hard_offline_page_store(struct device *dev,
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

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -600,41 +600,79 @@ static void hugetlb_vmtruncate(struct inode *inode, loff_t offset)
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ static inline bool is_pinnable_page(struct page *page)
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 {
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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static int kthread(void *_create)
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)
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),
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 @@ __kthread_create_worker(int cpu, unsigned int flags,
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);
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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ static void damon_reclaim_timer_fn(struct work_struct *work)
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,
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)
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int hwpoison_inject(void *data, u64 val)
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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ static void *kfence_guarded_alloc(struct kmem_cache *cache, size_t size, gfp_t g
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
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
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]);

0 commit comments

Comments
 (0)