Skip to content

Commit c912e19

Browse files
author
CKI KWF Bot
committed
Merge: Scheduler updates for 10.2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1424 JIRA: https://issues.redhat.com/browse/RHEL-110301 Depends: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1415 Tested: In addition to sched regression and functional tests this will be tested by the perf QE team. Scheduler updates for 10.2. This is up through 6.16 and includes some of the 6.17 merge window and fixes. Signed-off-by: Phil Auld <pauld@redhat.com> Approved-by: Joe Lawrence <joe.lawrence@redhat.com> Approved-by: Herton R. Krzesinski <herton@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 18f4377 + af99dee commit c912e19

File tree

15 files changed

+461
-411
lines changed

15 files changed

+461
-411
lines changed

include/linux/livepatch_sched.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,23 @@
33
#define _LINUX_LIVEPATCH_SCHED_H_
44

55
#include <linux/jump_label.h>
6-
#include <linux/static_call_types.h>
6+
#include <linux/sched.h>
77

88
#ifdef CONFIG_LIVEPATCH
99

1010
void __klp_sched_try_switch(void);
1111

12-
#if !defined(CONFIG_PREEMPT_DYNAMIC) || !defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
13-
1412
DECLARE_STATIC_KEY_FALSE(klp_sched_try_switch_key);
1513

16-
static __always_inline void klp_sched_try_switch(void)
14+
static __always_inline void klp_sched_try_switch(struct task_struct *curr)
1715
{
18-
if (static_branch_unlikely(&klp_sched_try_switch_key))
16+
if (static_branch_unlikely(&klp_sched_try_switch_key) &&
17+
READ_ONCE(curr->__state) & TASK_FREEZABLE)
1918
__klp_sched_try_switch();
2019
}
2120

22-
#endif /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */
23-
2421
#else /* !CONFIG_LIVEPATCH */
25-
static inline void klp_sched_try_switch(void) {}
26-
static inline void __klp_sched_try_switch(void) {}
22+
static inline void klp_sched_try_switch(struct task_struct *curr) {}
2723
#endif /* CONFIG_LIVEPATCH */
2824

2925
#endif /* _LINUX_LIVEPATCH_SCHED_H_ */

include/linux/psi_types.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ enum psi_aggregators {
8484
struct psi_group_cpu {
8585
/* 1st cacheline updated by the scheduler */
8686

87-
/* Aggregator needs to know of concurrent changes */
88-
seqcount_t seq ____cacheline_aligned_in_smp;
89-
9087
/* States of the tasks belonging to this group */
91-
unsigned int tasks[NR_PSI_TASK_COUNTS];
88+
unsigned int tasks[NR_PSI_TASK_COUNTS]
89+
____cacheline_aligned_in_smp;
9290

9391
/* Aggregate pressure state derived from the tasks */
9492
u32 state_mask;

include/linux/sched.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include <linux/seqlock_types.h>
4646
#include <linux/kcsan.h>
4747
#include <linux/rv.h>
48-
#include <linux/livepatch_sched.h>
4948
#include <linux/uidgid_types.h>
5049
#include <linux/tracepoint-defs.h>
5150
#include <asm/kmap_size.h>
@@ -2042,9 +2041,6 @@ extern int __cond_resched(void);
20422041

20432042
#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
20442043

2045-
void sched_dynamic_klp_enable(void);
2046-
void sched_dynamic_klp_disable(void);
2047-
20482044
DECLARE_STATIC_CALL(cond_resched, __cond_resched);
20492045

20502046
static __always_inline int _cond_resched(void)
@@ -2065,7 +2061,6 @@ static __always_inline int _cond_resched(void)
20652061

20662062
static inline int _cond_resched(void)
20672063
{
2068-
klp_sched_try_switch();
20692064
return __cond_resched();
20702065
}
20712066

@@ -2075,7 +2070,6 @@ static inline int _cond_resched(void)
20752070

20762071
static inline int _cond_resched(void)
20772072
{
2078-
klp_sched_try_switch();
20792073
return 0;
20802074
}
20812075

include/linux/sched/sd_flags.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,6 @@ SD_FLAG(SD_ASYM_PACKING, SDF_NEEDS_GROUPS)
153153
*/
154154
SD_FLAG(SD_PREFER_SIBLING, SDF_NEEDS_GROUPS)
155155

156-
/*
157-
* sched_groups of this level overlap
158-
*
159-
* SHARED_PARENT: Set for all NUMA levels above NODE.
160-
* NEEDS_GROUPS: Overlaps can only exist with more than one group.
161-
*/
162-
SD_FLAG(SD_OVERLAP, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
163-
164156
/*
165157
* Cross-node balancing
166158
*

include/linux/sched/topology.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ bool cpus_share_resources(int this_cpu, int that_cpu);
175175
typedef const struct cpumask *(*sched_domain_mask_f)(int cpu);
176176
typedef int (*sched_domain_flags_f)(void);
177177

178-
#define SDTL_OVERLAP 0x01
179-
180178
struct sd_data {
181179
struct sched_domain *__percpu *sd;
182180
struct sched_domain_shared *__percpu *sds;
@@ -187,7 +185,6 @@ struct sd_data {
187185
struct sched_domain_topology_level {
188186
sched_domain_mask_f mask;
189187
sched_domain_flags_f sd_flags;
190-
int flags;
191188
int numa_level;
192189
struct sd_data data;
193190
char *name;

include/trace/events/sched.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,39 @@ TRACE_EVENT(sched_skip_vma_numa,
745745
__entry->vm_end,
746746
__print_symbolic(__entry->reason, NUMAB_SKIP_REASON))
747747
);
748+
749+
TRACE_EVENT(sched_skip_cpuset_numa,
750+
751+
TP_PROTO(struct task_struct *tsk, nodemask_t *mem_allowed_ptr),
752+
753+
TP_ARGS(tsk, mem_allowed_ptr),
754+
755+
TP_STRUCT__entry(
756+
__array( char, comm, TASK_COMM_LEN )
757+
__field( pid_t, pid )
758+
__field( pid_t, tgid )
759+
__field( pid_t, ngid )
760+
__array( unsigned long, mem_allowed, BITS_TO_LONGS(MAX_NUMNODES))
761+
),
762+
763+
TP_fast_assign(
764+
memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN);
765+
__entry->pid = task_pid_nr(tsk);
766+
__entry->tgid = task_tgid_nr(tsk);
767+
__entry->ngid = task_numa_group_id(tsk);
768+
BUILD_BUG_ON(sizeof(nodemask_t) != \
769+
BITS_TO_LONGS(MAX_NUMNODES) * sizeof(long));
770+
memcpy(__entry->mem_allowed, mem_allowed_ptr->bits,
771+
sizeof(__entry->mem_allowed));
772+
),
773+
774+
TP_printk("comm=%s pid=%d tgid=%d ngid=%d mem_nodes_allowed=%*pbl",
775+
__entry->comm,
776+
__entry->pid,
777+
__entry->tgid,
778+
__entry->ngid,
779+
MAX_NUMNODES, __entry->mem_allowed)
780+
);
748781
#endif /* CONFIG_NUMA_BALANCING */
749782

750783
/*

kernel/livepatch/transition.c

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,13 @@ static unsigned int klp_signals_cnt;
2929

3030
/*
3131
* When a livepatch is in progress, enable klp stack checking in
32-
* cond_resched(). This helps CPU-bound kthreads get patched.
32+
* schedule(). This helps CPU-bound kthreads get patched.
3333
*/
34-
#if defined(CONFIG_PREEMPT_DYNAMIC) && defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL)
35-
36-
#define klp_cond_resched_enable() sched_dynamic_klp_enable()
37-
#define klp_cond_resched_disable() sched_dynamic_klp_disable()
38-
39-
#else /* !CONFIG_PREEMPT_DYNAMIC || !CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */
4034

4135
DEFINE_STATIC_KEY_FALSE(klp_sched_try_switch_key);
42-
EXPORT_SYMBOL(klp_sched_try_switch_key);
4336

44-
#define klp_cond_resched_enable() static_branch_enable(&klp_sched_try_switch_key)
45-
#define klp_cond_resched_disable() static_branch_disable(&klp_sched_try_switch_key)
46-
47-
#endif /* CONFIG_PREEMPT_DYNAMIC && CONFIG_HAVE_PREEMPT_DYNAMIC_CALL */
37+
#define klp_resched_enable() static_branch_enable(&klp_sched_try_switch_key)
38+
#define klp_resched_disable() static_branch_disable(&klp_sched_try_switch_key)
4839

4940
/*
5041
* This work can be performed periodically to finish patching or unpatching any
@@ -365,26 +356,18 @@ static bool klp_try_switch_task(struct task_struct *task)
365356

366357
void __klp_sched_try_switch(void)
367358
{
368-
if (likely(!klp_patch_pending(current)))
369-
return;
370-
371359
/*
372-
* This function is called from cond_resched() which is called in many
373-
* places throughout the kernel. Using the klp_mutex here might
374-
* deadlock.
375-
*
376-
* Instead, disable preemption to prevent racing with other callers of
377-
* klp_try_switch_task(). Thanks to task_call_func() they won't be
378-
* able to switch this task while it's running.
360+
* This function is called from __schedule() while a context switch is
361+
* about to happen. Preemption is already disabled and klp_mutex
362+
* can't be acquired.
363+
* Disabled preemption is used to prevent racing with other callers of
364+
* klp_try_switch_task(). Thanks to task_call_func() they won't be
365+
* able to switch to this task while it's running.
379366
*/
380-
preempt_disable();
367+
lockdep_assert_preemption_disabled();
381368

382-
/*
383-
* Make sure current didn't get patched between the above check and
384-
* preempt_disable().
385-
*/
386-
if (unlikely(!klp_patch_pending(current)))
387-
goto out;
369+
if (likely(!klp_patch_pending(current)))
370+
return;
388371

389372
/*
390373
* Enforce the order of the TIF_PATCH_PENDING read above and the
@@ -395,11 +378,7 @@ void __klp_sched_try_switch(void)
395378
smp_rmb();
396379

397380
klp_try_switch_task(current);
398-
399-
out:
400-
preempt_enable();
401381
}
402-
EXPORT_SYMBOL(__klp_sched_try_switch);
403382

404383
/*
405384
* Sends a fake signal to all non-kthread tasks with TIF_PATCH_PENDING set.
@@ -508,7 +487,7 @@ void klp_try_complete_transition(void)
508487
}
509488

510489
/* Done! Now cleanup the data structures. */
511-
klp_cond_resched_disable();
490+
klp_resched_disable();
512491
patch = klp_transition_patch;
513492
klp_complete_transition();
514493

@@ -560,7 +539,7 @@ void klp_start_transition(void)
560539
set_tsk_thread_flag(task, TIF_PATCH_PENDING);
561540
}
562541

563-
klp_cond_resched_enable();
542+
klp_resched_enable();
564543

565544
klp_signals_cnt = 0;
566545
}

0 commit comments

Comments
 (0)