From: Chen Yu <yu.c.chen@intel.com>
To: Chunxin Zang <spring.cxz@gmail.com>
Cc: Honglei Wang <jameshongleiwang@126.com>, <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>, <juri.lelli@redhat.com>,
<vincent.guittot@linaro.org>, <dietmar.eggemann@arm.com>,
<rostedt@goodmis.org>, <bsegall@google.com>, <mgorman@suse.de>,
<bristot@redhat.com>, <vschneid@redhat.com>,
Mike Galbraith <efault@gmx.de>,
K Prateek Nayak <kprateek.nayak@amd.com>,
<linux-kernel@vger.kernel.org>, <yangchen11@lixiang.com>,
Jerry Zhou <zhouchunhua@lixiang.com>,
Chunxin Zang <zangchunxin@lixiang.com>
Subject: Re: [PATCH v2] sched/fair: Reschedule the cfs_rq when current is ineligible
Date: Thu, 13 Jun 2024 21:23:04 +0800 [thread overview]
Message-ID: <ZmryuDqw2fEhHNni@chenyu5-mobl2> (raw)
In-Reply-To: <112FECA8-5D21-406F-814C-ACBE63351CBB@gmail.com>
On 2024-06-13 at 20:02:37 +0800, Chunxin Zang wrote:
>
>
> > On Jun 13, 2024, at 19:54, Chen Yu <yu.c.chen@intel.com> wrote:
> >
> > On 2024-06-12 at 18:39:11 +0800, Chunxin Zang wrote:
> >>
> >>
> >>> On Jun 7, 2024, at 13:07, Chen Yu <yu.c.chen@intel.com> wrote:
> >>>
> >>> On 2024-05-29 at 22:18:06 +0800, Chunxin Zang wrote:
> >> The purpose of the modification is to increase preemption opportunities without breaking the
> >> RUN_TO_PARITY rule. However, it clearly introduces some additional preemptions, or perhaps
> >> there should be a check for the eligibility of the se. Also, to avoid overwriting the scheduling
> >> strategy in entity_tick, would a modification like the following be more appropriate?
> >>
> >
> > I wonder if we can only take care of the NO_RUN_TO_PARITY case? Something like this,
> >
> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> >> index 03be0d1330a6..5e49a15bbdd3 100644
> >> --- a/kernel/sched/fair.c
> >> +++ b/kernel/sched/fair.c
> >> @@ -745,6 +745,21 @@ int entity_eligible(struct cfs_rq *cfs_rq, struct sched_entity *se)
> >> return vruntime_eligible(cfs_rq, se->vruntime);
> >> }
> >>
> >> +static bool check_entity_need_preempt(struct cfs_rq *cfs_rq, struct sched_entity *se)
> >> +{
> > if (sched_feat(RUN_TO_PARITY) || cfs_rq->nr_running <= 1 ||
> > !entity_eligible(cfs_rq, se))
> > return false;
> >
> > return true;
> >
> > Thoughts?
> >
>
> This does indeed look better. In that case, do I need to make the changes this way and send
> out a version 3?
If you mean the following changes, maybe we can continue the discussion here.
This is just my 2 cents, not sure what others think of it. Anyway, I can launch some tests.
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8a5b1ae0aa55..c0fdb25f0695 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -744,6 +744,15 @@ int entity_eligible(struct cfs_rq *cfs_rq, struct sched_entity *se)
return vruntime_eligible(cfs_rq, se->vruntime);
}
+static bool check_curr_preempt(struct cfs_rq *cfs_rq, struct sched_entity *curr)
+{
+ if (sched_feat(RUN_TO_PARITY) || cfs_rq->nr_running <= 1 ||
+ !entity_eligible(cfs_rq, curr))
+ return false;
+
+ return true;
+}
+
static u64 __update_min_vruntime(struct cfs_rq *cfs_rq, u64 vruntime)
{
u64 min_vruntime = cfs_rq->min_vruntime;
@@ -5536,6 +5545,9 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
hrtimer_active(&rq_of(cfs_rq)->hrtick_timer))
return;
#endif
+
+ if (check_curr_preempt(cfs_rq, curr))
+ resched_curr(rq_of(cfs_rq));
}
@@ -8415,7 +8427,7 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
/*
* XXX pick_eevdf(cfs_rq) != se ?
*/
- if (pick_eevdf(cfs_rq) == pse)
+ if (check_curr_preempt(cfs_rq, se) || pick_eevdf(cfs_rq) == pse)
goto preempt;
return;
--
2.25.1
next prev parent reply other threads:[~2024-06-13 13:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 14:18 [PATCH v2] sched/fair: Reschedule the cfs_rq when current is ineligible Chunxin Zang
2024-06-04 7:28 ` kernel test robot
2024-06-07 5:07 ` Chen Yu
2024-06-12 10:39 ` Chunxin Zang
2024-06-13 11:54 ` Chen Yu
2024-06-13 12:02 ` Chunxin Zang
2024-06-13 13:23 ` Chen Yu [this message]
2024-06-13 13:46 ` Chunxin Zang
2024-06-14 3:11 ` K Prateek Nayak
2024-06-14 3:16 ` K Prateek Nayak
2024-06-14 4:14 ` Chen Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZmryuDqw2fEhHNni@chenyu5-mobl2 \
--to=yu.c.chen@intel.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=efault@gmx.de \
--cc=jameshongleiwang@126.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=spring.cxz@gmail.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yangchen11@lixiang.com \
--cc=zangchunxin@lixiang.com \
--cc=zhouchunhua@lixiang.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox