Commit eb6a9339 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'mm-nonmm-stable-2024-05-19-11-56' of...

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
  ...
parents 16dbfae8 5cbcb62d
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -136,10 +136,6 @@ System kernel config options

	CONFIG_KEXEC_CORE=y

   Subsequently, CRASH_CORE is selected by KEXEC_CORE::

	CONFIG_CRASH_CORE=y

2) Enable "sysfs file system support" in "Filesystem" -> "Pseudo
   filesystems." This is usually enabled by default::

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

	CONFIG_CRASH_DUMP=y

   And this will select VMCORE_INFO and CRASH_RESERVE::
	CONFIG_VMCORE_INFO=y
	CONFIG_CRASH_RESERVE=y

2) Enable "/proc/vmcore support" under "Filesystems" -> "Pseudo filesystems"::

	CONFIG_PROC_VMCORE=y
+3 −2
Original line number Diff line number Diff line
@@ -3787,10 +3787,12 @@
			Format: [state][,regs][,debounce][,die]

	nmi_watchdog=	[KNL,BUGS=X86] Debugging features for SMP kernels
			Format: [panic,][nopanic,][num]
			Format: [panic,][nopanic,][rNNN,][num]
			Valid num: 0 or 1
			0 - turn hardlockup detector in nmi_watchdog off
			1 - turn hardlockup detector in nmi_watchdog on
			rNNN - configure the watchdog with raw perf event 0xNNN

			When panic is specified, panic when an NMI watchdog
			timeout occurs (or 'nopanic' to not panic on an NMI
			watchdog, if CONFIG_BOOTPARAM_HARDLOCKUP_PANIC is set)
@@ -7507,4 +7509,3 @@
				memory, and other data can't be written using
				xmon commands.
			off	xmon is disabled.
+14 −0
Original line number Diff line number Diff line
@@ -906,6 +906,20 @@ Macros, Attributes and Symbols

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

  **MACRO_ARG_UNUSED**
    If function-like macros do not utilize a parameter, it might result
    in a build warning. We advocate for utilizing static inline functions
    to replace such macros.
    For example, for a macro such as the one below::

      #define test(a) do { } while (0)

    there would be a warning like below::

      WARNING: Argument 'a' is not used in function-like macro.

    See: https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl

  **SINGLE_STATEMENT_DO_WHILE_MACRO**
    For the multi-statement macros, it is necessary to use the do-while
    loop to avoid unpredictable code paths. The do-while loop helps to
+23 −0
Original line number Diff line number Diff line
@@ -827,6 +827,29 @@ Macros with multiple statements should be enclosed in a do - while block:
				do_this(b, c);		\
		} while (0)

Function-like macros with unused parameters should be replaced by static
inline functions to avoid the issue of unused variables:

.. code-block:: c

	static inline void fun(struct foo *foo)
	{
	}

Due to historical practices, many files still employ the "cast to (void)"
approach to evaluate parameters. However, this method is not advisable.
Inline functions address the issue of "expression with side effects
evaluated more than once", circumvent unused-variable problems, and
are generally better documented than macros for some reason.

.. code-block:: c

	/*
	 * Avoid doing this whenever possible and instead opt for static
	 * inline functions
	 */
	#define macrofun(foo) do { (void) (foo); } while (0)

Things to avoid when using macros:

1) macros that affect control flow:
+17 −4
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
#include <linux/jump_label.h>
#include <linux/uaccess.h>
#include <linux/export.h>
#include <linux/instrumented.h>
#include <linux/string.h>
#include <linux/types.h>

@@ -61,10 +62,20 @@ unsigned long copy_mc_enhanced_fast_string(void *dst, const void *src, unsigned
 */
unsigned long __must_check copy_mc_to_kernel(void *dst, const void *src, unsigned len)
{
	if (copy_mc_fragile_enabled)
		return copy_mc_fragile(dst, src, len);
	if (static_cpu_has(X86_FEATURE_ERMS))
		return copy_mc_enhanced_fast_string(dst, src, len);
	unsigned long ret;

	if (copy_mc_fragile_enabled) {
		instrument_memcpy_before(dst, src, len);
		ret = copy_mc_fragile(dst, src, len);
		instrument_memcpy_after(dst, src, len, ret);
		return ret;
	}
	if (static_cpu_has(X86_FEATURE_ERMS)) {
		instrument_memcpy_before(dst, src, len);
		ret = copy_mc_enhanced_fast_string(dst, src, len);
		instrument_memcpy_after(dst, src, len, ret);
		return ret;
	}
	memcpy(dst, src, len);
	return 0;
}
@@ -75,6 +86,7 @@ unsigned long __must_check copy_mc_to_user(void __user *dst, const void *src, un
	unsigned long ret;

	if (copy_mc_fragile_enabled) {
		instrument_copy_to_user(dst, src, len);
		__uaccess_begin();
		ret = copy_mc_fragile((__force void *)dst, src, len);
		__uaccess_end();
@@ -82,6 +94,7 @@ unsigned long __must_check copy_mc_to_user(void __user *dst, const void *src, un
	}

	if (static_cpu_has(X86_FEATURE_ERMS)) {
		instrument_copy_to_user(dst, src, len);
		__uaccess_begin();
		ret = copy_mc_enhanced_fast_string((__force void *)dst, src, len);
		__uaccess_end();
Loading