Skip to content

Commit

Permalink
Merge tag 'mm-nonmm-stable-2024-05-19-11-56' of git:https://git.kernel.org/…
Browse files Browse the repository at this point in the history
…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:https://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
  ...
  • Loading branch information
torvalds committed May 19, 2024
2 parents 16dbfae + 5cbcb62 commit eb6a933
Show file tree
Hide file tree
Showing 77 changed files with 679 additions and 427 deletions.
8 changes: 4 additions & 4 deletions Documentation/admin-guide/kdump/kdump.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -7507,4 +7509,3 @@
memory, and other data can't be written using
xmon commands.
off xmon is disabled.

14 changes: 14 additions & 0 deletions Documentation/dev-tools/checkpatch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions Documentation/process/coding-style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 17 additions & 4 deletions arch/x86/lib/copy_mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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;
}
Expand All @@ -75,13 +86,15 @@ 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();
return ret;
}

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();
Expand Down
6 changes: 2 additions & 4 deletions block/partitions/ldm.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
ldm_crit ("Cannot find TOCBLOCK, database may be corrupt.");
return false;
}
strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name));
toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0;
strscpy_pad(toc->bitmap1_name, data + 0x24, sizeof(toc->bitmap1_name));
toc->bitmap1_start = get_unaligned_be64(data + 0x2E);
toc->bitmap1_size = get_unaligned_be64(data + 0x36);

Expand All @@ -142,8 +141,7 @@ static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
TOC_BITMAP1, toc->bitmap1_name);
return false;
}
strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name));
toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0;
strscpy_pad(toc->bitmap2_name, data + 0x46, sizeof(toc->bitmap2_name));
toc->bitmap2_start = get_unaligned_be64(data + 0x50);
toc->bitmap2_size = get_unaligned_be64(data + 0x58);
if (strncmp (toc->bitmap2_name, TOC_BITMAP2,
Expand Down
6 changes: 3 additions & 3 deletions drivers/hwtracing/intel_th/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ intel_th_alloc(struct device *dev, const struct intel_th_drvdata *drvdata,
if (!th)
return ERR_PTR(-ENOMEM);

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

err_ida:
ida_simple_remove(&intel_th_ida, th->id);
ida_free(&intel_th_ida, th->id);

err_alloc:
kfree(th);
Expand Down Expand Up @@ -964,7 +964,7 @@ void intel_th_free(struct intel_th *th)
__unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS,
"intel_th/output");

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

kfree(th);
}
Expand Down
1 change: 1 addition & 0 deletions drivers/media/cec/platform/sti/stih-cec.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/media/rc/mtk-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/reset.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/media/rc/serial_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/serial_reg.h>
#include <linux/types.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/media/rc/st_rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/media/rc/sunxi-cir.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
Expand Down
4 changes: 2 additions & 2 deletions drivers/mux/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void mux_chip_release(struct device *dev)
{
struct mux_chip *mux_chip = to_mux_chip(dev);

ida_simple_remove(&mux_ida, mux_chip->id);
ida_free(&mux_ida, mux_chip->id);
kfree(mux_chip);
}

Expand Down Expand Up @@ -111,7 +111,7 @@ struct mux_chip *mux_chip_alloc(struct device *dev,
mux_chip->dev.of_node = dev->of_node;
dev_set_drvdata(&mux_chip->dev, mux_chip);

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

Expand Down
6 changes: 3 additions & 3 deletions drivers/pps/clients/pps_parport.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static void parport_attach(struct parport *port)
return;
}

index = ida_simple_get(&pps_client_index, 0, 0, GFP_KERNEL);
index = ida_alloc(&pps_client_index, GFP_KERNEL);
memset(&pps_client_cb, 0, sizeof(pps_client_cb));
pps_client_cb.private = device;
pps_client_cb.irq_func = parport_irq;
Expand Down Expand Up @@ -188,7 +188,7 @@ static void parport_attach(struct parport *port)
err_unregister_dev:
parport_unregister_device(device->pardev);
err_free:
ida_simple_remove(&pps_client_index, index);
ida_free(&pps_client_index, index);
kfree(device);
}

Expand All @@ -208,7 +208,7 @@ static void parport_detach(struct parport *port)
pps_unregister_source(device->pps);
parport_release(pardev);
parport_unregister_device(pardev);
ida_simple_remove(&pps_client_index, device->index);
ida_free(&pps_client_index, device->index);
kfree(device);
}

Expand Down
2 changes: 1 addition & 1 deletion fs/binfmt_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ static void free_note_info(struct elf_note_info *info)
threads = t->next;
WARN_ON(t->notes[0].data && t->notes[0].data != &t->prstatus);
for (i = 1; i < info->thread_notes; ++i)
kfree(t->notes[i].data);
kvfree(t->notes[i].data);
kfree(t);
}
kfree(info->psinfo.data);
Expand Down
12 changes: 12 additions & 0 deletions fs/fat/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ enum { PARSE_INVALID = 1, PARSE_NOT_LONGNAME, PARSE_EOF, };
/**
* fat_parse_long - Parse extended directory entry.
*
* @dir: Pointer to the inode that represents the directory.
* @pos: On input, contains the starting position to read from.
* On output, updated with the new position.
* @bh: Pointer to the buffer head that may be used for reading directory
* entries. May be updated.
* @de: On input, points to the current directory entry.
* On output, points to the next directory entry.
* @unicode: Pointer to a buffer where the parsed Unicode long filename will be
* stored.
* @nr_slots: Pointer to a variable that will store the number of longname
* slots found.
*
* This function returns zero on success, negative value on error, or one of
* the following:
*
Expand Down
23 changes: 16 additions & 7 deletions fs/nilfs2/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1857,13 +1857,22 @@ nilfs_btree_commit_convert_and_insert(struct nilfs_bmap *btree,
}

/**
* nilfs_btree_convert_and_insert -
* @bmap:
* @key:
* @ptr:
* @keys:
* @ptrs:
* @n:
* nilfs_btree_convert_and_insert - Convert and insert entries into a B-tree
* @btree: NILFS B-tree structure
* @key: Key of the new entry to be inserted
* @ptr: Pointer (block number) associated with the key to be inserted
* @keys: Array of keys to be inserted in addition to @key
* @ptrs: Array of pointers associated with @keys
* @n: Number of keys and pointers in @keys and @ptrs
*
* This function is used to insert a new entry specified by @key and @ptr,
* along with additional entries specified by @keys and @ptrs arrays, into a
* NILFS B-tree.
* It prepares the necessary changes by allocating the required blocks and any
* necessary intermediate nodes. It converts configurations from other forms of
* block mapping (the one that currently exists is direct mapping) to a B-tree.
*
* Return: 0 on success or a negative error code on failure.
*/
int nilfs_btree_convert_and_insert(struct nilfs_bmap *btree,
__u64 key, __u64 ptr,
Expand Down
1 change: 0 additions & 1 deletion fs/nilfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ static bool nilfs_check_folio(struct folio *folio, char *kaddr)
dir->i_ino, (folio->index << PAGE_SHIFT) + offs,
(unsigned long)le64_to_cpu(p->inode));
fail:
folio_set_error(folio);
return false;
}

Expand Down
1 change: 1 addition & 0 deletions fs/nilfs2/gcinode.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ int nilfs_init_gcinode(struct inode *inode)

/**
* nilfs_remove_all_gcinodes() - remove all unprocessed gc inodes
* @nilfs: NILFS filesystem instance
*/
void nilfs_remove_all_gcinodes(struct the_nilfs *nilfs)
{
Expand Down
4 changes: 2 additions & 2 deletions fs/nilfs2/nilfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ void __nilfs_error(struct super_block *sb, const char *function,

extern struct nilfs_super_block *
nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **);
extern int nilfs_store_magic_and_option(struct super_block *,
struct nilfs_super_block *, char *);
extern int nilfs_store_magic(struct super_block *sb,
struct nilfs_super_block *sbp);
extern int nilfs_check_feature_compatibility(struct super_block *,
struct nilfs_super_block *);
extern void nilfs_set_log_cursor(struct nilfs_super_block *,
Expand Down
5 changes: 4 additions & 1 deletion fs/nilfs2/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs,
* checkpoint
* @nilfs: nilfs object
* @sb: super block instance
* @root: NILFS root instance
* @ri: pointer to a nilfs_recovery_info
*/
static int nilfs_do_roll_forward(struct the_nilfs *nilfs,
Expand Down Expand Up @@ -698,7 +699,9 @@ static void nilfs_finish_roll_forward(struct the_nilfs *nilfs,
return;

bh = __getblk(nilfs->ns_bdev, ri->ri_lsegs_start, nilfs->ns_blocksize);
BUG_ON(!bh);
if (WARN_ON(!bh))
return; /* should never happen */

memset(bh->b_data, 0, bh->b_size);
set_buffer_dirty(bh);
err = sync_dirty_buffer(bh);
Expand Down
8 changes: 1 addition & 7 deletions fs/nilfs2/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -1725,14 +1725,8 @@ static void nilfs_end_folio_io(struct folio *folio, int err)
return;
}

if (!err) {
if (!nilfs_folio_buffers_clean(folio))
filemap_dirty_folio(folio->mapping, folio);
folio_clear_error(folio);
} else {
if (err || !nilfs_folio_buffers_clean(folio))
filemap_dirty_folio(folio->mapping, folio);
folio_set_error(folio);
}

folio_end_writeback(folio);
}
Expand Down
Loading

0 comments on commit eb6a933

Please sign in to comment.