Skip to content

Commit eb6a933

Browse files
committed
Merge tag 'mm-nonmm-stable-2024-05-19-11-56' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Pull non-mm updates from Andrew Morton: "Mainly singleton patches, documented in their respective changelogs. Notable series include: - Some maintenance and performance work for ocfs2 in Heming Zhao's series "improve write IO performance when fragmentation is high". - Some ocfs2 bugfixes from Su Yue in the series "ocfs2 bugs fixes exposed by fstests". - kfifo header rework from Andy Shevchenko in the series "kfifo: Clean up kfifo.h". - GDB script fixes from Florian Rommel in the series "scripts/gdb: Fixes for $lx_current and $lx_per_cpu". - After much discussion, a coding-style update from Barry Song explaining one reason why inline functions are preferred over macros. The series is "codingstyle: avoid unused parameters for a function-like macro"" * tag 'mm-nonmm-stable-2024-05-19-11-56' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (62 commits) fs/proc: fix softlockup in __read_vmcore nilfs2: convert BUG_ON() in nilfs_finish_roll_forward() to WARN_ON() scripts: checkpatch: check unused parameters for function-like macro Documentation: coding-style: ask function-like macros to evaluate parameters nilfs2: use __field_struct() for a bitwise field selftests/kcmp: remove unused open mode nilfs2: remove calls to folio_set_error() and folio_clear_error() kernel/watchdog_perf.c: tidy up kerneldoc watchdog: allow nmi watchdog to use raw perf event watchdog: handle comma separated nmi_watchdog command line nilfs2: make superblock data array index computation sparse friendly squashfs: remove calls to set the folio error flag squashfs: convert squashfs_symlink_read_folio to use folio APIs scripts/gdb: fix detection of current CPU in KGDB scripts/gdb: make get_thread_info accept pointers scripts/gdb: fix parameter handling in $lx_per_cpu scripts/gdb: fix failing KGDB detection during probe kfifo: don't use "proxy" headers media: stih-cec: add missing io.h media: rc: add missing io.h ...
2 parents 16dbfae + 5cbcb62 commit eb6a933

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+679
-427
lines changed

Documentation/admin-guide/kdump/kdump.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ System kernel config options
136136

137137
CONFIG_KEXEC_CORE=y
138138

139-
Subsequently, CRASH_CORE is selected by KEXEC_CORE::
140-
141-
CONFIG_CRASH_CORE=y
142-
143139
2) Enable "sysfs file system support" in "Filesystem" -> "Pseudo
144140
filesystems." This is usually enabled by default::
145141

@@ -168,6 +164,10 @@ Dump-capture kernel config options (Arch Independent)
168164

169165
CONFIG_CRASH_DUMP=y
170166

167+
And this will select VMCORE_INFO and CRASH_RESERVE::
168+
CONFIG_VMCORE_INFO=y
169+
CONFIG_CRASH_RESERVE=y
170+
171171
2) Enable "/proc/vmcore support" under "Filesystems" -> "Pseudo filesystems"::
172172

173173
CONFIG_PROC_VMCORE=y

Documentation/admin-guide/kernel-parameters.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -3787,10 +3787,12 @@
37873787
Format: [state][,regs][,debounce][,die]
37883788

37893789
nmi_watchdog= [KNL,BUGS=X86] Debugging features for SMP kernels
3790-
Format: [panic,][nopanic,][num]
3790+
Format: [panic,][nopanic,][rNNN,][num]
37913791
Valid num: 0 or 1
37923792
0 - turn hardlockup detector in nmi_watchdog off
37933793
1 - turn hardlockup detector in nmi_watchdog on
3794+
rNNN - configure the watchdog with raw perf event 0xNNN
3795+
37943796
When panic is specified, panic when an NMI watchdog
37953797
timeout occurs (or 'nopanic' to not panic on an NMI
37963798
watchdog, if CONFIG_BOOTPARAM_HARDLOCKUP_PANIC is set)
@@ -7507,4 +7509,3 @@
75077509
memory, and other data can't be written using
75087510
xmon commands.
75097511
off xmon is disabled.
7510-

Documentation/dev-tools/checkpatch.rst

+14
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,20 @@ Macros, Attributes and Symbols
906906

907907
See: https://lore.kernel.org/lkml/1399671106.2912.21.camel@joe-AO725/
908908

909+
**MACRO_ARG_UNUSED**
910+
If function-like macros do not utilize a parameter, it might result
911+
in a build warning. We advocate for utilizing static inline functions
912+
to replace such macros.
913+
For example, for a macro such as the one below::
914+
915+
#define test(a) do { } while (0)
916+
917+
there would be a warning like below::
918+
919+
WARNING: Argument 'a' is not used in function-like macro.
920+
921+
See: https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl
922+
909923
**SINGLE_STATEMENT_DO_WHILE_MACRO**
910924
For the multi-statement macros, it is necessary to use the do-while
911925
loop to avoid unpredictable code paths. The do-while loop helps to

Documentation/process/coding-style.rst

+23
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,29 @@ Macros with multiple statements should be enclosed in a do - while block:
827827
do_this(b, c); \
828828
} while (0)
829829
830+
Function-like macros with unused parameters should be replaced by static
831+
inline functions to avoid the issue of unused variables:
832+
833+
.. code-block:: c
834+
835+
static inline void fun(struct foo *foo)
836+
{
837+
}
838+
839+
Due to historical practices, many files still employ the "cast to (void)"
840+
approach to evaluate parameters. However, this method is not advisable.
841+
Inline functions address the issue of "expression with side effects
842+
evaluated more than once", circumvent unused-variable problems, and
843+
are generally better documented than macros for some reason.
844+
845+
.. code-block:: c
846+
847+
/*
848+
* Avoid doing this whenever possible and instead opt for static
849+
* inline functions
850+
*/
851+
#define macrofun(foo) do { (void) (foo); } while (0)
852+
830853
Things to avoid when using macros:
831854

832855
1) macros that affect control flow:

arch/x86/lib/copy_mc.c

+17-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/jump_label.h>
55
#include <linux/uaccess.h>
66
#include <linux/export.h>
7+
#include <linux/instrumented.h>
78
#include <linux/string.h>
89
#include <linux/types.h>
910

@@ -61,10 +62,20 @@ unsigned long copy_mc_enhanced_fast_string(void *dst, const void *src, unsigned
6162
*/
6263
unsigned long __must_check copy_mc_to_kernel(void *dst, const void *src, unsigned len)
6364
{
64-
if (copy_mc_fragile_enabled)
65-
return copy_mc_fragile(dst, src, len);
66-
if (static_cpu_has(X86_FEATURE_ERMS))
67-
return copy_mc_enhanced_fast_string(dst, src, len);
65+
unsigned long ret;
66+
67+
if (copy_mc_fragile_enabled) {
68+
instrument_memcpy_before(dst, src, len);
69+
ret = copy_mc_fragile(dst, src, len);
70+
instrument_memcpy_after(dst, src, len, ret);
71+
return ret;
72+
}
73+
if (static_cpu_has(X86_FEATURE_ERMS)) {
74+
instrument_memcpy_before(dst, src, len);
75+
ret = copy_mc_enhanced_fast_string(dst, src, len);
76+
instrument_memcpy_after(dst, src, len, ret);
77+
return ret;
78+
}
6879
memcpy(dst, src, len);
6980
return 0;
7081
}
@@ -75,13 +86,15 @@ unsigned long __must_check copy_mc_to_user(void __user *dst, const void *src, un
7586
unsigned long ret;
7687

7788
if (copy_mc_fragile_enabled) {
89+
instrument_copy_to_user(dst, src, len);
7890
__uaccess_begin();
7991
ret = copy_mc_fragile((__force void *)dst, src, len);
8092
__uaccess_end();
8193
return ret;
8294
}
8395

8496
if (static_cpu_has(X86_FEATURE_ERMS)) {
97+
instrument_copy_to_user(dst, src, len);
8598
__uaccess_begin();
8699
ret = copy_mc_enhanced_fast_string((__force void *)dst, src, len);
87100
__uaccess_end();

block/partitions/ldm.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
131131
ldm_crit ("Cannot find TOCBLOCK, database may be corrupt.");
132132
return false;
133133
}
134-
strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name));
135-
toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0;
134+
strscpy_pad(toc->bitmap1_name, data + 0x24, sizeof(toc->bitmap1_name));
136135
toc->bitmap1_start = get_unaligned_be64(data + 0x2E);
137136
toc->bitmap1_size = get_unaligned_be64(data + 0x36);
138137

@@ -142,8 +141,7 @@ static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
142141
TOC_BITMAP1, toc->bitmap1_name);
143142
return false;
144143
}
145-
strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name));
146-
toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0;
144+
strscpy_pad(toc->bitmap2_name, data + 0x46, sizeof(toc->bitmap2_name));
147145
toc->bitmap2_start = get_unaligned_be64(data + 0x50);
148146
toc->bitmap2_size = get_unaligned_be64(data + 0x58);
149147
if (strncmp (toc->bitmap2_name, TOC_BITMAP2,

drivers/hwtracing/intel_th/core.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ intel_th_alloc(struct device *dev, const struct intel_th_drvdata *drvdata,
871871
if (!th)
872872
return ERR_PTR(-ENOMEM);
873873

874-
th->id = ida_simple_get(&intel_th_ida, 0, 0, GFP_KERNEL);
874+
th->id = ida_alloc(&intel_th_ida, GFP_KERNEL);
875875
if (th->id < 0) {
876876
err = th->id;
877877
goto err_alloc;
@@ -931,7 +931,7 @@ intel_th_alloc(struct device *dev, const struct intel_th_drvdata *drvdata,
931931
"intel_th/output");
932932

933933
err_ida:
934-
ida_simple_remove(&intel_th_ida, th->id);
934+
ida_free(&intel_th_ida, th->id);
935935

936936
err_alloc:
937937
kfree(th);
@@ -964,7 +964,7 @@ void intel_th_free(struct intel_th *th)
964964
__unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS,
965965
"intel_th/output");
966966

967-
ida_simple_remove(&intel_th_ida, th->id);
967+
ida_free(&intel_th_ida, th->id);
968968

969969
kfree(th);
970970
}

drivers/media/cec/platform/sti/stih-cec.c

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
#include <linux/clk.h>
88
#include <linux/interrupt.h>
9+
#include <linux/io.h>
910
#include <linux/kernel.h>
1011
#include <linux/mfd/syscon.h>
1112
#include <linux/module.h>

drivers/media/rc/mtk-cir.c

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/clk.h>
99
#include <linux/interrupt.h>
1010
#include <linux/module.h>
11+
#include <linux/io.h>
1112
#include <linux/of.h>
1213
#include <linux/platform_device.h>
1314
#include <linux/reset.h>

drivers/media/rc/serial_ir.c

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/module.h>
1919
#include <linux/errno.h>
2020
#include <linux/interrupt.h>
21+
#include <linux/io.h>
2122
#include <linux/kernel.h>
2223
#include <linux/serial_reg.h>
2324
#include <linux/types.h>

drivers/media/rc/st_rc.c

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/kernel.h>
77
#include <linux/clk.h>
88
#include <linux/interrupt.h>
9+
#include <linux/io.h>
910
#include <linux/module.h>
1011
#include <linux/of.h>
1112
#include <linux/platform_device.h>

drivers/media/rc/sunxi-cir.c

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <linux/clk.h>
1414
#include <linux/interrupt.h>
15+
#include <linux/io.h>
1516
#include <linux/module.h>
1617
#include <linux/of.h>
1718
#include <linux/platform_device.h>

drivers/mux/core.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void mux_chip_release(struct device *dev)
6464
{
6565
struct mux_chip *mux_chip = to_mux_chip(dev);
6666

67-
ida_simple_remove(&mux_ida, mux_chip->id);
67+
ida_free(&mux_ida, mux_chip->id);
6868
kfree(mux_chip);
6969
}
7070

@@ -111,7 +111,7 @@ struct mux_chip *mux_chip_alloc(struct device *dev,
111111
mux_chip->dev.of_node = dev->of_node;
112112
dev_set_drvdata(&mux_chip->dev, mux_chip);
113113

114-
mux_chip->id = ida_simple_get(&mux_ida, 0, 0, GFP_KERNEL);
114+
mux_chip->id = ida_alloc(&mux_ida, GFP_KERNEL);
115115
if (mux_chip->id < 0) {
116116
int err = mux_chip->id;
117117

drivers/pps/clients/pps_parport.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static void parport_attach(struct parport *port)
148148
return;
149149
}
150150

151-
index = ida_simple_get(&pps_client_index, 0, 0, GFP_KERNEL);
151+
index = ida_alloc(&pps_client_index, GFP_KERNEL);
152152
memset(&pps_client_cb, 0, sizeof(pps_client_cb));
153153
pps_client_cb.private = device;
154154
pps_client_cb.irq_func = parport_irq;
@@ -188,7 +188,7 @@ static void parport_attach(struct parport *port)
188188
err_unregister_dev:
189189
parport_unregister_device(device->pardev);
190190
err_free:
191-
ida_simple_remove(&pps_client_index, index);
191+
ida_free(&pps_client_index, index);
192192
kfree(device);
193193
}
194194

@@ -208,7 +208,7 @@ static void parport_detach(struct parport *port)
208208
pps_unregister_source(device->pps);
209209
parport_release(pardev);
210210
parport_unregister_device(pardev);
211-
ida_simple_remove(&pps_client_index, device->index);
211+
ida_free(&pps_client_index, device->index);
212212
kfree(device);
213213
}
214214

fs/binfmt_elf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ static void free_note_info(struct elf_note_info *info)
19341934
threads = t->next;
19351935
WARN_ON(t->notes[0].data && t->notes[0].data != &t->prstatus);
19361936
for (i = 1; i < info->thread_notes; ++i)
1937-
kfree(t->notes[i].data);
1937+
kvfree(t->notes[i].data);
19381938
kfree(t);
19391939
}
19401940
kfree(info->psinfo.data);

fs/fat/dir.c

+12
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ enum { PARSE_INVALID = 1, PARSE_NOT_LONGNAME, PARSE_EOF, };
269269
/**
270270
* fat_parse_long - Parse extended directory entry.
271271
*
272+
* @dir: Pointer to the inode that represents the directory.
273+
* @pos: On input, contains the starting position to read from.
274+
* On output, updated with the new position.
275+
* @bh: Pointer to the buffer head that may be used for reading directory
276+
* entries. May be updated.
277+
* @de: On input, points to the current directory entry.
278+
* On output, points to the next directory entry.
279+
* @unicode: Pointer to a buffer where the parsed Unicode long filename will be
280+
* stored.
281+
* @nr_slots: Pointer to a variable that will store the number of longname
282+
* slots found.
283+
*
272284
* This function returns zero on success, negative value on error, or one of
273285
* the following:
274286
*

fs/nilfs2/btree.c

+16-7
Original file line numberDiff line numberDiff line change
@@ -1857,13 +1857,22 @@ nilfs_btree_commit_convert_and_insert(struct nilfs_bmap *btree,
18571857
}
18581858

18591859
/**
1860-
* nilfs_btree_convert_and_insert -
1861-
* @bmap:
1862-
* @key:
1863-
* @ptr:
1864-
* @keys:
1865-
* @ptrs:
1866-
* @n:
1860+
* nilfs_btree_convert_and_insert - Convert and insert entries into a B-tree
1861+
* @btree: NILFS B-tree structure
1862+
* @key: Key of the new entry to be inserted
1863+
* @ptr: Pointer (block number) associated with the key to be inserted
1864+
* @keys: Array of keys to be inserted in addition to @key
1865+
* @ptrs: Array of pointers associated with @keys
1866+
* @n: Number of keys and pointers in @keys and @ptrs
1867+
*
1868+
* This function is used to insert a new entry specified by @key and @ptr,
1869+
* along with additional entries specified by @keys and @ptrs arrays, into a
1870+
* NILFS B-tree.
1871+
* It prepares the necessary changes by allocating the required blocks and any
1872+
* necessary intermediate nodes. It converts configurations from other forms of
1873+
* block mapping (the one that currently exists is direct mapping) to a B-tree.
1874+
*
1875+
* Return: 0 on success or a negative error code on failure.
18671876
*/
18681877
int nilfs_btree_convert_and_insert(struct nilfs_bmap *btree,
18691878
__u64 key, __u64 ptr,

fs/nilfs2/dir.c

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static bool nilfs_check_folio(struct folio *folio, char *kaddr)
174174
dir->i_ino, (folio->index << PAGE_SHIFT) + offs,
175175
(unsigned long)le64_to_cpu(p->inode));
176176
fail:
177-
folio_set_error(folio);
178177
return false;
179178
}
180179

fs/nilfs2/gcinode.c

+1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ int nilfs_init_gcinode(struct inode *inode)
175175

176176
/**
177177
* nilfs_remove_all_gcinodes() - remove all unprocessed gc inodes
178+
* @nilfs: NILFS filesystem instance
178179
*/
179180
void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs)
180181
{

fs/nilfs2/nilfs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ void __nilfs_error(struct super_block *sb, const char *function,
335335

336336
extern struct nilfs_super_block *
337337
nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
338-
extern int nilfs_store_magic_and_option(struct super_block *,
339-
struct nilfs_super_block *, char *);
338+
extern int nilfs_store_magic(struct super_block *sb,
339+
struct nilfs_super_block *sbp);
340340
extern int nilfs_check_feature_compatibility(struct super_block *,
341341
struct nilfs_super_block *);
342342
extern void nilfs_set_log_cursor(struct nilfs_super_block *,

fs/nilfs2/recovery.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
563563
* checkpoint
564564
* @nilfs: nilfs object
565565
* @sb: super block instance
566+
* @root: NILFS root instance
566567
* @ri: pointer to a nilfs_recovery_info
567568
*/
568569
static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
@@ -698,7 +699,9 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
698699
return;
699700

700701
bh = __getblk(nilfs->ns_bdev, ri->ri_lsegs_start, nilfs->ns_blocksize);
701-
BUG_ON(!bh);
702+
if (WARN_ON(!bh))
703+
return; /* should never happen */
704+
702705
memset(bh->b_data, 0, bh->b_size);
703706
set_buffer_dirty(bh);
704707
err = sync_dirty_buffer(bh);

fs/nilfs2/segment.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -1725,14 +1725,8 @@ static void nilfs_end_folio_io(struct folio *folio, int err)
17251725
return;
17261726
}
17271727

1728-
if (!err) {
1729-
if (!nilfs_folio_buffers_clean(folio))
1730-
filemap_dirty_folio(folio->mapping, folio);
1731-
folio_clear_error(folio);
1732-
} else {
1728+
if (err || !nilfs_folio_buffers_clean(folio))
17331729
filemap_dirty_folio(folio->mapping, folio);
1734-
folio_set_error(folio);
1735-
}
17361730

17371731
folio_end_writeback(folio);
17381732
}

0 commit comments

Comments
 (0)