Skip to content

Commit dc772f8

Browse files
committed
Merge tag 'mm-hotfixes-stable-2024-06-07-15-24' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "14 hotfixes, 6 of which are cc:stable. All except the nilfs2 fix affect MM and all are singletons - see the chagelogs for details" * tag 'mm-hotfixes-stable-2024-06-07-15-24' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: nilfs2: fix nilfs_empty_dir() misjudgment and long loop on I/O errors mm: fix xyz_noprof functions calling profiled functions codetag: avoid race at alloc_slab_obj_exts mm/hugetlb: do not call vma_add_reservation upon ENOMEM mm/ksm: fix ksm_zero_pages accounting mm/ksm: fix ksm_pages_scanned accounting kmsan: do not wipe out origin when doing partial unpoisoning vmalloc: check CONFIG_EXECMEM in is_vmalloc_or_module_addr() mm: page_alloc: fix highatomic typing in multi-block buddies nilfs2: fix potential kernel bug due to lack of writeback flag waiting memcg: remove the lockdep assert from __mod_objcg_mlstate() mm: arm64: fix the out-of-bounds issue in contpte_clear_young_dirty_ptes mm: huge_mm: fix undefined reference to `mthp_stats' for CONFIG_SYSFS=n mm: drop the 'anon_' prefix for swap-out mTHP counters
2 parents e60721b + 7373a51 commit dc772f8

File tree

21 files changed

+115
-62
lines changed

21 files changed

+115
-62
lines changed

Documentation/admin-guide/mm/transhuge.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,11 +467,11 @@ anon_fault_fallback_charge
467467
instead falls back to using huge pages with lower orders or
468468
small pages even though the allocation was successful.
469469

470-
anon_swpout
470+
swpout
471471
is incremented every time a huge page is swapped out in one
472472
piece without splitting.
473473

474-
anon_swpout_fallback
474+
swpout_fallback
475475
is incremented if a huge page has to be split before swapout.
476476
Usually because failed to allocate some continuous swap space
477477
for the huge page.

arch/arm64/mm/contpte.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ void contpte_clear_young_dirty_ptes(struct vm_area_struct *vma,
376376
* clearing access/dirty for the whole block.
377377
*/
378378
unsigned long start = addr;
379-
unsigned long end = start + nr;
379+
unsigned long end = start + nr * PAGE_SIZE;
380380

381381
if (pte_cont(__ptep_get(ptep + nr - 1)))
382382
end = ALIGN(end, CONT_PTE_SIZE);
@@ -386,7 +386,7 @@ void contpte_clear_young_dirty_ptes(struct vm_area_struct *vma,
386386
ptep = contpte_align_down(ptep);
387387
}
388388

389-
__clear_young_dirty_ptes(vma, start, ptep, end - start, flags);
389+
__clear_young_dirty_ptes(vma, start, ptep, (end - start) / PAGE_SIZE, flags);
390390
}
391391
EXPORT_SYMBOL_GPL(contpte_clear_young_dirty_ptes);
392392

fs/nilfs2/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ int nilfs_empty_dir(struct inode *inode)
607607

608608
kaddr = nilfs_get_folio(inode, i, &folio);
609609
if (IS_ERR(kaddr))
610-
continue;
610+
return 0;
611611

612612
de = (struct nilfs_dir_entry *)kaddr;
613613
kaddr += nilfs_last_byte(inode, i) - NILFS_DIR_REC_LEN(1);

fs/nilfs2/segment.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,7 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
16521652
if (bh->b_folio != bd_folio) {
16531653
if (bd_folio) {
16541654
folio_lock(bd_folio);
1655+
folio_wait_writeback(bd_folio);
16551656
folio_clear_dirty_for_io(bd_folio);
16561657
folio_start_writeback(bd_folio);
16571658
folio_unlock(bd_folio);
@@ -1665,6 +1666,7 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
16651666
if (bh == segbuf->sb_super_root) {
16661667
if (bh->b_folio != bd_folio) {
16671668
folio_lock(bd_folio);
1669+
folio_wait_writeback(bd_folio);
16681670
folio_clear_dirty_for_io(bd_folio);
16691671
folio_start_writeback(bd_folio);
16701672
folio_unlock(bd_folio);
@@ -1681,6 +1683,7 @@ static void nilfs_segctor_prepare_write(struct nilfs_sc_info *sci)
16811683
}
16821684
if (bd_folio) {
16831685
folio_lock(bd_folio);
1686+
folio_wait_writeback(bd_folio);
16841687
folio_clear_dirty_for_io(bd_folio);
16851688
folio_start_writeback(bd_folio);
16861689
folio_unlock(bd_folio);

fs/proc/base.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3214,7 +3214,7 @@ static int proc_pid_ksm_stat(struct seq_file *m, struct pid_namespace *ns,
32143214
mm = get_task_mm(task);
32153215
if (mm) {
32163216
seq_printf(m, "ksm_rmap_items %lu\n", mm->ksm_rmap_items);
3217-
seq_printf(m, "ksm_zero_pages %lu\n", mm->ksm_zero_pages);
3217+
seq_printf(m, "ksm_zero_pages %ld\n", mm_ksm_zero_pages(mm));
32183218
seq_printf(m, "ksm_merging_pages %lu\n", mm->ksm_merging_pages);
32193219
seq_printf(m, "ksm_process_profit %ld\n", ksm_process_profit(mm));
32203220
mmput(mm);

include/linux/huge_mm.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,16 @@ enum mthp_stat_item {
269269
MTHP_STAT_ANON_FAULT_ALLOC,
270270
MTHP_STAT_ANON_FAULT_FALLBACK,
271271
MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE,
272-
MTHP_STAT_ANON_SWPOUT,
273-
MTHP_STAT_ANON_SWPOUT_FALLBACK,
272+
MTHP_STAT_SWPOUT,
273+
MTHP_STAT_SWPOUT_FALLBACK,
274274
__MTHP_STAT_COUNT
275275
};
276276

277277
struct mthp_stat {
278278
unsigned long stats[ilog2(MAX_PTRS_PER_PTE) + 1][__MTHP_STAT_COUNT];
279279
};
280280

281+
#ifdef CONFIG_SYSFS
281282
DECLARE_PER_CPU(struct mthp_stat, mthp_stats);
282283

283284
static inline void count_mthp_stat(int order, enum mthp_stat_item item)
@@ -287,6 +288,11 @@ static inline void count_mthp_stat(int order, enum mthp_stat_item item)
287288

288289
this_cpu_inc(mthp_stats.stats[order][item]);
289290
}
291+
#else
292+
static inline void count_mthp_stat(int order, enum mthp_stat_item item)
293+
{
294+
}
295+
#endif
290296

291297
#define transparent_hugepage_use_zero_page() \
292298
(transparent_hugepage_flags & \

include/linux/ksm.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,27 @@ void __ksm_exit(struct mm_struct *mm);
3333
*/
3434
#define is_ksm_zero_pte(pte) (is_zero_pfn(pte_pfn(pte)) && pte_dirty(pte))
3535

36-
extern unsigned long ksm_zero_pages;
36+
extern atomic_long_t ksm_zero_pages;
37+
38+
static inline void ksm_map_zero_page(struct mm_struct *mm)
39+
{
40+
atomic_long_inc(&ksm_zero_pages);
41+
atomic_long_inc(&mm->ksm_zero_pages);
42+
}
3743

3844
static inline void ksm_might_unmap_zero_page(struct mm_struct *mm, pte_t pte)
3945
{
4046
if (is_ksm_zero_pte(pte)) {
41-
ksm_zero_pages--;
42-
mm->ksm_zero_pages--;
47+
atomic_long_dec(&ksm_zero_pages);
48+
atomic_long_dec(&mm->ksm_zero_pages);
4349
}
4450
}
4551

52+
static inline long mm_ksm_zero_pages(struct mm_struct *mm)
53+
{
54+
return atomic_long_read(&mm->ksm_zero_pages);
55+
}
56+
4657
static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
4758
{
4859
if (test_bit(MMF_VM_MERGEABLE, &oldmm->flags))

include/linux/mm_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ struct mm_struct {
985985
* Represent how many empty pages are merged with kernel zero
986986
* pages when enabling KSM use_zero_pages.
987987
*/
988-
unsigned long ksm_zero_pages;
988+
atomic_long_t ksm_zero_pages;
989989
#endif /* CONFIG_KSM */
990990
#ifdef CONFIG_LRU_GEN_WALKS_MMU
991991
struct {

mm/filemap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ struct folio *filemap_alloc_folio_noprof(gfp_t gfp, unsigned int order)
10001000
do {
10011001
cpuset_mems_cookie = read_mems_allowed_begin();
10021002
n = cpuset_mem_spread_node();
1003-
folio = __folio_alloc_node(gfp, order, n);
1003+
folio = __folio_alloc_node_noprof(gfp, order, n);
10041004
} while (!folio && read_mems_allowed_retry(cpuset_mems_cookie));
10051005

10061006
return folio;

mm/huge_memory.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,15 @@ static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
558558
DEFINE_MTHP_STAT_ATTR(anon_fault_alloc, MTHP_STAT_ANON_FAULT_ALLOC);
559559
DEFINE_MTHP_STAT_ATTR(anon_fault_fallback, MTHP_STAT_ANON_FAULT_FALLBACK);
560560
DEFINE_MTHP_STAT_ATTR(anon_fault_fallback_charge, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE);
561-
DEFINE_MTHP_STAT_ATTR(anon_swpout, MTHP_STAT_ANON_SWPOUT);
562-
DEFINE_MTHP_STAT_ATTR(anon_swpout_fallback, MTHP_STAT_ANON_SWPOUT_FALLBACK);
561+
DEFINE_MTHP_STAT_ATTR(swpout, MTHP_STAT_SWPOUT);
562+
DEFINE_MTHP_STAT_ATTR(swpout_fallback, MTHP_STAT_SWPOUT_FALLBACK);
563563

564564
static struct attribute *stats_attrs[] = {
565565
&anon_fault_alloc_attr.attr,
566566
&anon_fault_fallback_attr.attr,
567567
&anon_fault_fallback_charge_attr.attr,
568-
&anon_swpout_attr.attr,
569-
&anon_swpout_fallback_attr.attr,
568+
&swpout_attr.attr,
569+
&swpout_fallback_attr.attr,
570570
NULL,
571571
};
572572

0 commit comments

Comments
 (0)