Skip to content

Commit 6bacf66

Browse files
committed
Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fixes from Ingo Molnar: "Two fixes: tighten up a jump-labels warning to not trigger on certain modules and fix confusing (and non-existent) mutex API documentation" * 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: jump_label: Disable jump labels in __exit code locking/mutex: Improve documentation
2 parents f1869a8 + 578ae44 commit 6bacf66

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

include/linux/jump_label.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ extern struct jump_entry __start___jump_table[];
151151
extern struct jump_entry __stop___jump_table[];
152152

153153
extern void jump_label_init(void);
154-
extern void jump_label_invalidate_init(void);
154+
extern void jump_label_invalidate_initmem(void);
155155
extern void jump_label_lock(void);
156156
extern void jump_label_unlock(void);
157157
extern void arch_jump_label_transform(struct jump_entry *entry,
@@ -199,7 +199,7 @@ static __always_inline void jump_label_init(void)
199199
static_key_initialized = true;
200200
}
201201

202-
static inline void jump_label_invalidate_init(void) {}
202+
static inline void jump_label_invalidate_initmem(void) {}
203203

204204
static __always_inline bool static_key_false(struct static_key *key)
205205
{

init/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ static int __ref kernel_init(void *unused)
10011001
/* need to finish all async __init code before freeing the memory */
10021002
async_synchronize_full();
10031003
ftrace_free_init_mem();
1004-
jump_label_invalidate_init();
1004+
jump_label_invalidate_initmem();
10051005
free_initmem();
10061006
mark_readonly();
10071007
system_state = SYSTEM_RUNNING;

kernel/jump_label.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/jump_label_ratelimit.h>
1717
#include <linux/bug.h>
1818
#include <linux/cpu.h>
19+
#include <asm/sections.h>
1920

2021
#ifdef HAVE_JUMP_LABEL
2122

@@ -421,15 +422,15 @@ void __init jump_label_init(void)
421422
cpus_read_unlock();
422423
}
423424

424-
/* Disable any jump label entries in __init code */
425-
void __init jump_label_invalidate_init(void)
425+
/* Disable any jump label entries in __init/__exit code */
426+
void __init jump_label_invalidate_initmem(void)
426427
{
427428
struct jump_entry *iter_start = __start___jump_table;
428429
struct jump_entry *iter_stop = __stop___jump_table;
429430
struct jump_entry *iter;
430431

431432
for (iter = iter_start; iter < iter_stop; iter++) {
432-
if (init_kernel_text(iter->code))
433+
if (init_section_contains((void *)(unsigned long)iter->code, 1))
433434
iter->code = 0;
434435
}
435436
}

kernel/locking/mutex.c

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,15 +1082,16 @@ static noinline int __sched
10821082
__mutex_lock_interruptible_slowpath(struct mutex *lock);
10831083

10841084
/**
1085-
* mutex_lock_interruptible - acquire the mutex, interruptible
1086-
* @lock: the mutex to be acquired
1085+
* mutex_lock_interruptible() - Acquire the mutex, interruptible by signals.
1086+
* @lock: The mutex to be acquired.
10871087
*
1088-
* Lock the mutex like mutex_lock(), and return 0 if the mutex has
1089-
* been acquired or sleep until the mutex becomes available. If a
1090-
* signal arrives while waiting for the lock then this function
1091-
* returns -EINTR.
1088+
* Lock the mutex like mutex_lock(). If a signal is delivered while the
1089+
* process is sleeping, this function will return without acquiring the
1090+
* mutex.
10921091
*
1093-
* This function is similar to (but not equivalent to) down_interruptible().
1092+
* Context: Process context.
1093+
* Return: 0 if the lock was successfully acquired or %-EINTR if a
1094+
* signal arrived.
10941095
*/
10951096
int __sched mutex_lock_interruptible(struct mutex *lock)
10961097
{
@@ -1104,6 +1105,18 @@ int __sched mutex_lock_interruptible(struct mutex *lock)
11041105

11051106
EXPORT_SYMBOL(mutex_lock_interruptible);
11061107

1108+
/**
1109+
* mutex_lock_killable() - Acquire the mutex, interruptible by fatal signals.
1110+
* @lock: The mutex to be acquired.
1111+
*
1112+
* Lock the mutex like mutex_lock(). If a signal which will be fatal to
1113+
* the current process is delivered while the process is sleeping, this
1114+
* function will return without acquiring the mutex.
1115+
*
1116+
* Context: Process context.
1117+
* Return: 0 if the lock was successfully acquired or %-EINTR if a
1118+
* fatal signal arrived.
1119+
*/
11071120
int __sched mutex_lock_killable(struct mutex *lock)
11081121
{
11091122
might_sleep();
@@ -1115,6 +1128,16 @@ int __sched mutex_lock_killable(struct mutex *lock)
11151128
}
11161129
EXPORT_SYMBOL(mutex_lock_killable);
11171130

1131+
/**
1132+
* mutex_lock_io() - Acquire the mutex and mark the process as waiting for I/O
1133+
* @lock: The mutex to be acquired.
1134+
*
1135+
* Lock the mutex like mutex_lock(). While the task is waiting for this
1136+
* mutex, it will be accounted as being in the IO wait state by the
1137+
* scheduler.
1138+
*
1139+
* Context: Process context.
1140+
*/
11181141
void __sched mutex_lock_io(struct mutex *lock)
11191142
{
11201143
int token;

0 commit comments

Comments
 (0)