Skip to content

Commit 4a996d9

Browse files
committed
Merge tag 'sched-core-2024-07-16' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler updates from Ingo Molnar: - Update Daniel Bristot de Oliveira's entry in MAINTAINERS, and credit him in CREDITS - Harmonize the lock-yielding behavior on dynamically selected preemption models with static ones - Reorganize the code a bit: split out sched/syscalls.c to reduce the size of sched/core.c - Micro-optimize psi_group_change() - Fix set_load_weight() for SCHED_IDLE tasks - Misc cleanups & fixes * tag 'sched-core-2024-07-16' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched: Update MAINTAINERS and CREDITS sched/fair: set_load_weight() must also call reweight_task() for SCHED_IDLE tasks sched/psi: Optimise psi_group_change a bit sched/core: Drop spinlocks on contention iff kernel is preemptible sched/core: Move preempt_model_*() helpers from sched.h to preempt.h sched/balance: Skip unnecessary updates to idle load balancer's flags idle: Remove stale RCU comment sched/headers: Move struct pre-declarations to the beginning of the header sched/core: Clean up kernel/sched/sched.h a bit sched/core: Simplify prefetch_curr_exec_start() sched: Fix spelling in comments sched/syscalls: Split out kernel/sched/syscalls.c from kernel/sched/core.c
2 parents 0c182ac + db43a60 commit 4a996d9

File tree

23 files changed

+2267
-2179
lines changed

23 files changed

+2267
-2179
lines changed

CREDITS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ D: Driver for WaveFront soundcards (Turtle Beach Maui, Tropez, Tropez+)
271271
D: Various bugfixes and changes to sound drivers
272272
S: USA
273273

274+
N: Daniel Bristot de Oliveira
275+
D: Scheduler contributions, notably: SCHED_DEADLINE
276+
274277
N: Carlos Henrique Bauer
275278
E: chbauer@acm.org
276279
E: bauer@atlas.unisinos.br

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4728,7 +4728,9 @@
47284728
none - Limited to cond_resched() calls
47294729
voluntary - Limited to cond_resched() and might_sleep() calls
47304730
full - Any section that isn't explicitly preempt disabled
4731-
can be preempted anytime.
4731+
can be preempted anytime. Tasks will also yield
4732+
contended spinlocks (if the critical section isn't
4733+
explicitly preempt disabled beyond the lock itself).
47324734

47334735
print-fatal-signals=
47344736
[KNL] debug: print fatal signals

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20047,7 +20047,6 @@ R: Dietmar Eggemann <dietmar.eggemann@arm.com> (SCHED_NORMAL)
2004720047
R: Steven Rostedt <rostedt@goodmis.org> (SCHED_FIFO/SCHED_RR)
2004820048
R: Ben Segall <bsegall@google.com> (CONFIG_CFS_BANDWIDTH)
2004920049
R: Mel Gorman <mgorman@suse.de> (CONFIG_NUMA_BALANCING)
20050-
R: Daniel Bristot de Oliveira <bristot@redhat.com> (SCHED_DEADLINE)
2005120050
R: Valentin Schneider <vschneid@redhat.com> (TOPOLOGY)
2005220051
L: linux-kernel@vger.kernel.org
2005320052
S: Maintained

include/linux/preempt.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,45 @@ DEFINE_LOCK_GUARD_0(preempt, preempt_disable(), preempt_enable())
481481
DEFINE_LOCK_GUARD_0(preempt_notrace, preempt_disable_notrace(), preempt_enable_notrace())
482482
DEFINE_LOCK_GUARD_0(migrate, migrate_disable(), migrate_enable())
483483

484+
#ifdef CONFIG_PREEMPT_DYNAMIC
485+
486+
extern bool preempt_model_none(void);
487+
extern bool preempt_model_voluntary(void);
488+
extern bool preempt_model_full(void);
489+
490+
#else
491+
492+
static inline bool preempt_model_none(void)
493+
{
494+
return IS_ENABLED(CONFIG_PREEMPT_NONE);
495+
}
496+
static inline bool preempt_model_voluntary(void)
497+
{
498+
return IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY);
499+
}
500+
static inline bool preempt_model_full(void)
501+
{
502+
return IS_ENABLED(CONFIG_PREEMPT);
503+
}
504+
505+
#endif
506+
507+
static inline bool preempt_model_rt(void)
508+
{
509+
return IS_ENABLED(CONFIG_PREEMPT_RT);
510+
}
511+
512+
/*
513+
* Does the preemption model allow non-cooperative preemption?
514+
*
515+
* For !CONFIG_PREEMPT_DYNAMIC kernels this is an exact match with
516+
* CONFIG_PREEMPTION; for CONFIG_PREEMPT_DYNAMIC this doesn't work as the
517+
* kernel is *built* with CONFIG_PREEMPTION=y but may run with e.g. the
518+
* PREEMPT_NONE model.
519+
*/
520+
static inline bool preempt_model_preemptible(void)
521+
{
522+
return preempt_model_full() || preempt_model_rt();
523+
}
524+
484525
#endif /* __LINUX_PREEMPT_H */

include/linux/sched.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,47 +2064,6 @@ extern int __cond_resched_rwlock_write(rwlock_t *lock);
20642064
__cond_resched_rwlock_write(lock); \
20652065
})
20662066

2067-
#ifdef CONFIG_PREEMPT_DYNAMIC
2068-
2069-
extern bool preempt_model_none(void);
2070-
extern bool preempt_model_voluntary(void);
2071-
extern bool preempt_model_full(void);
2072-
2073-
#else
2074-
2075-
static inline bool preempt_model_none(void)
2076-
{
2077-
return IS_ENABLED(CONFIG_PREEMPT_NONE);
2078-
}
2079-
static inline bool preempt_model_voluntary(void)
2080-
{
2081-
return IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY);
2082-
}
2083-
static inline bool preempt_model_full(void)
2084-
{
2085-
return IS_ENABLED(CONFIG_PREEMPT);
2086-
}
2087-
2088-
#endif
2089-
2090-
static inline bool preempt_model_rt(void)
2091-
{
2092-
return IS_ENABLED(CONFIG_PREEMPT_RT);
2093-
}
2094-
2095-
/*
2096-
* Does the preemption model allow non-cooperative preemption?
2097-
*
2098-
* For !CONFIG_PREEMPT_DYNAMIC kernels this is an exact match with
2099-
* CONFIG_PREEMPTION; for CONFIG_PREEMPT_DYNAMIC this doesn't work as the
2100-
* kernel is *built* with CONFIG_PREEMPTION=y but may run with e.g. the
2101-
* PREEMPT_NONE model.
2102-
*/
2103-
static inline bool preempt_model_preemptible(void)
2104-
{
2105-
return preempt_model_full() || preempt_model_rt();
2106-
}
2107-
21082067
static __always_inline bool need_resched(void)
21092068
{
21102069
return unlikely(tif_need_resched());

include/linux/spinlock.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,10 @@ static __always_inline int spin_is_contended(spinlock_t *lock)
462462
*/
463463
static inline int spin_needbreak(spinlock_t *lock)
464464
{
465-
#ifdef CONFIG_PREEMPTION
465+
if (!preempt_model_preemptible())
466+
return 0;
467+
466468
return spin_is_contended(lock);
467-
#else
468-
return 0;
469-
#endif
470469
}
471470

472471
/*
@@ -479,11 +478,10 @@ static inline int spin_needbreak(spinlock_t *lock)
479478
*/
480479
static inline int rwlock_needbreak(rwlock_t *lock)
481480
{
482-
#ifdef CONFIG_PREEMPTION
481+
if (!preempt_model_preemptible())
482+
return 0;
483+
483484
return rwlock_is_contended(lock);
484-
#else
485-
return 0;
486-
#endif
487485
}
488486

489487
/*

kernel/sched/build_policy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@
5252
#include "cputime.c"
5353
#include "deadline.c"
5454

55+
#include "syscalls.c"

kernel/sched/clock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static notrace u64 sched_clock_remote(struct sched_clock_data *scd)
340340
this_clock = sched_clock_local(my_scd);
341341
/*
342342
* We must enforce atomic readout on 32-bit, otherwise the
343-
* update on the remote CPU can hit inbetween the readout of
343+
* update on the remote CPU can hit in between the readout of
344344
* the low 32-bit and the high 32-bit portion.
345345
*/
346346
remote_clock = cmpxchg64(&scd->clock, 0, 0);
@@ -444,7 +444,7 @@ notrace void sched_clock_tick_stable(void)
444444
}
445445

446446
/*
447-
* We are going deep-idle (irqs are disabled):
447+
* We are going deep-idle (IRQs are disabled):
448448
*/
449449
notrace void sched_clock_idle_sleep_event(void)
450450
{

0 commit comments

Comments
 (0)