Skip to content

Commit 30c9999

Browse files
committed
Merge tag 'sched-core-2022-10-07' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler updates from Ingo Molnar: "Debuggability: - Change most occurances of BUG_ON() to WARN_ON_ONCE() - Reorganize & fix TASK_ state comparisons, turn it into a bitmap - Update/fix misc scheduler debugging facilities Load-balancing & regular scheduling: - Improve the behavior of the scheduler in presence of lot of SCHED_IDLE tasks - in particular they should not impact other scheduling classes. - Optimize task load tracking, cleanups & fixes - Clean up & simplify misc load-balancing code Freezer: - Rewrite the core freezer to behave better wrt thawing and be simpler in general, by replacing PF_FROZEN with TASK_FROZEN & fixing/adjusting all the fallout. Deadline scheduler: - Fix the DL capacity-aware code - Factor out dl_task_is_earliest_deadline() & replenish_dl_new_period() - Relax/optimize locking in task_non_contending() Cleanups: - Factor out the update_current_exec_runtime() helper - Various cleanups, simplifications" * tag 'sched-core-2022-10-07' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (41 commits) sched: Fix more TASK_state comparisons sched: Fix TASK_state comparisons sched/fair: Move call to list_last_entry() in detach_tasks sched/fair: Cleanup loop_max and loop_break sched/fair: Make sure to try to detach at least one movable task sched: Show PF_flag holes freezer,sched: Rewrite core freezer logic sched: Widen TAKS_state literals sched/wait: Add wait_event_state() sched/completion: Add wait_for_completion_state() sched: Add TASK_ANY for wait_task_inactive() sched: Change wait_task_inactive()s match_state freezer,umh: Clean up freezer/initrd interaction freezer: Have {,un}lock_system_sleep() save/restore flags sched: Rename task_running() to task_on_cpu() sched/fair: Cleanup for SIS_PROP sched/fair: Default to false in test_idle_cores() sched/fair: Remove useless check in select_idle_core() sched/fair: Avoid double search on same cpu sched/fair: Remove redundant check in select_idle_smt() ...
2 parents 493ffd6 + fdf756f commit 30c9999

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+616
-760
lines changed

drivers/acpi/x86/s2idle.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -654,25 +654,29 @@ void __init acpi_s2idle_setup(void)
654654

655655
int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg)
656656
{
657+
unsigned int sleep_flags;
658+
657659
if (!lps0_device_handle || sleep_no_lps0)
658660
return -ENODEV;
659661

660-
lock_system_sleep();
662+
sleep_flags = lock_system_sleep();
661663
list_add(&arg->list_node, &lps0_s2idle_devops_head);
662-
unlock_system_sleep();
664+
unlock_system_sleep(sleep_flags);
663665

664666
return 0;
665667
}
666668
EXPORT_SYMBOL_GPL(acpi_register_lps0_dev);
667669

668670
void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg)
669671
{
672+
unsigned int sleep_flags;
673+
670674
if (!lps0_device_handle || sleep_no_lps0)
671675
return;
672676

673-
lock_system_sleep();
677+
sleep_flags = lock_system_sleep();
674678
list_del(&arg->list_node);
675-
unlock_system_sleep();
679+
unlock_system_sleep(sleep_flags);
676680
}
677681
EXPORT_SYMBOL_GPL(acpi_unregister_lps0_dev);
678682

drivers/android/binder.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -4259,10 +4259,9 @@ static int binder_wait_for_work(struct binder_thread *thread,
42594259
struct binder_proc *proc = thread->proc;
42604260
int ret = 0;
42614261

4262-
freezer_do_not_count();
42634262
binder_inner_proc_lock(proc);
42644263
for (;;) {
4265-
prepare_to_wait(&thread->wait, &wait, TASK_INTERRUPTIBLE);
4264+
prepare_to_wait(&thread->wait, &wait, TASK_INTERRUPTIBLE|TASK_FREEZABLE);
42664265
if (binder_has_work_ilocked(thread, do_proc_work))
42674266
break;
42684267
if (do_proc_work)
@@ -4279,7 +4278,6 @@ static int binder_wait_for_work(struct binder_thread *thread,
42794278
}
42804279
finish_wait(&thread->wait, &wait);
42814280
binder_inner_proc_unlock(proc);
4282-
freezer_count();
42834281

42844282
return ret;
42854283
}

drivers/media/pci/pt3/pt3.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@ static int pt3_fetch_thread(void *data)
445445
pt3_proc_dma(adap);
446446

447447
delay = ktime_set(0, PT3_FETCH_DELAY * NSEC_PER_MSEC);
448-
set_current_state(TASK_UNINTERRUPTIBLE);
449-
freezable_schedule_hrtimeout_range(&delay,
448+
set_current_state(TASK_UNINTERRUPTIBLE|TASK_FREEZABLE);
449+
schedule_hrtimeout_range(&delay,
450450
PT3_FETCH_DELAY_DELTA * NSEC_PER_MSEC,
451451
HRTIMER_MODE_REL);
452452
}

drivers/powercap/idle_inject.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ void idle_inject_stop(struct idle_inject_device *ii_dev)
254254
iit = per_cpu_ptr(&idle_inject_thread, cpu);
255255
iit->should_run = 0;
256256

257-
wait_task_inactive(iit->tsk, 0);
257+
wait_task_inactive(iit->tsk, TASK_ANY);
258258
}
259259

260260
cpu_hotplug_enable();

drivers/scsi/scsi_transport_spi.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -998,16 +998,17 @@ void
998998
spi_dv_device(struct scsi_device *sdev)
999999
{
10001000
struct scsi_target *starget = sdev->sdev_target;
1001-
u8 *buffer;
10021001
const int len = SPI_MAX_ECHO_BUFFER_SIZE*2;
1002+
unsigned int sleep_flags;
1003+
u8 *buffer;
10031004

10041005
/*
10051006
* Because this function and the power management code both call
10061007
* scsi_device_quiesce(), it is not safe to perform domain validation
10071008
* while suspend or resume is in progress. Hence the
10081009
* lock/unlock_system_sleep() calls.
10091010
*/
1010-
lock_system_sleep();
1011+
sleep_flags = lock_system_sleep();
10111012

10121013
if (scsi_autopm_get_device(sdev))
10131014
goto unlock_system_sleep;
@@ -1058,7 +1059,7 @@ spi_dv_device(struct scsi_device *sdev)
10581059
scsi_autopm_put_device(sdev);
10591060

10601061
unlock_system_sleep:
1061-
unlock_system_sleep();
1062+
unlock_system_sleep(sleep_flags);
10621063
}
10631064
EXPORT_SYMBOL(spi_dv_device);
10641065

fs/cifs/inode.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ cifs_invalidate_mapping(struct inode *inode)
23272327
static int
23282328
cifs_wait_bit_killable(struct wait_bit_key *key, int mode)
23292329
{
2330-
freezable_schedule_unsafe();
2330+
schedule();
23312331
if (signal_pending_state(mode, current))
23322332
return -ERESTARTSYS;
23332333
return 0;
@@ -2345,7 +2345,7 @@ cifs_revalidate_mapping(struct inode *inode)
23452345
return 0;
23462346

23472347
rc = wait_on_bit_lock_action(flags, CIFS_INO_LOCK, cifs_wait_bit_killable,
2348-
TASK_KILLABLE);
2348+
TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
23492349
if (rc)
23502350
return rc;
23512351

fs/cifs/transport.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,9 @@ wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ)
753753
{
754754
int error;
755755

756-
error = wait_event_freezekillable_unsafe(server->response_q,
757-
midQ->mid_state != MID_REQUEST_SUBMITTED);
756+
error = wait_event_state(server->response_q,
757+
midQ->mid_state != MID_REQUEST_SUBMITTED,
758+
(TASK_KILLABLE|TASK_FREEZABLE_UNSAFE));
758759
if (error < 0)
759760
return -ERESTARTSYS;
760761

fs/coredump.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,16 @@ static int coredump_wait(int exit_code, struct core_state *core_state)
402402
if (core_waiters > 0) {
403403
struct core_thread *ptr;
404404

405-
freezer_do_not_count();
406-
wait_for_completion(&core_state->startup);
407-
freezer_count();
405+
wait_for_completion_state(&core_state->startup,
406+
TASK_UNINTERRUPTIBLE|TASK_FREEZABLE);
408407
/*
409408
* Wait for all the threads to become inactive, so that
410409
* all the thread context (extended register state, like
411410
* fpu etc) gets copied to the memory.
412411
*/
413412
ptr = core_state->dumper.next;
414413
while (ptr != NULL) {
415-
wait_task_inactive(ptr->task, 0);
414+
wait_task_inactive(ptr->task, TASK_ANY);
416415
ptr = ptr->next;
417416
}
418417
}

fs/nfs/file.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,8 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
567567
}
568568

569569
wait_on_bit_action(&NFS_I(inode)->flags, NFS_INO_INVALIDATING,
570-
nfs_wait_bit_killable, TASK_KILLABLE);
570+
nfs_wait_bit_killable,
571+
TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
571572

572573
lock_page(page);
573574
mapping = page_file_mapping(page);

fs/nfs/inode.c

+4-8
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,13 @@ nfs_fattr_to_ino_t(struct nfs_fattr *fattr)
7272
return nfs_fileid_to_ino_t(fattr->fileid);
7373
}
7474

75-
static int nfs_wait_killable(int mode)
75+
int nfs_wait_bit_killable(struct wait_bit_key *key, int mode)
7676
{
77-
freezable_schedule_unsafe();
77+
schedule();
7878
if (signal_pending_state(mode, current))
7979
return -ERESTARTSYS;
8080
return 0;
8181
}
82-
83-
int nfs_wait_bit_killable(struct wait_bit_key *key, int mode)
84-
{
85-
return nfs_wait_killable(mode);
86-
}
8782
EXPORT_SYMBOL_GPL(nfs_wait_bit_killable);
8883

8984
/**
@@ -1332,7 +1327,8 @@ int nfs_clear_invalid_mapping(struct address_space *mapping)
13321327
*/
13331328
for (;;) {
13341329
ret = wait_on_bit_action(bitlock, NFS_INO_INVALIDATING,
1335-
nfs_wait_bit_killable, TASK_KILLABLE);
1330+
nfs_wait_bit_killable,
1331+
TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
13361332
if (ret)
13371333
goto out;
13381334
spin_lock(&inode->i_lock);

fs/nfs/nfs3proc.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
3636
res = rpc_call_sync(clnt, msg, flags);
3737
if (res != -EJUKEBOX)
3838
break;
39-
freezable_schedule_timeout_killable_unsafe(NFS_JUKEBOX_RETRY_TIME);
39+
__set_current_state(TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
40+
schedule_timeout(NFS_JUKEBOX_RETRY_TIME);
4041
res = -ERESTARTSYS;
4142
} while (!fatal_signal_pending(current));
4243
return res;

fs/nfs/nfs4proc.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ static int nfs4_delay_killable(long *timeout)
416416
{
417417
might_sleep();
418418

419-
freezable_schedule_timeout_killable_unsafe(
420-
nfs4_update_delay(timeout));
419+
__set_current_state(TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
420+
schedule_timeout(nfs4_update_delay(timeout));
421421
if (!__fatal_signal_pending(current))
422422
return 0;
423423
return -EINTR;
@@ -427,7 +427,8 @@ static int nfs4_delay_interruptible(long *timeout)
427427
{
428428
might_sleep();
429429

430-
freezable_schedule_timeout_interruptible_unsafe(nfs4_update_delay(timeout));
430+
__set_current_state(TASK_INTERRUPTIBLE|TASK_FREEZABLE_UNSAFE);
431+
schedule_timeout(nfs4_update_delay(timeout));
431432
if (!signal_pending(current))
432433
return 0;
433434
return __fatal_signal_pending(current) ? -EINTR :-ERESTARTSYS;
@@ -7406,7 +7407,8 @@ nfs4_retry_setlk_simple(struct nfs4_state *state, int cmd,
74067407
status = nfs4_proc_setlk(state, cmd, request);
74077408
if ((status != -EAGAIN) || IS_SETLK(cmd))
74087409
break;
7409-
freezable_schedule_timeout_interruptible(timeout);
7410+
__set_current_state(TASK_INTERRUPTIBLE|TASK_FREEZABLE);
7411+
schedule_timeout(timeout);
74107412
timeout *= 2;
74117413
timeout = min_t(unsigned long, NFS4_LOCK_MAXTIMEOUT, timeout);
74127414
status = -ERESTARTSYS;
@@ -7474,10 +7476,8 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
74747476
break;
74757477

74767478
status = -ERESTARTSYS;
7477-
freezer_do_not_count();
7478-
wait_woken(&waiter.wait, TASK_INTERRUPTIBLE,
7479+
wait_woken(&waiter.wait, TASK_INTERRUPTIBLE|TASK_FREEZABLE,
74797480
NFS4_LOCK_MAXTIMEOUT);
7480-
freezer_count();
74817481
} while (!signalled());
74827482

74837483
remove_wait_queue(q, &waiter.wait);

fs/nfs/nfs4state.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,8 @@ int nfs4_wait_clnt_recover(struct nfs_client *clp)
13141314

13151315
refcount_inc(&clp->cl_count);
13161316
res = wait_on_bit_action(&clp->cl_state, NFS4CLNT_MANAGER_RUNNING,
1317-
nfs_wait_bit_killable, TASK_KILLABLE);
1317+
nfs_wait_bit_killable,
1318+
TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
13181319
if (res)
13191320
goto out;
13201321
if (clp->cl_cons_state < 0)

fs/nfs/pnfs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ static int pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo)
19081908
pnfs_layoutcommit_inode(lo->plh_inode, false);
19091909
return wait_on_bit_action(&lo->plh_flags, NFS_LAYOUT_RETURN,
19101910
nfs_wait_bit_killable,
1911-
TASK_KILLABLE);
1911+
TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
19121912
}
19131913

19141914
static void nfs_layoutget_begin(struct pnfs_layout_hdr *lo)
@@ -3192,7 +3192,7 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync)
31923192
status = wait_on_bit_lock_action(&nfsi->flags,
31933193
NFS_INO_LAYOUTCOMMITTING,
31943194
nfs_wait_bit_killable,
3195-
TASK_KILLABLE);
3195+
TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
31963196
if (status)
31973197
goto out;
31983198
}

fs/xfs/xfs_trans_ail.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -602,9 +602,9 @@ xfsaild(
602602

603603
while (1) {
604604
if (tout && tout <= 20)
605-
set_current_state(TASK_KILLABLE);
605+
set_current_state(TASK_KILLABLE|TASK_FREEZABLE);
606606
else
607-
set_current_state(TASK_INTERRUPTIBLE);
607+
set_current_state(TASK_INTERRUPTIBLE|TASK_FREEZABLE);
608608

609609
/*
610610
* Check kthread_should_stop() after we set the task state to
@@ -653,14 +653,14 @@ xfsaild(
653653
ailp->ail_target == ailp->ail_target_prev &&
654654
list_empty(&ailp->ail_buf_list)) {
655655
spin_unlock(&ailp->ail_lock);
656-
freezable_schedule();
656+
schedule();
657657
tout = 0;
658658
continue;
659659
}
660660
spin_unlock(&ailp->ail_lock);
661661

662662
if (tout)
663-
freezable_schedule_timeout(msecs_to_jiffies(tout));
663+
schedule_timeout(msecs_to_jiffies(tout));
664664

665665
__set_current_state(TASK_RUNNING);
666666

include/linux/completion.h

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ extern void wait_for_completion(struct completion *);
103103
extern void wait_for_completion_io(struct completion *);
104104
extern int wait_for_completion_interruptible(struct completion *x);
105105
extern int wait_for_completion_killable(struct completion *x);
106+
extern int wait_for_completion_state(struct completion *x, unsigned int state);
106107
extern unsigned long wait_for_completion_timeout(struct completion *x,
107108
unsigned long timeout);
108109
extern unsigned long wait_for_completion_io_timeout(struct completion *x,

0 commit comments

Comments
 (0)