lkml.org 
[lkml]   [2023]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [External] Re: [PATCH] sched/core: Fix wrong warning check in rq_clock_start_loop_update()
On Sat, Oct 07, 2023 at 04:44:46PM +0800, Hao Jia wrote:

> > That is, would not something like the below make more sense?
>
> If we understand correctly, this may not work.
>
> After applying this patch, the following situation will trigger the
> rq->clock_update_flags < RQCF_ACT_SKIP warning.
>
> If rq_clock_skip_update() is called before __schedule(), so RQCF_REQ_SKIP of
> rq->clock_update_flags is set.
>
>
>
>
> __schedule() {
> rq_lock(rq, &rf); [rq->clock_update_flags is RQCF_REQ_SKIP]
> rq->clock_update_flags <<= 1;
> update_rq_clock(rq); [rq->clock_update_flags is RQCF_ACT_SKIP]
> + rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
> * At this time, rq->clock_update_flags = 0; *

Fixed easily enough, just change to:

rq->clock_updated_flags = RQCF_UPDATED;

>
> pick_next_task_fair
> set_next_entity
> update_load_avg
> assert_clock_updated() <---
> }

---
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a0a582c8cf8c..cf9eb1a26c22 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5357,8 +5357,6 @@ context_switch(struct rq *rq, struct task_struct *prev,
/* switch_mm_cid() requires the memory barriers above. */
switch_mm_cid(rq, prev, next);

- rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
-
prepare_lock_switch(rq, next, rf);

/* Here we just switch the register state and the stack. */
@@ -6596,6 +6594,7 @@ static void __sched notrace __schedule(unsigned int sched_mode)
/* Promote REQ to ACT */
rq->clock_update_flags <<= 1;
update_rq_clock(rq);
+ rq->clock_update_flags = RQCF_UPDATED;

switch_count = &prev->nivcsw;

@@ -6675,8 +6674,6 @@ static void __sched notrace __schedule(unsigned int sched_mode)
/* Also unlocks the rq: */
rq = context_switch(rq, prev, next, &rf);
} else {
- rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP);
-
rq_unpin_lock(rq, &rf);
__balance_callbacks(rq);
raw_spin_rq_unlock_irq(rq);
\
 
 \ /
  Last update: 2023-10-10 15:56    [W:0.061 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site