Skip to content

Commit 7aaa713

Browse files
committed
sched: change wake_up_bit() and related function to expect unsigned long *
JIRA: https://issues.redhat.com/browse/RHEL-117497 commit 2382d68 Author: NeilBrown <neilb@suse.de> Date: Wed Sep 25 15:31:38 2024 +1000 sched: change wake_up_bit() and related function to expect unsigned long * wake_up_bit() currently allows a "void *". While this isn't strictly a problem as the address is never dereferenced, it is inconsistent with the corresponding wait_on_bit() which requires "unsigned long *" and does dereference the pointer. Any code that needs to wait for a change in something other than an unsigned long would be better served by wake_up_var()/wait_var_event(). This patch changes all related "void *" to "unsigned long *". Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lore.kernel.org/r/20240925053405.3960701-2-neilb@suse.de Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
1 parent 1295404 commit 7aaa713

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

include/linux/wait_bit.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <linux/wait.h>
99

1010
struct wait_bit_key {
11-
void *flags;
11+
unsigned long *flags;
1212
int bit_nr;
1313
unsigned long timeout;
1414
};
@@ -23,14 +23,14 @@ struct wait_bit_queue_entry {
2323

2424
typedef int wait_bit_action_f(struct wait_bit_key *key, int mode);
2525

26-
void __wake_up_bit(struct wait_queue_head *wq_head, void *word, int bit);
26+
void __wake_up_bit(struct wait_queue_head *wq_head, unsigned long *word, int bit);
2727
int __wait_on_bit(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_entry, wait_bit_action_f *action, unsigned int mode);
2828
int __wait_on_bit_lock(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_entry, wait_bit_action_f *action, unsigned int mode);
29-
void wake_up_bit(void *word, int bit);
30-
int out_of_line_wait_on_bit(void *word, int, wait_bit_action_f *action, unsigned int mode);
31-
int out_of_line_wait_on_bit_timeout(void *word, int, wait_bit_action_f *action, unsigned int mode, unsigned long timeout);
32-
int out_of_line_wait_on_bit_lock(void *word, int, wait_bit_action_f *action, unsigned int mode);
33-
struct wait_queue_head *bit_waitqueue(void *word, int bit);
29+
void wake_up_bit(unsigned long *word, int bit);
30+
int out_of_line_wait_on_bit(unsigned long *word, int, wait_bit_action_f *action, unsigned int mode);
31+
int out_of_line_wait_on_bit_timeout(unsigned long *word, int, wait_bit_action_f *action, unsigned int mode, unsigned long timeout);
32+
int out_of_line_wait_on_bit_lock(unsigned long *word, int, wait_bit_action_f *action, unsigned int mode);
33+
struct wait_queue_head *bit_waitqueue(unsigned long *word, int bit);
3434
extern void __init wait_bit_init(void);
3535

3636
int wake_bit_function(struct wait_queue_entry *wq_entry, unsigned mode, int sync, void *key);
@@ -326,7 +326,7 @@ do { \
326326
* You can use this helper if bitflags are manipulated atomically rather than
327327
* non-atomically under a lock.
328328
*/
329-
static inline void clear_and_wake_up_bit(int bit, void *word)
329+
static inline void clear_and_wake_up_bit(int bit, unsigned long *word)
330330
{
331331
clear_bit_unlock(bit, word);
332332
/* See wake_up_bit() for which memory barrier you need to use. */

kernel/sched/wait_bit.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
static wait_queue_head_t bit_wait_table[WAIT_TABLE_SIZE] __cacheline_aligned;
1111

12-
wait_queue_head_t *bit_waitqueue(void *word, int bit)
12+
wait_queue_head_t *bit_waitqueue(unsigned long *word, int bit)
1313
{
1414
const int shift = BITS_PER_LONG == 32 ? 5 : 6;
1515
unsigned long val = (unsigned long)word << shift | bit;
@@ -55,7 +55,7 @@ __wait_on_bit(struct wait_queue_head *wq_head, struct wait_bit_queue_entry *wbq_
5555
}
5656
EXPORT_SYMBOL(__wait_on_bit);
5757

58-
int __sched out_of_line_wait_on_bit(void *word, int bit,
58+
int __sched out_of_line_wait_on_bit(unsigned long *word, int bit,
5959
wait_bit_action_f *action, unsigned mode)
6060
{
6161
struct wait_queue_head *wq_head = bit_waitqueue(word, bit);
@@ -66,7 +66,7 @@ int __sched out_of_line_wait_on_bit(void *word, int bit,
6666
EXPORT_SYMBOL(out_of_line_wait_on_bit);
6767

6868
int __sched out_of_line_wait_on_bit_timeout(
69-
void *word, int bit, wait_bit_action_f *action,
69+
unsigned long *word, int bit, wait_bit_action_f *action,
7070
unsigned mode, unsigned long timeout)
7171
{
7272
struct wait_queue_head *wq_head = bit_waitqueue(word, bit);
@@ -108,7 +108,7 @@ __wait_on_bit_lock(struct wait_queue_head *wq_head, struct wait_bit_queue_entry
108108
}
109109
EXPORT_SYMBOL(__wait_on_bit_lock);
110110

111-
int __sched out_of_line_wait_on_bit_lock(void *word, int bit,
111+
int __sched out_of_line_wait_on_bit_lock(unsigned long *word, int bit,
112112
wait_bit_action_f *action, unsigned mode)
113113
{
114114
struct wait_queue_head *wq_head = bit_waitqueue(word, bit);
@@ -118,7 +118,7 @@ int __sched out_of_line_wait_on_bit_lock(void *word, int bit,
118118
}
119119
EXPORT_SYMBOL(out_of_line_wait_on_bit_lock);
120120

121-
void __wake_up_bit(struct wait_queue_head *wq_head, void *word, int bit)
121+
void __wake_up_bit(struct wait_queue_head *wq_head, unsigned long *word, int bit)
122122
{
123123
struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(word, bit);
124124

@@ -144,7 +144,7 @@ EXPORT_SYMBOL(__wake_up_bit);
144144
* may need to use a less regular barrier, such fs/inode.c's smp_mb(),
145145
* because spin_unlock() does not guarantee a memory barrier.
146146
*/
147-
void wake_up_bit(void *word, int bit)
147+
void wake_up_bit(unsigned long *word, int bit)
148148
{
149149
__wake_up_bit(bit_waitqueue(word, bit), word, bit);
150150
}

0 commit comments

Comments
 (0)