Skip to content

Commit 5e4def2

Browse files
committed
Pass mode to wait_on_atomic_t() action funcs and provide default actions
Make wait_on_atomic_t() pass the TASK_* mode onto its action function as an extra argument and make it 'unsigned int throughout. Also, consolidate a bunch of identical action functions into a default function that can do the appropriate thing for the mode. Also, change the argument name in the bit_wait*() function declarations to reflect the fact that it's the mode and not the bit number. [Peter Z gives this a grudging ACK, but thinks that the whole atomic_t wait should be done differently, though he's not immediately sure as to how] Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Peter Zijlstra <peterz@infradead.org> cc: Ingo Molnar <mingo@kernel.org>
1 parent 81445e6 commit 5e4def2

14 files changed

Lines changed: 37 additions & 98 deletions

File tree

‎arch/mips/kernel/traps.c‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,18 +1233,6 @@ static int default_cu2_call(struct notifier_block *nfb, unsigned long action,
12331233
return NOTIFY_OK;
12341234
}
12351235

1236-
static int wait_on_fp_mode_switch(atomic_t *p)
1237-
{
1238-
/*
1239-
* The FP mode for this task is currently being switched. That may
1240-
* involve modifications to the format of this tasks FP context which
1241-
* make it unsafe to proceed with execution for the moment. Instead,
1242-
* schedule some other task.
1243-
*/
1244-
schedule();
1245-
return 0;
1246-
}
1247-
12481236
static int enable_restore_fp_context(int msa)
12491237
{
12501238
int err, was_fpu_owner, prior_msa;
@@ -1254,7 +1242,7 @@ static int enable_restore_fp_context(int msa)
12541242
* complete before proceeding.
12551243
*/
12561244
wait_on_atomic_t(&current->mm->context.fp_mode_switching,
1257-
wait_on_fp_mode_switch, TASK_KILLABLE);
1245+
atomic_t_wait, TASK_KILLABLE);
12581246

12591247
if (!used_math()) {
12601248
/* First time FP context user. */

‎drivers/gpu/drm/drm_dp_aux_dev.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,6 @@ static struct drm_dp_aux_dev *drm_dp_aux_dev_get_by_aux(struct drm_dp_aux *aux)
263263
return aux_dev;
264264
}
265265

266-
static int auxdev_wait_atomic_t(atomic_t *p)
267-
{
268-
schedule();
269-
return 0;
270-
}
271-
272266
void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux)
273267
{
274268
struct drm_dp_aux_dev *aux_dev;
@@ -283,7 +277,7 @@ void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux)
283277
mutex_unlock(&aux_idr_mutex);
284278

285279
atomic_dec(&aux_dev->usecount);
286-
wait_on_atomic_t(&aux_dev->usecount, auxdev_wait_atomic_t,
280+
wait_on_atomic_t(&aux_dev->usecount, atomic_t_wait,
287281
TASK_UNINTERRUPTIBLE);
288282

289283
minor = aux_dev->index;

‎drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,7 @@ struct igt_wakeup {
271271
u32 seqno;
272272
};
273273

274-
static int wait_atomic(atomic_t *p)
275-
{
276-
schedule();
277-
return 0;
278-
}
279-
280-
static int wait_atomic_timeout(atomic_t *p)
274+
static int wait_atomic_timeout(atomic_t *p, unsigned int mode)
281275
{
282276
return schedule_timeout(10 * HZ) ? 0 : -ETIMEDOUT;
283277
}
@@ -348,7 +342,7 @@ static void igt_wake_all_sync(atomic_t *ready,
348342
atomic_set(ready, 0);
349343
wake_up_all(wq);
350344

351-
wait_on_atomic_t(set, wait_atomic, TASK_UNINTERRUPTIBLE);
345+
wait_on_atomic_t(set, atomic_t_wait, TASK_UNINTERRUPTIBLE);
352346
atomic_set(ready, count);
353347
atomic_set(done, count);
354348
}

‎drivers/media/platform/qcom/venus/hfi.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,6 @@ int hfi_core_init(struct venus_core *core)
8888
return ret;
8989
}
9090

91-
static int core_deinit_wait_atomic_t(atomic_t *p)
92-
{
93-
schedule();
94-
return 0;
95-
}
96-
9791
int hfi_core_deinit(struct venus_core *core, bool blocking)
9892
{
9993
int ret = 0, empty;
@@ -112,7 +106,7 @@ int hfi_core_deinit(struct venus_core *core, bool blocking)
112106

113107
if (!empty) {
114108
mutex_unlock(&core->lock);
115-
wait_on_atomic_t(&core->insts_count, core_deinit_wait_atomic_t,
109+
wait_on_atomic_t(&core->insts_count, atomic_t_wait,
116110
TASK_UNINTERRUPTIBLE);
117111
mutex_lock(&core->lock);
118112
}

‎fs/afs/rxrpc.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ static void afs_charge_preallocation(struct work_struct *);
4141

4242
static DECLARE_WORK(afs_charge_preallocation_work, afs_charge_preallocation);
4343

44-
static int afs_wait_atomic_t(atomic_t *p)
45-
{
46-
schedule();
47-
return 0;
48-
}
49-
5044
/*
5145
* open an RxRPC socket and bind it to be a server for callback notifications
5246
* - the socket is left in blocking mode and non-blocking ops use MSG_DONTWAIT
@@ -121,7 +115,7 @@ void afs_close_socket(void)
121115
}
122116

123117
_debug("outstanding %u", atomic_read(&afs_outstanding_calls));
124-
wait_on_atomic_t(&afs_outstanding_calls, afs_wait_atomic_t,
118+
wait_on_atomic_t(&afs_outstanding_calls, atomic_t_wait,
125119
TASK_UNINTERRUPTIBLE);
126120
_debug("no outstanding calls");
127121

‎fs/btrfs/extent-tree.c‎

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4016,16 +4016,9 @@ void btrfs_dec_nocow_writers(struct btrfs_fs_info *fs_info, u64 bytenr)
40164016
btrfs_put_block_group(bg);
40174017
}
40184018

4019-
static int btrfs_wait_nocow_writers_atomic_t(atomic_t *a)
4020-
{
4021-
schedule();
4022-
return 0;
4023-
}
4024-
40254019
void btrfs_wait_nocow_writers(struct btrfs_block_group_cache *bg)
40264020
{
4027-
wait_on_atomic_t(&bg->nocow_writers,
4028-
btrfs_wait_nocow_writers_atomic_t,
4021+
wait_on_atomic_t(&bg->nocow_writers, atomic_t_wait,
40294022
TASK_UNINTERRUPTIBLE);
40304023
}
40314024

@@ -6595,12 +6588,6 @@ void btrfs_dec_block_group_reservations(struct btrfs_fs_info *fs_info,
65956588
btrfs_put_block_group(bg);
65966589
}
65976590

6598-
static int btrfs_wait_bg_reservations_atomic_t(atomic_t *a)
6599-
{
6600-
schedule();
6601-
return 0;
6602-
}
6603-
66046591
void btrfs_wait_block_group_reservations(struct btrfs_block_group_cache *bg)
66056592
{
66066593
struct btrfs_space_info *space_info = bg->space_info;
@@ -6623,8 +6610,7 @@ void btrfs_wait_block_group_reservations(struct btrfs_block_group_cache *bg)
66236610
down_write(&space_info->groups_sem);
66246611
up_write(&space_info->groups_sem);
66256612

6626-
wait_on_atomic_t(&bg->reservations,
6627-
btrfs_wait_bg_reservations_atomic_t,
6613+
wait_on_atomic_t(&bg->reservations, atomic_t_wait,
66286614
TASK_UNINTERRUPTIBLE);
66296615
}
66306616

@@ -11106,12 +11092,6 @@ int btrfs_start_write_no_snapshotting(struct btrfs_root *root)
1110611092
return 1;
1110711093
}
1110811094

11109-
static int wait_snapshotting_atomic_t(atomic_t *a)
11110-
{
11111-
schedule();
11112-
return 0;
11113-
}
11114-
1111511095
void btrfs_wait_for_snapshot_creation(struct btrfs_root *root)
1111611096
{
1111711097
while (true) {
@@ -11120,8 +11100,7 @@ void btrfs_wait_for_snapshot_creation(struct btrfs_root *root)
1112011100
ret = btrfs_start_write_no_snapshotting(root);
1112111101
if (ret)
1112211102
break;
11123-
wait_on_atomic_t(&root->will_be_snapshotted,
11124-
wait_snapshotting_atomic_t,
11103+
wait_on_atomic_t(&root->will_be_snapshotted, atomic_t_wait,
1112511104
TASK_UNINTERRUPTIBLE);
1112611105
}
1112711106
}

‎fs/fscache/cookie.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ void __fscache_disable_cookie(struct fscache_cookie *cookie, bool invalidate)
558558
* have completed.
559559
*/
560560
if (!atomic_dec_and_test(&cookie->n_active))
561-
wait_on_atomic_t(&cookie->n_active, fscache_wait_atomic_t,
561+
wait_on_atomic_t(&cookie->n_active, atomic_t_wait,
562562
TASK_UNINTERRUPTIBLE);
563563

564564
/* Make sure any pending writes are cancelled. */

‎fs/fscache/internal.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ static inline bool fscache_object_congested(void)
9797
return workqueue_congested(WORK_CPU_UNBOUND, fscache_object_wq);
9898
}
9999

100-
extern int fscache_wait_atomic_t(atomic_t *);
101-
102100
/*
103101
* object.c
104102
*/

‎fs/fscache/main.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,3 @@ static void __exit fscache_exit(void)
195195
}
196196

197197
module_exit(fscache_exit);
198-
199-
/*
200-
* wait_on_atomic_t() sleep function for uninterruptible waiting
201-
*/
202-
int fscache_wait_atomic_t(atomic_t *p)
203-
{
204-
schedule();
205-
return 0;
206-
}

‎fs/nfs/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ int nfs_wait_bit_killable(struct wait_bit_key *key, int mode)
8585
}
8686
EXPORT_SYMBOL_GPL(nfs_wait_bit_killable);
8787

88-
int nfs_wait_atomic_killable(atomic_t *p)
88+
int nfs_wait_atomic_killable(atomic_t *p, unsigned int mode)
8989
{
90-
return nfs_wait_killable(TASK_KILLABLE);
90+
return nfs_wait_killable(mode);
9191
}
9292

9393
/**

0 commit comments

Comments
 (0)