Tested-by: Julien Desfossez <jdesfos...@digitalocean.com>
Not-Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org>
---
 kernel/sched/core.c | 35 ++++++++++++++++++++++++++++++++++-
 kernel/sched/fair.c |  9 +++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a3844e2e7379..56ba2ca4f922 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -106,6 +106,10 @@ static inline bool prio_less(struct task_struct *a, struct 
task_struct *b, bool
 
        int pa = __task_prio(a), pb = __task_prio(b);
 
+       trace_printk("(%s/%d;%d,%Lu,%Lu) ?< (%s/%d;%d,%Lu,%Lu)\n",
+                    a->comm, a->pid, pa, a->se.vruntime, a->dl.deadline,
+                    b->comm, b->pid, pb, b->se.vruntime, b->dl.deadline);
+
        if (-pa < -pb)
                return true;
 
@@ -296,12 +300,16 @@ static void __sched_core_enable(void)
 
        static_branch_enable(&__sched_core_enabled);
        stop_machine(__sched_core_stopper, (void *)true, NULL);
+
+       printk("core sched enabled\n");
 }
 
 static void __sched_core_disable(void)
 {
        stop_machine(__sched_core_stopper, (void *)false, NULL);
        static_branch_disable(&__sched_core_enabled);
+
+       printk("core sched disabled\n");
 }
 
 void sched_core_get(void)
@@ -5237,6 +5245,13 @@ pick_next_task(struct rq *rq, struct task_struct *prev, 
struct rq_flags *rf)
                        set_next_task(rq, next);
                }
 
+               trace_printk("pick pre selected (%u %u %u): %s/%d %lx\n",
+                            rq->core->core_task_seq,
+                            rq->core->core_pick_seq,
+                            rq->core_sched_seq,
+                            next->comm, next->pid,
+                            next->core_cookie);
+
                rq->core_pick = NULL;
                return next;
        }
@@ -5331,6 +5346,9 @@ pick_next_task(struct rq *rq, struct task_struct *prev, 
struct rq_flags *rf)
                                        rq->core->core_forceidle_seq++;
                        }
 
+                       trace_printk("cpu(%d): selected: %s/%d %lx\n",
+                                    i, p->comm, p->pid, p->core_cookie);
+
                        /*
                         * If this new candidate is of higher priority than the
                         * previous; and they're incompatible; we need to wipe
@@ -5347,6 +5365,8 @@ pick_next_task(struct rq *rq, struct task_struct *prev, 
struct rq_flags *rf)
                                rq->core->core_cookie = p->core_cookie;
                                max = p;
 
+                               trace_printk("max: %s/%d %lx\n", max->comm, 
max->pid, max->core_cookie);
+
                                if (old_max) {
                                        rq->core->core_forceidle = false;
                                        for_each_cpu(j, smt_mask) {
@@ -5368,6 +5388,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev, 
struct rq_flags *rf)
 
        /* Something should have been selected for current CPU */
        WARN_ON_ONCE(!next);
+       trace_printk("picked: %s/%d %lx\n", next->comm, next->pid, 
next->core_cookie);
 
        /*
         * Reschedule siblings
@@ -5409,13 +5430,21 @@ pick_next_task(struct rq *rq, struct task_struct *prev, 
struct rq_flags *rf)
                }
 
                /* Did we break L1TF mitigation requirements? */
-               WARN_ON_ONCE(!cookie_match(next, rq_i->core_pick));
+               if (unlikely(!cookie_match(next, rq_i->core_pick))) {
+                       trace_printk("[%d]: cookie mismatch. 
%s/%d/0x%lx/0x%lx\n",
+                                    rq_i->cpu, rq_i->core_pick->comm,
+                                    rq_i->core_pick->pid,
+                                    rq_i->core_pick->core_cookie,
+                                    rq_i->core->core_cookie);
+                       WARN_ON_ONCE(1);
+               }
 
                if (rq_i->curr == rq_i->core_pick) {
                        rq_i->core_pick = NULL;
                        continue;
                }
 
+               trace_printk("IPI(%d)\n", i);
                resched_curr(rq_i);
        }
 
@@ -5455,6 +5484,10 @@ static bool try_steal_cookie(int this, int that)
                if (p->core_occupation > dst->idle->core_occupation)
                        goto next;
 
+               trace_printk("core fill: %s/%d (%d->%d) %d %d %lx\n",
+                            p->comm, p->pid, that, this,
+                            p->core_occupation, dst->idle->core_occupation, 
cookie);
+
                p->on_rq = TASK_ON_RQ_MIGRATING;
                deactivate_task(src, p, 0);
                set_task_cpu(p, this);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index fddd7c44bbf3..ebeeebc4223a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10769,6 +10769,15 @@ static void se_fi_update(struct sched_entity *se, 
unsigned int fi_seq, bool forc
                        cfs_rq->forceidle_seq = fi_seq;
                }
 
+
+               if (root) {
+                       old = cfs_rq->min_vruntime_fi;
+                       new = cfs_rq->min_vruntime;
+                       root = false;
+                       trace_printk("cfs_rq(min_vruntime_fi) %lu->%lu\n",
+                                    old, new);
+               }
+
                cfs_rq->min_vruntime_fi = cfs_rq->min_vruntime;
        }
 }
-- 
2.30.0.280.ga3ce27912f-goog

Reply via email to