Skip to content

Commit 37acade

Browse files
Matthew Wilcox (Oracle)akpm00
authored andcommitted
sched: remove wait bookmarks
There are no users of wait bookmarks left, so simplify the wait code by removing them. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Acked-by: Ingo Molnar <[email protected]> Cc: Benjamin Segall <[email protected]> Cc: Bin Lai <[email protected]> Cc: Daniel Bristot de Oliveira <[email protected]> Cc: Dietmar Eggemann <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Juri Lelli <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt (Google) <[email protected]> Cc: Valentin Schneider <[email protected]> Cc: Vincent Guittot <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b0b598e commit 37acade

File tree

2 files changed

+13
-56
lines changed

2 files changed

+13
-56
lines changed

include/linux/wait.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ int default_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, int
1919
/* wait_queue_entry::flags */
2020
#define WQ_FLAG_EXCLUSIVE 0x01
2121
#define WQ_FLAG_WOKEN 0x02
22-
#define WQ_FLAG_BOOKMARK 0x04
23-
#define WQ_FLAG_CUSTOM 0x08
24-
#define WQ_FLAG_DONE 0x10
25-
#define WQ_FLAG_PRIORITY 0x20
22+
#define WQ_FLAG_CUSTOM 0x04
23+
#define WQ_FLAG_DONE 0x08
24+
#define WQ_FLAG_PRIORITY 0x10
2625

2726
/*
2827
* A single wait-queue entry structure:
@@ -212,8 +211,6 @@ __remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry *wq
212211
int __wake_up(struct wait_queue_head *wq_head, unsigned int mode, int nr, void *key);
213212
void __wake_up_on_current_cpu(struct wait_queue_head *wq_head, unsigned int mode, void *key);
214213
void __wake_up_locked_key(struct wait_queue_head *wq_head, unsigned int mode, void *key);
215-
void __wake_up_locked_key_bookmark(struct wait_queue_head *wq_head,
216-
unsigned int mode, void *key, wait_queue_entry_t *bookmark);
217214
void __wake_up_sync_key(struct wait_queue_head *wq_head, unsigned int mode, void *key);
218215
void __wake_up_locked_sync_key(struct wait_queue_head *wq_head, unsigned int mode, void *key);
219216
void __wake_up_locked(struct wait_queue_head *wq_head, unsigned int mode, int nr);

kernel/sched/wait.c

Lines changed: 10 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ void remove_wait_queue(struct wait_queue_head *wq_head, struct wait_queue_entry
5757
}
5858
EXPORT_SYMBOL(remove_wait_queue);
5959

60-
/*
61-
* Scan threshold to break wait queue walk.
62-
* This allows a waker to take a break from holding the
63-
* wait queue lock during the wait queue walk.
64-
*/
65-
#define WAITQUEUE_WALK_BREAK_CNT 64
66-
6760
/*
6861
* The core wakeup function. Non-exclusive wakeups (nr_exclusive == 0) just
6962
* wake everything up. If it's an exclusive wakeup (nr_exclusive == small +ve
@@ -78,21 +71,13 @@ EXPORT_SYMBOL(remove_wait_queue);
7871
* zero in this (rare) case, and we handle it by continuing to scan the queue.
7972
*/
8073
static int __wake_up_common(struct wait_queue_head *wq_head, unsigned int mode,
81-
int nr_exclusive, int wake_flags, void *key,
82-
wait_queue_entry_t *bookmark)
74+
int nr_exclusive, int wake_flags, void *key)
8375
{
8476
wait_queue_entry_t *curr, *next;
85-
int cnt = 0;
8677

8778
lockdep_assert_held(&wq_head->lock);
8879

89-
if (bookmark && (bookmark->flags & WQ_FLAG_BOOKMARK)) {
90-
curr = list_next_entry(bookmark, entry);
91-
92-
list_del(&bookmark->entry);
93-
bookmark->flags = 0;
94-
} else
95-
curr = list_first_entry(&wq_head->head, wait_queue_entry_t, entry);
80+
curr = list_first_entry(&wq_head->head, wait_queue_entry_t, entry);
9681

9782
if (&curr->entry == &wq_head->head)
9883
return nr_exclusive;
@@ -101,21 +86,11 @@ static int __wake_up_common(struct wait_queue_head *wq_head, unsigned int mode,
10186
unsigned flags = curr->flags;
10287
int ret;
10388

104-
if (flags & WQ_FLAG_BOOKMARK)
105-
continue;
106-
10789
ret = curr->func(curr, mode, wake_flags, key);
10890
if (ret < 0)
10991
break;
11092
if (ret && (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive)
11193
break;
112-
113-
if (bookmark && (++cnt > WAITQUEUE_WALK_BREAK_CNT) &&
114-
(&next->entry != &wq_head->head)) {
115-
bookmark->flags = WQ_FLAG_BOOKMARK;
116-
list_add_tail(&bookmark->entry, &next->entry);
117-
break;
118-
}
11994
}
12095

12196
return nr_exclusive;
@@ -125,20 +100,12 @@ static int __wake_up_common_lock(struct wait_queue_head *wq_head, unsigned int m
125100
int nr_exclusive, int wake_flags, void *key)
126101
{
127102
unsigned long flags;
128-
wait_queue_entry_t bookmark;
129-
int remaining = nr_exclusive;
103+
int remaining;
130104

131-
bookmark.flags = 0;
132-
bookmark.private = NULL;
133-
bookmark.func = NULL;
134-
INIT_LIST_HEAD(&bookmark.entry);
135-
136-
do {
137-
spin_lock_irqsave(&wq_head->lock, flags);
138-
remaining = __wake_up_common(wq_head, mode, remaining,
139-
wake_flags, key, &bookmark);
140-
spin_unlock_irqrestore(&wq_head->lock, flags);
141-
} while (bookmark.flags & WQ_FLAG_BOOKMARK);
105+
spin_lock_irqsave(&wq_head->lock, flags);
106+
remaining = __wake_up_common(wq_head, mode, nr_exclusive, wake_flags,
107+
key);
108+
spin_unlock_irqrestore(&wq_head->lock, flags);
142109

143110
return nr_exclusive - remaining;
144111
}
@@ -171,23 +138,16 @@ void __wake_up_on_current_cpu(struct wait_queue_head *wq_head, unsigned int mode
171138
*/
172139
void __wake_up_locked(struct wait_queue_head *wq_head, unsigned int mode, int nr)
173140
{
174-
__wake_up_common(wq_head, mode, nr, 0, NULL, NULL);
141+
__wake_up_common(wq_head, mode, nr, 0, NULL);
175142
}
176143
EXPORT_SYMBOL_GPL(__wake_up_locked);
177144

178145
void __wake_up_locked_key(struct wait_queue_head *wq_head, unsigned int mode, void *key)
179146
{
180-
__wake_up_common(wq_head, mode, 1, 0, key, NULL);
147+
__wake_up_common(wq_head, mode, 1, 0, key);
181148
}
182149
EXPORT_SYMBOL_GPL(__wake_up_locked_key);
183150

184-
void __wake_up_locked_key_bookmark(struct wait_queue_head *wq_head,
185-
unsigned int mode, void *key, wait_queue_entry_t *bookmark)
186-
{
187-
__wake_up_common(wq_head, mode, 1, 0, key, bookmark);
188-
}
189-
EXPORT_SYMBOL_GPL(__wake_up_locked_key_bookmark);
190-
191151
/**
192152
* __wake_up_sync_key - wake up threads blocked on a waitqueue.
193153
* @wq_head: the waitqueue
@@ -233,7 +193,7 @@ EXPORT_SYMBOL_GPL(__wake_up_sync_key);
233193
void __wake_up_locked_sync_key(struct wait_queue_head *wq_head,
234194
unsigned int mode, void *key)
235195
{
236-
__wake_up_common(wq_head, mode, 1, WF_SYNC, key, NULL);
196+
__wake_up_common(wq_head, mode, 1, WF_SYNC, key);
237197
}
238198
EXPORT_SYMBOL_GPL(__wake_up_locked_sync_key);
239199

0 commit comments

Comments
 (0)