mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	<linux-kernel@vger.kernel.org>, Mike Galbraith <efault@gmx.de>,
	<linux-tip-commits@vger.kernel.org>, <x86@kernel.org>
Subject: Re: [PATCH] sched/fair: Do not wakeup-preempt same-prio SCHED_OTHER tasks
Date: Tue, 26 Sep 2023 00:45:47 +0800	[thread overview]
Message-ID: <ZRG5O93PFsxzF2BQ@chenyu5-mobl2.ccr.corp.intel.com> (raw)
In-Reply-To: <ZRFp3EO2JUXtK6XB@gmail.com>

Hi Ingo,

On 2023-09-25 at 13:07:08 +0200, Ingo Molnar wrote:
> 
> Anyway, it's clear from these results that while many workloads hurt
> from our notion of wake-preemption, there's several ones that benefit
> from it, especially generic ones like phoronix-test-suite - which have
> no good way to turn off wakeup preemption (SCHED_BATCH might help though).
> 
> One way to approach this would be to instead of always doing
> wakeup-preemption (our current default), we could turn it around and
> only use it when it is clearly beneficial - such as signal delivery,
> or exec().
>
> The canonical way to solve this would be give *userspace* a way to
> signal that it's beneficial to preempt immediately, ie. yield(),
> but right now that interface is hurting tasks that only want to
> give other tasks a chance to run, without necessarily giving up
> their own right to run:
> 
>         se->deadline += calc_delta_fair(se->slice, se);
>

Do you mean we want to give hint to the scheduler that, in most cases
the tasks do not want to be wakeup-preempted, but some other tasks
want to keep current wakeup-preempt strategy?

If we want the current task to be preempted easier, we have to shrink
the current task's slice, which gives up its own right to run. If this
is the case, how about introducing negative se->slice, tasks has a
negative slice indicates that it wants to be wakeup-preempted,
and its real slice is the absolute value of se->slice.

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index f7c0d9cad6e0..019576da9737 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8120,7 +8120,7 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
 	 * Batch and idle tasks do not preempt non-idle tasks (their preemption
 	 * is driven by the tick):
 	 */
-	if (unlikely(p->policy != SCHED_NORMAL) || !sched_feat(WAKEUP_PREEMPTION))
+	if (unlikely(p->policy != SCHED_NORMAL) || || se->slice > 0 || !sched_feat(WAKEUP_PREEMPTION))
 		return;
 
 	find_matching_se(&se, &pse);

thanks,
Chenyu

  reply	other threads:[~2023-09-25 16:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10 13:24 [tip:sched/eevdf] [sched/fair] e0c2ff903c: phoronix-test-suite.blogbench.Write.final_score -34.8% regression kernel test robot
2023-08-11  1:11 ` Chen Yu
2023-08-11  2:42   ` Chen Yu
2023-08-14 13:29     ` Peter Zijlstra
2023-08-14 18:32       ` Mike Galbraith
2023-08-15 23:52         ` Peter Zijlstra
2023-08-16  3:54           ` Mike Galbraith
2023-08-16 12:37         ` Peter Zijlstra
2023-08-16 13:40           ` Peter Zijlstra
2023-08-16 15:38             ` Mike Galbraith
2023-08-16 20:04               ` Peter Zijlstra
2023-08-17  1:25                 ` Mike Galbraith
2023-08-17 15:10             ` [tip: sched/core] sched/eevdf: Curb wakeup-preemption tip-bot2 for Peter Zijlstra
2023-08-21 10:39               ` K Prateek Nayak
2023-08-21 15:30                 ` Mike Galbraith
2023-08-22  3:03                   ` K Prateek Nayak
2023-08-22  6:09                     ` Mike Galbraith
2023-08-25  6:41                       ` K Prateek Nayak
2023-09-19  9:02                       ` [PATCH] sched/fair: Do not wakeup-preempt same-prio SCHED_OTHER tasks Ingo Molnar
2023-09-19  9:48                         ` Mike Galbraith
2023-09-22 10:00                         ` kernel test robot
2023-09-25 11:07                           ` Ingo Molnar
2023-09-25 16:45                             ` Chen Yu [this message]
2023-08-18  1:09             ` [tip:sched/eevdf] [sched/fair] e0c2ff903c: phoronix-test-suite.blogbench.Write.final_score -34.8% regression Chen Yu
2023-08-22  6:48               ` Chen Yu
2023-08-22  7:07                 ` Chen Yu
2023-08-16  3:40       ` Chen Yu
2023-08-16  9:20         ` Peter Zijlstra
2023-08-14 12:49   ` Peter Zijlstra
2023-08-18  1:54     ` 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=ZRG5O93PFsxzF2BQ@chenyu5-mobl2.ccr.corp.intel.com \
    --to=yu.c.chen@intel.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.org \
    /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

Powered by JetHome