Skip to content

Commit 76c0f27

Browse files
committed
Merge tag 'mm-hotfixes-stable-2024-09-03-20-19' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull misc fixes from Andrew Morton: "17 hotfixes, 15 of which are cc:stable. Mostly MM, no identifiable theme. And a few nilfs2 fixups" * tag 'mm-hotfixes-stable-2024-09-03-20-19' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: alloc_tag: fix allocation tag reporting when CONFIG_MODULES=n mm: vmalloc: optimize vmap_lazy_nr arithmetic when purging each vmap_area mailmap: update entry for Jan Kuliga codetag: debug: mark codetags for poisoned page as empty mm/memcontrol: respect zswap.writeback setting from parent cg too scripts: fix gfp-translate after ___GFP_*_BITS conversion to an enum Revert "mm: skip CMA pages when they are not available" maple_tree: remove rcu_read_lock() from mt_validate() kexec_file: fix elfcorehdr digest exclusion when CONFIG_CRASH_HOTPLUG=y mm/slub: add check for s->flags in the alloc_tagging_slab_free_hook nilfs2: fix state management in error path of log writing function nilfs2: fix missing cleanup on rollforward recovery error nilfs2: protect references to superblock parameters exposed in sysfs userfaultfd: don't BUG_ON() if khugepaged yanks our page table userfaultfd: fix checks for huge PMDs mm: vmalloc: ensure vmap_block is initialised before adding to queue selftests: mm: fix build errors on armhf
2 parents 88fac17 + 052a45c commit 76c0f27

File tree

17 files changed

+197
-124
lines changed

17 files changed

+197
-124
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ James Ketrenos <jketreno@io.(none)>
269269
270270
271271
272+
272273
273274
274275

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,9 +1717,10 @@ The following nested keys are defined.
17171717
entries fault back in or are written out to disk.
17181718

17191719
memory.zswap.writeback
1720-
A read-write single value file. The default value is "1". The
1721-
initial value of the root cgroup is 1, and when a new cgroup is
1722-
created, it inherits the current value of its parent.
1720+
A read-write single value file. The default value is "1".
1721+
Note that this setting is hierarchical, i.e. the writeback would be
1722+
implicitly disabled for child cgroups if the upper hierarchy
1723+
does so.
17231724

17241725
When this is set to 0, all swapping attempts to swapping devices
17251726
are disabled. This included both zswap writebacks, and swapping due

fs/nilfs2/recovery.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,33 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
715715
brelse(bh);
716716
}
717717

718+
/**
719+
* nilfs_abort_roll_forward - cleaning up after a failed rollforward recovery
720+
* @nilfs: nilfs object
721+
*/
722+
static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)
723+
{
724+
struct nilfs_inode_info *ii, *n;
725+
LIST_HEAD(head);
726+
727+
/* Abandon inodes that have read recovery data */
728+
spin_lock(&nilfs->ns_inode_lock);
729+
list_splice_init(&nilfs->ns_dirty_files, &head);
730+
spin_unlock(&nilfs->ns_inode_lock);
731+
if (list_empty(&head))
732+
return;
733+
734+
set_nilfs_purging(nilfs);
735+
list_for_each_entry_safe(ii, n, &head, i_dirty) {
736+
spin_lock(&nilfs->ns_inode_lock);
737+
list_del_init(&ii->i_dirty);
738+
spin_unlock(&nilfs->ns_inode_lock);
739+
740+
iput(&ii->vfs_inode);
741+
}
742+
clear_nilfs_purging(nilfs);
743+
}
744+
718745
/**
719746
* nilfs_salvage_orphan_logs - salvage logs written after the latest checkpoint
720747
* @nilfs: nilfs object
@@ -773,15 +800,19 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,
773800
if (unlikely(err)) {
774801
nilfs_err(sb, "error %d writing segment for recovery",
775802
err);
776-
goto failed;
803+
goto put_root;
777804
}
778805

779806
nilfs_finish_roll_forward(nilfs, ri);
780807
}
781808

782-
failed:
809+
put_root:
783810
nilfs_put_root(root);
784811
return err;
812+
813+
failed:
814+
nilfs_abort_roll_forward(nilfs);
815+
goto put_root;
785816
}
786817

787818
/**

fs/nilfs2/segment.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,9 @@ static void nilfs_segctor_abort_construction(struct nilfs_sc_info *sci,
18121812
nilfs_abort_logs(&logs, ret ? : err);
18131813

18141814
list_splice_tail_init(&sci->sc_segbufs, &logs);
1815+
if (list_empty(&logs))
1816+
return; /* if the first segment buffer preparation failed */
1817+
18151818
nilfs_cancel_segusage(&logs, nilfs->ns_sufile);
18161819
nilfs_free_incomplete_logs(&logs, nilfs);
18171820

@@ -2056,7 +2059,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
20562059

20572060
err = nilfs_segctor_begin_construction(sci, nilfs);
20582061
if (unlikely(err))
2059-
goto out;
2062+
goto failed;
20602063

20612064
/* Update time stamp */
20622065
sci->sc_seg_ctime = ktime_get_real_seconds();
@@ -2120,10 +2123,9 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode)
21202123
return err;
21212124

21222125
failed_to_write:
2123-
if (sci->sc_stage.flags & NILFS_CF_IFILE_STARTED)
2124-
nilfs_redirty_inodes(&sci->sc_dirty_files);
2125-
21262126
failed:
2127+
if (mode == SC_LSEG_SR && nilfs_sc_cstage_get(sci) >= NILFS_ST_IFILE)
2128+
nilfs_redirty_inodes(&sci->sc_dirty_files);
21272129
if (nilfs_doing_gc())
21282130
nilfs_redirty_inodes(&sci->sc_gc_inodes);
21292131
nilfs_segctor_abort_construction(sci, nilfs, err);

fs/nilfs2/sysfs.c

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,15 @@ ssize_t nilfs_dev_revision_show(struct nilfs_dev_attr *attr,
836836
struct the_nilfs *nilfs,
837837
char *buf)
838838
{
839-
struct nilfs_super_block **sbp = nilfs->ns_sbp;
840-
u32 major = le32_to_cpu(sbp[0]->s_rev_level);
841-
u16 minor = le16_to_cpu(sbp[0]->s_minor_rev_level);
839+
struct nilfs_super_block *raw_sb;
840+
u32 major;
841+
u16 minor;
842+
843+
down_read(&nilfs->ns_sem);
844+
raw_sb = nilfs->ns_sbp[0];
845+
major = le32_to_cpu(raw_sb->s_rev_level);
846+
minor = le16_to_cpu(raw_sb->s_minor_rev_level);
847+
up_read(&nilfs->ns_sem);
842848

843849
return sysfs_emit(buf, "%d.%d\n", major, minor);
844850
}
@@ -856,8 +862,13 @@ ssize_t nilfs_dev_device_size_show(struct nilfs_dev_attr *attr,
856862
struct the_nilfs *nilfs,
857863
char *buf)
858864
{
859-
struct nilfs_super_block **sbp = nilfs->ns_sbp;
860-
u64 dev_size = le64_to_cpu(sbp[0]->s_dev_size);
865+
struct nilfs_super_block *raw_sb;
866+
u64 dev_size;
867+
868+
down_read(&nilfs->ns_sem);
869+
raw_sb = nilfs->ns_sbp[0];
870+
dev_size = le64_to_cpu(raw_sb->s_dev_size);
871+
up_read(&nilfs->ns_sem);
861872

862873
return sysfs_emit(buf, "%llu\n", dev_size);
863874
}
@@ -879,20 +890,32 @@ ssize_t nilfs_dev_uuid_show(struct nilfs_dev_attr *attr,
879890
struct the_nilfs *nilfs,
880891
char *buf)
881892
{
882-
struct nilfs_super_block **sbp = nilfs->ns_sbp;
893+
struct nilfs_super_block *raw_sb;
894+
ssize_t len;
883895

884-
return sysfs_emit(buf, "%pUb\n", sbp[0]->s_uuid);
896+
down_read(&nilfs->ns_sem);
897+
raw_sb = nilfs->ns_sbp[0];
898+
len = sysfs_emit(buf, "%pUb\n", raw_sb->s_uuid);
899+
up_read(&nilfs->ns_sem);
900+
901+
return len;
885902
}
886903

887904
static
888905
ssize_t nilfs_dev_volume_name_show(struct nilfs_dev_attr *attr,
889906
struct the_nilfs *nilfs,
890907
char *buf)
891908
{
892-
struct nilfs_super_block **sbp = nilfs->ns_sbp;
909+
struct nilfs_super_block *raw_sb;
910+
ssize_t len;
911+
912+
down_read(&nilfs->ns_sem);
913+
raw_sb = nilfs->ns_sbp[0];
914+
len = scnprintf(buf, sizeof(raw_sb->s_volume_name), "%s\n",
915+
raw_sb->s_volume_name);
916+
up_read(&nilfs->ns_sem);
893917

894-
return scnprintf(buf, sizeof(sbp[0]->s_volume_name), "%s\n",
895-
sbp[0]->s_volume_name);
918+
return len;
896919
}
897920

898921
static const char dev_readme_str[] =

kernel/kexec_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static int kexec_calculate_store_digests(struct kimage *image)
752752

753753
#ifdef CONFIG_CRASH_HOTPLUG
754754
/* Exclude elfcorehdr segment to allow future changes via hotplug */
755-
if (j == image->elfcorehdr_index)
755+
if (i == image->elfcorehdr_index)
756756
continue;
757757
#endif
758758

lib/codetag.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ static inline size_t range_size(const struct codetag_type *cttype,
125125
cttype->desc.tag_size;
126126
}
127127

128-
#ifdef CONFIG_MODULES
129128
static void *get_symbol(struct module *mod, const char *prefix, const char *name)
130129
{
131130
DECLARE_SEQ_BUF(sb, KSYM_NAME_LEN);
@@ -155,6 +154,15 @@ static struct codetag_range get_section_range(struct module *mod,
155154
};
156155
}
157156

157+
static const char *get_mod_name(__maybe_unused struct module *mod)
158+
{
159+
#ifdef CONFIG_MODULES
160+
if (mod)
161+
return mod->name;
162+
#endif
163+
return "(built-in)";
164+
}
165+
158166
static int codetag_module_init(struct codetag_type *cttype, struct module *mod)
159167
{
160168
struct codetag_range range;
@@ -164,8 +172,7 @@ static int codetag_module_init(struct codetag_type *cttype, struct module *mod)
164172
range = get_section_range(mod, cttype->desc.section);
165173
if (!range.start || !range.stop) {
166174
pr_warn("Failed to load code tags of type %s from the module %s\n",
167-
cttype->desc.section,
168-
mod ? mod->name : "(built-in)");
175+
cttype->desc.section, get_mod_name(mod));
169176
return -EINVAL;
170177
}
171178

@@ -199,6 +206,7 @@ static int codetag_module_init(struct codetag_type *cttype, struct module *mod)
199206
return 0;
200207
}
201208

209+
#ifdef CONFIG_MODULES
202210
void codetag_load_module(struct module *mod)
203211
{
204212
struct codetag_type *cttype;
@@ -248,9 +256,6 @@ bool codetag_unload_module(struct module *mod)
248256

249257
return unload_ok;
250258
}
251-
252-
#else /* CONFIG_MODULES */
253-
static int codetag_module_init(struct codetag_type *cttype, struct module *mod) { return 0; }
254259
#endif /* CONFIG_MODULES */
255260

256261
struct codetag_type *

lib/maple_tree.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7566,14 +7566,14 @@ static void mt_validate_nulls(struct maple_tree *mt)
75667566
* 2. The gap is correctly set in the parents
75677567
*/
75687568
void mt_validate(struct maple_tree *mt)
7569+
__must_hold(mas->tree->ma_lock)
75697570
{
75707571
unsigned char end;
75717572

75727573
MA_STATE(mas, mt, 0, 0);
7573-
rcu_read_lock();
75747574
mas_start(&mas);
75757575
if (!mas_is_active(&mas))
7576-
goto done;
7576+
return;
75777577

75787578
while (!mte_is_leaf(mas.node))
75797579
mas_descend(&mas);
@@ -7594,9 +7594,6 @@ void mt_validate(struct maple_tree *mt)
75947594
mas_dfs_postorder(&mas, ULONG_MAX);
75957595
}
75967596
mt_validate_nulls(mt);
7597-
done:
7598-
rcu_read_unlock();
7599-
76007597
}
76017598
EXPORT_SYMBOL_GPL(mt_validate);
76027599

mm/memcontrol.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,8 +3613,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
36133613
memcg1_soft_limit_reset(memcg);
36143614
#ifdef CONFIG_ZSWAP
36153615
memcg->zswap_max = PAGE_COUNTER_MAX;
3616-
WRITE_ONCE(memcg->zswap_writeback,
3617-
!parent || READ_ONCE(parent->zswap_writeback));
3616+
WRITE_ONCE(memcg->zswap_writeback, true);
36183617
#endif
36193618
page_counter_set_high(&memcg->swap, PAGE_COUNTER_MAX);
36203619
if (parent) {
@@ -5320,7 +5319,14 @@ void obj_cgroup_uncharge_zswap(struct obj_cgroup *objcg, size_t size)
53205319
bool mem_cgroup_zswap_writeback_enabled(struct mem_cgroup *memcg)
53215320
{
53225321
/* if zswap is disabled, do not block pages going to the swapping device */
5323-
return !zswap_is_enabled() || !memcg || READ_ONCE(memcg->zswap_writeback);
5322+
if (!zswap_is_enabled())
5323+
return true;
5324+
5325+
for (; memcg; memcg = parent_mem_cgroup(memcg))
5326+
if (!READ_ONCE(memcg->zswap_writeback))
5327+
return false;
5328+
5329+
return true;
53245330
}
53255331

53265332
static u64 zswap_current_read(struct cgroup_subsys_state *css,

mm/page_alloc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,13 @@ __always_inline bool free_pages_prepare(struct page *page,
10541054
reset_page_owner(page, order);
10551055
page_table_check_free(page, order);
10561056
pgalloc_tag_sub(page, 1 << order);
1057+
1058+
/*
1059+
* The page is isolated and accounted for.
1060+
* Mark the codetag as empty to avoid accounting error
1061+
* when the page is freed by unpoison_memory().
1062+
*/
1063+
clear_page_tag_ref(page);
10571064
return false;
10581065
}
10591066

0 commit comments

Comments
 (0)