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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 14 additions & 0 deletions
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

Lines changed: 23 additions & 0 deletions
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

Lines changed: 17 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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>

0 commit comments

Comments
 (0)